|
7 | 7 | from fundamend.models.anwendungshandbuch import Anwendungsfall, Anwendungshandbuch, Bedingung, Paket, UbBedingung |
8 | 8 | from fundamend.reader import AhbReader |
9 | 9 |
|
| 10 | +from .conftest import is_private_submodule_checked_out |
| 11 | + |
10 | 12 |
|
11 | 13 | @pytest.mark.parametrize( |
12 | 14 | "ahb_xml_file_path, expected_date", |
@@ -193,3 +195,28 @@ def test_anwendungshandbuch_hashable(ahb_xml_file_path: Path) -> None: |
193 | 195 | assert isinstance(hash_code, int) |
194 | 196 | hash_collection = set() |
195 | 197 | hash_collection.add(ahb) |
| 198 | + |
| 199 | + |
| 200 | +_xml_submodule_root: Path = Path(__file__).parent.parent / "xml-migs-and-ahbs" |
| 201 | + |
| 202 | + |
| 203 | +@pytest.mark.snapshot() |
| 204 | +def test_sanitizing_all_awf_beschreibungen(snapshot: SnapshotAssertion) -> None: |
| 205 | + """this test makes changes to the sanitation code visible.""" |
| 206 | + if not is_private_submodule_checked_out(): |
| 207 | + pytest.skip("Skipping test because of missing private submodule") |
| 208 | + all_sanitized_awf_beschreibungen: set[str] = set() |
| 209 | + for ahb_file_path in _xml_submodule_root.rglob("**/*AHB*.xml"): |
| 210 | + reader = AhbReader(ahb_file_path) |
| 211 | + ahb = reader.read() |
| 212 | + for awf in ahb.anwendungsfaelle: |
| 213 | + if awf.is_outdated: |
| 214 | + continue |
| 215 | + all_sanitized_awf_beschreibungen.add(awf.beschreibung) |
| 216 | + # If you're unhappy with any specific entry in this list, better write a new unit test case in |
| 217 | + # test_utils.py / test_anwendungsfall_beschreibung_normalization (add more parametrization). |
| 218 | + # If the snapshot test fails because of updated data, just run |
| 219 | + # tox -e snapshots |
| 220 | + # and commit the updated .ambr file. |
| 221 | + distinct_beschreibungen_as_list = list(sorted(all_sanitized_awf_beschreibungen)) |
| 222 | + snapshot.assert_match(distinct_beschreibungen_as_list) |
0 commit comments