diff --git a/tests/repositories/property/test_landlord_override_overlays.py b/tests/repositories/property/test_landlord_override_overlays.py index 1f790aa88..99d0d3b82 100644 --- a/tests/repositories/property/test_landlord_override_overlays.py +++ b/tests/repositories/property/test_landlord_override_overlays.py @@ -7,11 +7,15 @@ that fold onto the lodged EPC — per component, partial, skipping unmapped rows from __future__ import annotations from datatypes.epc.domain.epc_property_data import BuildingPartIdentifier +from domain.modelling.scoring.overlay_applicator import apply_simulations from repositories.property.landlord_override_overlays import overlays_from from repositories.property.property_overrides_reader import ( ResolvedPropertyOverride, ResolvedPropertyOverrides, ) +from tests.domain.sap10_calculator.worksheet._elmhurst_worksheet_000490 import ( + build_epc, +) def test_roof_type_row_produces_a_roof_overlay() -> None: @@ -143,3 +147,27 @@ def test_unresolvable_rows_are_skipped() -> None: # Assert assert overlays == [] + + +def test_main_fuel_override_wins_over_a_heating_archetype_natural_fuel() -> None: + # A heating-system override drags a natural fuel (a solid-fuel room heater + # defaults to house coal, RdSAP main_fuel 33), but an explicit main_fuel + # override must win. apply_simulations is last-wins and the override rows + # arrive in arbitrary order, so overlays_from must apply main_fuel AFTER + # main_heating_system — otherwise the natural-fuel default clobbers the + # explicit fuel (ADR-0041). The rows here are in the order that exposes it. + baseline = build_epc() + overrides = ResolvedPropertyOverrides( + rows=( + ResolvedPropertyOverride("main_fuel", 0, "smokeless coal"), + ResolvedPropertyOverride( + "main_heating_system", 0, "Solid fuel room heater, closed" + ), + ) + ) + + # Act + result = apply_simulations(baseline, overlays_from(overrides)) + + # Assert — the explicit fuel (smokeless coal 15) wins over the coal default. + assert result.sap_heating.main_heating_details[0].main_fuel_type == 15