|
4 | 4 | from freezegun import freeze_time
|
5 | 5 |
|
6 | 6 | 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 |
7 | 8 | from unittests import path_to_test_edi_energy_mirror_repo, path_to_test_files_fv2310
|
8 | 9 |
|
9 | 10 |
|
@@ -47,3 +48,31 @@ def test_save_pruefi_map_to_toml(self):
|
47 | 48 | actual_pruefi_map = f.read()
|
48 | 49 | assert actual_pruefi_map == expected_pruefi_map
|
49 | 50 | 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