diff --git a/tests/domain/modelling/test_heating_recommendation.py b/tests/domain/modelling/test_heating_recommendation.py index 4f1a321a6..4a4687580 100644 --- a/tests/domain/modelling/test_heating_recommendation.py +++ b/tests/domain/modelling/test_heating_recommendation.py @@ -23,9 +23,11 @@ from tests.domain.sap10_calculator.worksheet._elmhurst_worksheet_000490 import ( build_epc, ) -# Electricity main-fuel code (Elmhurst → SAP10) and the Table 4a SAP code an -# existing (non-HHR) electric storage system lodges. +# Electricity fuel codes and the Table 4a SAP code an existing (non-HHR) +# electric storage system lodges. 30 is the SAP Table 12 code (used by +# Elmhurst / cascade); 29 is the raw gov-API enum that some certs carry. _ELECTRICITY = 30 +_API_ELECTRICITY = 29 _OLD_STORAGE_SAP_CODE = 402 @@ -138,6 +140,24 @@ def test_hhr_storage_bundle_carries_the_product_cost_and_contingency() -> None: assert abs(option.cost.contingency_rate - 0.26) <= 1e-9 +def test_on_gas_street_electric_dwelling_yields_hhr_storage_bundle() -> None: + # Arrange — electrically heated dwelling whose cert carries the raw API + # fuel code (29) instead of the SAP Table 12 code (30), AND has a mains- + # gas connection at the street (mains_gas=True, the default for 000490). + # Bug: off_gas = not True = False; electric_main = 29 == 30 = False → + # HHRSH incorrectly blocked. Fix: key on main_fuel_type not in _GAS_FUEL_CODES. + baseline: EpcPropertyData = _electric_storage_baseline() + baseline.sap_heating.main_heating_details[0].main_fuel_type = _API_ELECTRICITY + + # Act + recommendation: Recommendation | None = recommend_heating(baseline, _StubProducts()) + + # Assert — dwelling heats electrically (not with gas) → HHRSH must be offered. + assert recommendation is not None + options = {o.measure_type.value: o for o in recommendation.options} + assert "high_heat_retention_storage_heaters" in options + + def _gas_boiler_house() -> EpcPropertyData: """A 000490 mains-gas combi dwelling, explicitly a House — ASHP-eligible.""" epc: EpcPropertyData = build_epc()