Skip to content

Commit

Permalink
Add test for locale-agnostic PDF preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
cydanil committed Jul 12, 2021
1 parent 57c4e7b commit a1546f4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: sudo pip3 install -r development.in

- name: Test with pytest
run: xvfb-run -a pytest -vv tests/test_*
run: LANGUAGE=de_DE.utf-8 xvfb-run -a pytest -vv tests/test_*

- name: Check imports ordering
run: >
Expand Down
32 changes: 32 additions & 0 deletions tests/test_pdf_exporter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""This test may leave marks in the user preferences file."""
import os
os.environ['LANGUAGE'] = 'de_DE.utf-8' # must happend before Gourmet import

from gourmet.gglobals import gourmetdir
from gourmet.plugins.import_export.pdf_plugin.pdf_exporter import PdfPrefGetter # noqa: import not at top of file

def test_get_args_from_opts(tmp_path):
gourmetdir = tmp_path
pref_getter = PdfPrefGetter()

options = (['Papiergröße:', 'Letter'],
['_Ausrichtung:', 'Hochformat'],
['_Schriftgröße:', 10],
['Seiten-Layout', 'Eben'],
['Linker Rand:', 70.86614173228347],
['Rechter Rand:', 70.86614173228347],
['Oberer Rand:', 70.86614173228347],
['Unterer Rand:', 70.86614173228347])

expected = {'pagesize': 'letter',
'pagemode': 'portrait',
'base_font_size': 10,
'mode': ('column', 1),
'left_margin': 70.86614173228347,
'right_margin': 70.86614173228347,
'top_margin': 70.86614173228347,
'bottom_margin': 70.86614173228347}

ret = pref_getter.get_args_from_opts(options)

assert ret == expected

0 comments on commit a1546f4

Please sign in to comment.