Route age-band overrides to the right part, normalise, reject unknown 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-19 13:42:02 +00:00
parent 406365753b
commit cd14751fdb

View file

@ -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