From 8b0176976de9970c797073693e6c0035a04188a2 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Wed, 1 Jul 2026 16:12:00 +0000 Subject: [PATCH] =?UTF-8?q?Resolve=20electric=20CPSU=20from=20the=20proper?= =?UTF-8?q?ty's=20fuel,=20keeping=20gas=20CPSU=20on=20120=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- scripts/reclassify_main_heating.py | 8 ++++++++ tests/scripts/test_reclassify_main_heating.py | 17 ++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/reclassify_main_heating.py b/scripts/reclassify_main_heating.py index a51743aa4..c958458b4 100644 --- a/scripts/reclassify_main_heating.py +++ b/scripts/reclassify_main_heating.py @@ -26,13 +26,21 @@ from __future__ import annotations import argparse from collections.abc import Iterable +from typing import Optional from sqlalchemy import Connection, text from domain.epc.property_overrides.main_heating_guard import main_heating_guard +from domain.epc.property_overrides.main_heating_system_type import ( + MainHeatingSystemType, +) from scripts.e2e_common import build_engine, load_env +def electric_cpsu_for(description: str, main_fuel: Optional[str]) -> Optional[str]: + raise NotImplementedError + + def main_heating_corrections( stored: Iterable[tuple[str, str]], ) -> dict[str, str]: diff --git a/tests/scripts/test_reclassify_main_heating.py b/tests/scripts/test_reclassify_main_heating.py index 12ce4254d..8c172d0c5 100644 --- a/tests/scripts/test_reclassify_main_heating.py +++ b/tests/scripts/test_reclassify_main_heating.py @@ -11,7 +11,10 @@ from domain.epc.property_overrides.main_heating_guard import main_heating_guard from domain.epc.property_overrides.main_heating_system_type import ( MainHeatingSystemType, ) -from scripts.reclassify_main_heating import main_heating_corrections +from scripts.reclassify_main_heating import ( + electric_cpsu_for, + main_heating_corrections, +) def test_garbage_drawer_rows_are_remapped_to_faithful_archetypes() -> None: @@ -85,6 +88,18 @@ def test_every_guard_target_round_trips_to_a_resolvable_archetype() -> None: assert simulation.heating.sap_main_heating_code is not None, description +def test_electric_cpsu_is_resolved_from_the_fuel_not_the_description() -> None: + # "Boiler: A/C rated CPSU" is identical bar the band — the electric/gas split is + # fuel-determined (the pure-string guard can't see it), so the reclassify keys + # on the property's main_fuel override: electricity → Electric CPSU (192); + # mains gas / unknown → keep Gas CPSU (120). A non-CPSU boiler is ignored here + # (the guard handles "NA" electric boilers) — ADR-0045. + assert electric_cpsu_for("boiler: a rated cpsu", "electricity") == "Electric CPSU" + assert electric_cpsu_for("boiler: c rated cpsu", "mains gas") is None + assert electric_cpsu_for("boiler: c rated cpsu", None) is None + assert electric_cpsu_for("boiler: a rated na", "electricity") is None + + def test_already_corrected_rows_need_no_change() -> None: # Act / Assert — idempotent. assert (