Skip to content

Commit b0c9f34

Browse files
committed
add test for function get_pruefidentifikator_list
1 parent a07f461 commit b0c9f34

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

unittests/test_ahb.py

+29
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from freezegun import freeze_time
55

66
from kohlrahbi.ahb import find_pruefidentifikatoren, get_ahb_documents_path, save_pruefi_map_to_toml
7+
from kohlrahbi.ahb.ahb_xml_functions import get_pruefidentifikator_list
78
from unittests import path_to_test_edi_energy_mirror_repo, path_to_test_files_fv2310
89

910

@@ -47,3 +48,31 @@ def test_save_pruefi_map_to_toml(self):
4748
actual_pruefi_map = f.read()
4849
assert actual_pruefi_map == expected_pruefi_map
4950
expected_output_path.unlink()
51+
52+
@pytest.mark.snapshot
53+
def test_get_pruefidentifikator_list(self):
54+
"""
55+
Test get_pruefidentifikator_list function with a sample XML file.
56+
"""
57+
# Test with non-existent file
58+
with pytest.raises(FileNotFoundError) as exc_info:
59+
get_pruefidentifikator_list(Path("non_existent.xml"))
60+
assert "XML file not found" in str(exc_info.value)
61+
62+
# Test with actual XML file
63+
xml_path = Path("xml-migs-and-ahbs/UTILMD/UTILMD_AHB_Strom_2_1_2024_10_01_2024_09_20.xml")
64+
pruefis = get_pruefidentifikator_list(xml_path)
65+
66+
# Verify the result is a list of strings
67+
assert isinstance(pruefis, list)
68+
assert all(isinstance(p, str) for p in pruefis)
69+
70+
# Verify the list is not empty and contains expected format
71+
assert len(pruefis) > 0
72+
assert all(p.isdigit() for p in pruefis) # Pruefidentifikator should be numeric
73+
74+
# Verify the list is sorted
75+
assert pruefis == sorted(pruefis)
76+
77+
# Verify there are no duplicates
78+
assert len(pruefis) == len(set(pruefis))

0 commit comments

Comments
 (0)