Skip to content

Commit

Permalink
test: test jinja
Browse files Browse the repository at this point in the history
  • Loading branch information
daxartio committed Dec 16, 2024
1 parent f909ced commit 2fdb063
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ jobs:
- name: Install python dependencies
run: pip install poetry && poetry install -E win
- name: Generate mo files
run: poetry run poe generate-mo generate-version
run: poetry run poe generate-mo
- name: Generate version file
run: poetry run poe generate-version
- name: Build
run: poetry run python builder.py build
- name: Generate installer
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ jobs:
- name: Install python dependencies
run: pip install poetry && poetry install -E win
- name: Generate mo files
run: poetry run poe generate-mo generate-version
run: poetry run poe generate-mo
- name: Generate version file
run: poetry run poe generate-version
- name: Build
run: poetry run python builder.py build
- name: Generate installer
Expand Down
3 changes: 1 addition & 2 deletions sportorg/libs/template/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def finalize(thing):


def get_text_from_path(path, **kwargs):
custom_encoding = locale.getdefaultlocale()[1]
# custom_encoding = 'cp1251'
custom_encoding = locale.getdefaultlocale()[1] or "utf-8"
with open(path, errors="ignore") as f:
html = f.read().encode(custom_encoding, "ignore").decode(errors="ignore")

Expand Down
20 changes: 20 additions & 0 deletions tests/test_templates.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from sportorg.common.template import get_text_from_file
from sportorg.models.constant import RentCards
from sportorg.models.memory import get_current_race_index, races
from sportorg.modules.backup.file import File


def test_generate_report():
File("tests/data/test.json").open()
races_dict = [r.to_dict() for r in races()]

result = get_text_from_file(
"reports/1_results.html",
race=races_dict[get_current_race_index()],
races=races_dict,
rent_cards=list(RentCards().get()),
current_race=get_current_race_index(),
selected={"persons": []},
)

assert result

0 comments on commit 2fdb063

Please sign in to comment.