From a6f2ae99df61a6475784a50b2f2c0602b1c2e390 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Fri, 19 Jun 2026 14:06:52 +0000 Subject: [PATCH] =?UTF-8?q?Remap=20the=20primary=20heating=20system=20and?= =?UTF-8?q?=20compose=20the=20heating=20override=20trio=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../epc/test_main_heating_system_overlay.py | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/domain/epc/test_main_heating_system_overlay.py b/tests/domain/epc/test_main_heating_system_overlay.py index 1a55de61..0710837e 100644 --- a/tests/domain/epc/test_main_heating_system_overlay.py +++ b/tests/domain/epc/test_main_heating_system_overlay.py @@ -8,9 +8,17 @@ from __future__ import annotations import pytest +from domain.epc.property_overlays.main_fuel_overlay import fuel_overlay_for from domain.epc.property_overlays.main_heating_system_overlay import ( main_heating_overlay_for, ) +from domain.epc.property_overlays.water_heating_overlay import ( + water_heating_overlay_for, +) +from domain.modelling.scoring.overlay_applicator import apply_simulations +from tests.domain.sap10_calculator.worksheet._elmhurst_worksheet_000490 import ( + build_epc, +) def test_gas_combi_overlays_the_primary_heating_code() -> None: @@ -59,3 +67,39 @@ def test_unresolvable_or_unmodelled_heating_produces_no_overlay( # Assert assert simulation is None + + +def test_main_heating_override_remaps_the_primary_system_code() -> None: + # Arrange + baseline = build_epc() + overlay = main_heating_overlay_for("Gas boiler, regular", 0) + assert overlay is not None + + # Act + result = apply_simulations(baseline, [overlay]) + + # Assert — the calculator reads the code off main_heating_details[0]. + assert result.sap_heating.main_heating_details[0].sap_main_heating_code == 102 + + +def test_the_three_heating_overrides_compose_without_conflict() -> None: + # Arrange — main_fuel, water_heating and main_heating_system all fold onto one + # HeatingOverlay surface but set DISJOINT fields, so they compose (the + # field-disjoint design that makes precedence moot for these three). + baseline = build_epc() + overlays = [ + fuel_overlay_for("electricity", 0), + water_heating_overlay_for("Electric immersion, electricity", 0), + main_heating_overlay_for("Electric storage heaters, fan", 0), + ] + assert all(o is not None for o in overlays) + + # Act + result = apply_simulations(baseline, [o for o in overlays if o is not None]) + + # Assert — each override landed on its own field. + main = result.sap_heating.main_heating_details[0] + assert main.main_fuel_type == 29 + assert main.sap_main_heating_code == 404 + assert result.sap_heating.water_heating_code == 903 + assert result.sap_heating.water_heating_fuel == 29