mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Resolve electric CPSU from the property's fuel, keeping gas CPSU on 120 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fedae2ea00
commit
8b0176976d
2 changed files with 24 additions and 1 deletions
|
|
@ -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]:
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue