diff --git a/datatypes/epc/domain/tests/test_from_site_notes.py b/datatypes/epc/domain/tests/test_from_site_notes.py index be334e293..b5dd445b8 100644 --- a/datatypes/epc/domain/tests/test_from_site_notes.py +++ b/datatypes/epc/domain/tests/test_from_site_notes.py @@ -188,6 +188,39 @@ class TestGlazingTypeCoding: EpcPropertyDataMapper.from_site_notes(survey) +class TestMainFuelCoding: + """`from_site_notes` must int-code the PAS Hub main-heating `fuel` label to the + SAP10 fuel code the calculator's cascade routes via, not copy the raw label. A + raw label reaches the calculator as `MissingMainFuelType`; an unmapped one + strict-raises `UnmappedPasHubLabel` at the boundary. `Bulk LPG` was the last + residual label parse-raising in the Guinness cohort (issue #1558); `Mains Gas` + is the capitalised variant the newer `Fuel:` site-note form lodges. + """ + + @pytest.mark.parametrize( + "label, expected_code", + [ + ("Mains gas", 26), # standard mains-gas fuel code (landed #1554) + ("Mains Gas", 26), # `Fuel:` form capitalisation variant → same code + ("Bulk LPG", 27), # bulk LPG (Table 32 code 2), matches Elmhurst map + ("Electricity", 30), # standard-electricity fuel code + ], + ) + def test_label_maps_to_sap_code(self, label: str, expected_code: int) -> None: + data = load("pashub_rdsap_site_notes_example1.json") + data["heating_and_hot_water"]["main_heating"]["fuel"] = label + survey = from_dict(PasHubRdSapSiteNotes, data) + result = EpcPropertyDataMapper.from_site_notes(survey) + assert result.sap_heating.main_heating_details[0].main_fuel_type == expected_code + + def test_unknown_label_strict_raises(self) -> None: + data = load("pashub_rdsap_site_notes_example1.json") + data["heating_and_hot_water"]["main_heating"]["fuel"] = "Fusion reactor" + survey = from_dict(PasHubRdSapSiteNotes, data) + with pytest.raises(UnmappedPasHubLabel): + EpcPropertyDataMapper.from_site_notes(survey) + + class TestFromSiteNotesExample1: """ Fixture: pashub_rdsap_site_notes_example1.json