From 46d1f8bbb22f9da3796db19e56556c2e8dbd275c Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Fri, 19 Jun 2026 13:45:31 +0000 Subject: [PATCH] =?UTF-8?q?Guarantee=20every=20classifier=20age-band=20val?= =?UTF-8?q?ue=20maps=20to=20an=20overlay=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../epc/test_construction_age_band_overlay.py | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/domain/epc/test_construction_age_band_overlay.py b/tests/domain/epc/test_construction_age_band_overlay.py index 7527b9ea..3408900b 100644 --- a/tests/domain/epc/test_construction_age_band_overlay.py +++ b/tests/domain/epc/test_construction_age_band_overlay.py @@ -9,7 +9,12 @@ from __future__ import annotations import pytest -from datatypes.epc.domain.epc_property_data import BuildingPartIdentifier +from datatypes.epc.domain.epc_property_data import ( + BuildingPartIdentifier, + EpcPropertyData, + SapBuildingPart, +) +from domain.epc.construction_age_band import ConstructionAgeBand from domain.epc.property_overlays.construction_age_band_overlay import ( age_band_overlay_for, ) @@ -19,7 +24,9 @@ from tests.domain.sap10_calculator.worksheet._elmhurst_worksheet_000490 import ( ) -def _part(epc, identifier): # type: ignore[no-untyped-def] +def _part( + epc: EpcPropertyData, identifier: BuildingPartIdentifier +) -> SapBuildingPart: return next(p for p in epc.sap_building_parts if p.identifier is identifier) @@ -84,3 +91,19 @@ def test_age_band_override_re_dates_the_main_part_only() -> None: assert ( _part(result, BuildingPartIdentifier.EXTENSION_1).construction_age_band == "B" ) + + +@pytest.mark.parametrize( + "member", [m for m in ConstructionAgeBand if m is not ConstructionAgeBand.UNKNOWN] +) +def test_every_resolvable_age_band_value_decodes_to_an_overlay( + member: ConstructionAgeBand, +) -> None: + # A classifier emits a ConstructionAgeBand value; if the overlay can't decode + # it the override silently no-ops. Every non-UNKNOWN member must resolve. + + # Act + simulation = age_band_overlay_for(member.value, 0) + + # Assert + assert simulation is not None