From cd14751fdb5a27c1cc50001f70e42986ee8de43d Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Fri, 19 Jun 2026 13:42:02 +0000 Subject: [PATCH] =?UTF-8?q?Route=20age-band=20overrides=20to=20the=20right?= =?UTF-8?q?=20part,=20normalise,=20reject=20unknown=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 | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/domain/epc/test_construction_age_band_overlay.py b/tests/domain/epc/test_construction_age_band_overlay.py index 066244a6..bb66933e 100644 --- a/tests/domain/epc/test_construction_age_band_overlay.py +++ b/tests/domain/epc/test_construction_age_band_overlay.py @@ -7,6 +7,8 @@ the override's building part. from __future__ import annotations +import pytest + from datatypes.epc.domain.epc_property_data import BuildingPartIdentifier from domain.epc.property_overlays.construction_age_band_overlay import ( age_band_overlay_for, @@ -21,3 +23,38 @@ def test_age_band_overlays_the_main_building_part() -> None: assert simulation is not None overlay = simulation.building_parts[BuildingPartIdentifier.MAIN] assert overlay.construction_age_band == "B" + + +def test_age_band_overlay_targets_the_extension_building_part() -> None: + # Act — building_part 1 is the first extension. + simulation = age_band_overlay_for("L", 1) + + # Assert + assert simulation is not None + assert BuildingPartIdentifier.EXTENSION_1 in simulation.building_parts + assert ( + simulation.building_parts[BuildingPartIdentifier.EXTENSION_1] + .construction_age_band + == "L" + ) + + +def test_lowercase_age_band_is_normalised_to_its_letter_code() -> None: + # Act + simulation = age_band_overlay_for("d", 0) + + # Assert — the calculator upper-cases the band; the overlay stores it upper. + assert simulation is not None + assert ( + simulation.building_parts[BuildingPartIdentifier.MAIN].construction_age_band + == "D" + ) + + +@pytest.mark.parametrize("age_band_value", ["Z", "", "1900-1929", "Unknown"]) +def test_unrecognised_age_band_produces_no_overlay(age_band_value: str) -> None: + # Act + simulation = age_band_overlay_for(age_band_value, 0) + + # Assert + assert simulation is None