Re-date a building part's EPC age band from a landlord override 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-19 13:43:28 +00:00
parent b13166742d
commit e71df5df99

View file

@ -13,6 +13,14 @@ from datatypes.epc.domain.epc_property_data import BuildingPartIdentifier
from domain.epc.property_overlays.construction_age_band_overlay import (
age_band_overlay_for,
)
from domain.modelling.scoring.overlay_applicator import apply_simulations
from tests.domain.sap10_calculator.worksheet._elmhurst_worksheet_000490 import (
build_epc,
)
def _part(epc, identifier): # type: ignore[no-untyped-def]
return next(p for p in epc.sap_building_parts if p.identifier is identifier)
def test_age_band_overlays_the_main_building_part() -> None:
@ -58,3 +66,21 @@ def test_unrecognised_age_band_produces_no_overlay(age_band_value: str) -> None:
# Assert
assert simulation is None
def test_age_band_override_re_dates_the_main_part_only() -> None:
# Arrange — baseline main + extension are both band B; the landlord corrects
# the main building's age band to F (1976-1982).
baseline = build_epc()
overlay = age_band_overlay_for("F", 0)
assert overlay is not None
# Act
result = apply_simulations(baseline, [overlay])
# Assert — the main part is re-dated (its U-value cascade now keys on F); the
# extension is left untouched.
assert _part(result, BuildingPartIdentifier.MAIN).construction_age_band == "F"
assert (
_part(result, BuildingPartIdentifier.EXTENSION_1).construction_age_band == "B"
)