"""The Landlord-Override water-heating → heating Simulation Overlay mapping. A water-heating value resolves to the SAP `water_heating_code` (system) and `water_heating_fuel` the calculator reads; the overlay is whole-dwelling. """ from __future__ import annotations import pytest from domain.epc.property_overlays.water_heating_overlay import ( water_heating_overlay_for, ) from domain.epc.property_overrides.water_heating_type import WaterHeatingType from domain.modelling.scoring.overlay_applicator import apply_simulations from tests.domain.sap10_calculator.worksheet._elmhurst_worksheet_000490 import ( build_epc, ) def test_from_main_system_mains_gas_overlays_water_heating() -> None: # Act simulation = water_heating_overlay_for("From main system, mains gas", 0) # Assert — "from main system" is water_heating_code 901, mains gas fuel 26. assert simulation is not None assert simulation.heating is not None assert simulation.heating.water_heating_code == 901 assert simulation.heating.water_heating_fuel == 26 @pytest.mark.parametrize( ("water_heating_value", "code", "fuel"), [ ("From main system, electricity", 901, 29), ("Electric immersion, electricity", 903, 29), ], ) def test_water_heating_systems_decode_to_their_codes( water_heating_value: str, code: int, fuel: int ) -> None: # Act simulation = water_heating_overlay_for(water_heating_value, 0) # Assert assert simulation is not None assert simulation.heating is not None assert simulation.heating.water_heating_code == code assert simulation.heating.water_heating_fuel == fuel @pytest.mark.parametrize( ("water_heating_value", "code", "fuel"), [ ("From main system, oil", 901, 28), ("From main system, LPG (bulk)", 901, 27), ("From main system, bottled LPG", 901, 3), ("From main system, house coal", 901, 33), # "boiler/circulator for water heating only" is SAP Table 4a code 911. ("Gas boiler/circulator, mains gas", 911, 26), ], ) def test_more_water_heating_combos_decode_to_their_codes( water_heating_value: str, code: int, fuel: int ) -> None: # Act simulation = water_heating_overlay_for(water_heating_value, 0) # Assert assert simulation is not None assert simulation.heating is not None assert simulation.heating.water_heating_code == code assert simulation.heating.water_heating_fuel == fuel @pytest.mark.parametrize("water_heating_value", ["Unknown", ""]) def test_unresolvable_water_heating_produces_no_overlay( water_heating_value: str, ) -> None: # Act simulation = water_heating_overlay_for(water_heating_value, 0) # Assert assert simulation is None def test_water_heating_override_remaps_the_hot_water_arrangement() -> None: # Arrange — landlord correction: HW is a separate electric immersion. baseline = build_epc() overlay = water_heating_overlay_for("Electric immersion, electricity", 0) assert overlay is not None # Act result = apply_simulations(baseline, [overlay]) # Assert — the calculator reads these off sap_heating. assert result.sap_heating.water_heating_code == 903 assert result.sap_heating.water_heating_fuel == 29 @pytest.mark.parametrize( "member", [m for m in WaterHeatingType if m is not WaterHeatingType.UNKNOWN] ) def test_every_resolvable_water_heating_value_decodes( member: WaterHeatingType, ) -> None: # Act simulation = water_heating_overlay_for(member.value, 0) # Assert assert simulation is not None