"""The flat-roof reclassify maps a stated depth onto its Table 16 thickness member, leaves depthless / non-flat rows alone, and is idempotent (#1376 / ADR-0041).""" from __future__ import annotations from scripts.reclassify_flat_roof_thickness import flat_thickness_corrections def test_flat_depth_rows_are_corrected_to_the_thickness_member() -> None: # Arrange — flat roofs with a real depth (currently on the age-band-default # value), alongside depthless flat rows and a pitched row that must be left. stored = [ ("flat: 150mm", "Flat, insulated (assumed)"), ("flat: 50mm", "Flat, insulated (assumed)"), ("flat: unknown", "Flat, insulated (assumed)"), ("flat: as built", "Flat, insulated (assumed)"), ("flat: no insulation", "Flat, no insulation"), ("pitchednormalloftaccess: 100mm", "Pitched, 100 mm loft insulation"), ] # Act corrections = flat_thickness_corrections(stored) # Assert — only the flat-depth rows are re-mapped, to their thickness member. assert corrections == { "flat: 150mm": "Flat, 150 mm insulation", "flat: 50mm": "Flat, 50 mm insulation", } def test_a_non_rung_depth_snaps_to_the_nearest_tabulated_rung() -> None: # RdSAP Table 16 uses the nearest tabulated thickness <= the stated depth. # Act / Assert assert flat_thickness_corrections( [("flat: 60mm", "Flat, insulated (assumed)")] ) == {"flat: 60mm": "Flat, 50 mm insulation"} def test_already_corrected_flat_rows_need_no_change() -> None: # Act / Assert — idempotent. assert ( flat_thickness_corrections([("flat: 150mm", "Flat, 150 mm insulation")]) == {} )