From 240d7b102513e8d9430d760b0add12d24184a20e Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Fri, 19 Jun 2026 12:07:32 +0000 Subject: [PATCH] =?UTF-8?q?Resolve=20a=20landlord=20mains-gas=20override?= =?UTF-8?q?=20to=20the=20primary=20fuel=20code=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) --- .../property_overlays/main_fuel_overlay.py | 22 +++++++++++++++++++ tests/domain/epc/test_main_fuel_overlay.py | 19 ++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 domain/epc/property_overlays/main_fuel_overlay.py create mode 100644 tests/domain/epc/test_main_fuel_overlay.py diff --git a/domain/epc/property_overlays/main_fuel_overlay.py b/domain/epc/property_overlays/main_fuel_overlay.py new file mode 100644 index 00000000..4d721865 --- /dev/null +++ b/domain/epc/property_overlays/main_fuel_overlay.py @@ -0,0 +1,22 @@ +"""Map a Landlord-Override main-fuel value to a heating Simulation Overlay. + +A main-fuel value is one canonical gov-EPC `main_fuel` description ("mains gas", +"electricity", …). The calculator reads the dwelling's primary fuel from +`main_heating_details[0].main_fuel_type` as the RdSAP **int code**, so the +overlay decomposes the value into that code and emits a whole-dwelling +`HeatingOverlay` (fuel is not a per-building-part attribute, so `building_part` +is ignored). Codes follow the modern RdSAP-20/21 `(not community)` family the +gov-EPC API baseline uses. Unresolvable values produce no overlay. +""" + +from __future__ import annotations + +from typing import Optional + +from domain.modelling.simulation import EpcSimulation + + +def fuel_overlay_for( + main_fuel_value: str, building_part: int +) -> Optional[EpcSimulation]: + raise NotImplementedError diff --git a/tests/domain/epc/test_main_fuel_overlay.py b/tests/domain/epc/test_main_fuel_overlay.py new file mode 100644 index 00000000..96072c1d --- /dev/null +++ b/tests/domain/epc/test_main_fuel_overlay.py @@ -0,0 +1,19 @@ +"""The Landlord-Override main-fuel → heating Simulation Overlay mapping. + +A main-fuel value resolves to the RdSAP `main_fuel_type` int code the calculator +reads from the dwelling's primary heating system; the overlay is whole-dwelling. +""" + +from __future__ import annotations + +from domain.epc.property_overlays.main_fuel_overlay import fuel_overlay_for + + +def test_mains_gas_overlays_the_primary_fuel() -> None: + # Act + simulation = fuel_overlay_for("mains gas", 0) + + # Assert — mains gas (not community) is RdSAP main_fuel code 26. + assert simulation is not None + assert simulation.heating is not None + assert simulation.heating.main_fuel_type == 26