Skip to content

Commit

Permalink
Add Test Case for Segment ID Parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-kklein committed May 19, 2024
1 parent 58c8062 commit 21eacde
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion unittests/test_ahb_sub_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from docx.table import Table

from kohlrahbi.ahbtable.ahbsubtable import AhbSubTable
from kohlrahbi.read_functions import get_all_paragraphs_and_tables
from kohlrahbi.read_functions import get_ahb_table, get_all_paragraphs_and_tables
from kohlrahbi.unfoldedahb import UnfoldedAhb


class TestAhbSubTable:
Expand Down Expand Up @@ -41,3 +42,20 @@ def test_from_table(self) -> None:
assert isinstance(ahb_sub_table, AhbSubTable)
else:
raise TypeError("You did not pass a docx table instance.")

def test_segment_id_parsing(self) -> None:
"""
https://github.com/Hochfrequenz/kohlrahbi/issues/304
"""
ahb_file_path: Path = Path(__file__).parent / Path(
"test-files/docx_files/UTILMDAHBStrom-informatorischeLesefassung1.2a_99991231_20240403.docx"
)
assert ahb_file_path.exists()
doc = docx.Document(str(ahb_file_path)) # Creating word reader object.
ahb_table = get_ahb_table(document=doc, pruefi="55109")
assert ahb_table is not None
unfolded_ahb = UnfoldedAhb.from_ahb_table(ahb_table=ahb_table, pruefi="55109")
assert unfolded_ahb is not None
flat_ahb = unfolded_ahb.convert_to_flat_ahb()
assert flat_ahb is not None
assert any(l for l in flat_ahb.lines if l.segment_id is not None)

0 comments on commit 21eacde

Please sign in to comment.