Resolve a landlord mains-gas override to the primary fuel code 🟥

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-19 12:07:32 +00:00
parent 360e069386
commit 240d7b1025
2 changed files with 41 additions and 0 deletions

View file

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

View file

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