Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions unittests/test_highlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,21 +129,42 @@ def test_extraction(self, datafiles, get_ebd_keys_and_files: List[Tuple[str, str
# I tried really hard for 1.5 to get the parametrization right and then just gave up and came around with a
# different approach, called pytest-subtests: https://github.com/pytest-dev/pytest-subtests
for ebd_key, filename in get_ebd_keys_and_files:
with subtests.test(ebd_key): # this requires pytest-subtests to be installed (see tox.ini)
with subtests.test(ebd_key, key=ebd_key, file=filename):
# this requires pytest-subtests to be installed (see tox.ini)
issue_number: str
try:
docx_tables = get_ebd_docx_tables(datafiles, filename, ebd_key=ebd_key)
converter = DocxTableConverter(
docx_tables, ebd_key=ebd_key, chapter="Dummy Chapter", sub_chapter="Dummy Subchapter"
)
actual = converter.convert_docx_tables_to_ebd_table()
assert isinstance(actual, EbdTable)
# In the long run, all these catchers shall be removed.
except TableNotFoundError:
# https://github.com/Hochfrequenz/ebd_docx_to_table/issues/9
pass # ignore for now
except Exception as error: # for everything which is _not_ a TableNotFoundError
# In the long run, this pokemon catcher shall be removed.
# For not it allows us to quickly get an overview of how well the scraping works for a single docx.
except ValueError as value_error:
# Simply run the test, then see how many of the subtests pass and which are skipped.
# The skipped ones require developer analysis and code improvements.
# This library has probably reached v1.0.0 if this catch block is not necessary anymore.
error_msg = f"Error while scraping '{ebd_key}': {str(error)}"
match value_error.args[0]:
case "None is not in list":
# https://github.com/Hochfrequenz/ebd_docx_to_table/issues/20
issue_number = "20"
case "Exactly one of the entries in sub_rows has to have check_result.result True":
# https://github.com/Hochfrequenz/ebd_docx_to_table/issues/21
issue_number = "21"
case "The cell content '--' does not belong to a ja/nein cell":
# https://github.com/Hochfrequenz/ebd_docx_to_table/issues/23
issue_number = "23"
case _:
raise
except UnboundLocalError as unbound_error:
match unbound_error.args[0]:
case "cannot access local variable 'role' where it is not associated with a value":
# https://github.com/Hochfrequenz/ebd_docx_to_table/issues/22
issue_number = "22"
case _:
raise
error_msg = f"Error while scraping '{ebd_key}' (#{issue_number})"
pytest.skip(error_msg)