diff --git a/backend/documents_parser/tests/test_extractor.py b/backend/documents_parser/tests/test_extractor.py index be577f1bf..438c8a74d 100644 --- a/backend/documents_parser/tests/test_extractor.py +++ b/backend/documents_parser/tests/test_extractor.py @@ -537,6 +537,44 @@ class TestHeatingAndHotWater: ) +class TestMainHeatingFuelLabelVariant: + """The newer PAS Hub site-note form lodges the main-heating fuel under a + `Fuel:` label (with colon) rather than the usual `Fuel`. The extractor must + recognise both, else the fuel is silently dropped and the property presents + as fuel-less downstream — the 3 Guinness cohort "blank-fuel" residuals that + were really Mains Gas all along (issue #1558).""" + + def _section(self, fuel_label: str) -> list[str]: + return [ + "Heating & Hot Water", + "System type:", + "Boiler with radiators or underfloor heating", + fuel_label, + "Mains Gas", + "Ventilation", + ] + + def test_colon_fuel_label_captures_value(self) -> None: + # Arrange + tokens = self._section("Fuel:") + + # Act + hhw = PasHubRdSapSiteNotesExtractor(tokens).extract_heating_and_hot_water() + + # Assert + assert hhw.main_heating.fuel == "Mains Gas" + + def test_plain_fuel_label_still_captures_value(self) -> None: + # Arrange + tokens = self._section("Fuel") + + # Act + hhw = PasHubRdSapSiteNotesExtractor(tokens).extract_heating_and_hot_water() + + # Assert + assert hhw.main_heating.fuel == "Mains Gas" + + class TestVentilation: @pytest.fixture def ventilation(self) -> Ventilation: