From 29f9a664a53726908d045572d2fbfcbcbccb398a Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Thu, 16 Apr 2026 14:19:01 +0000 Subject: [PATCH] =?UTF-8?q?Load=20HeatingAndHotWater=20from=20SiteNotes=20?= =?UTF-8?q?JSON=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/documents_parser/extractor.py | 7 ++ .../documents_parser/tests/test_extractor.py | 72 +++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/backend/documents_parser/extractor.py b/backend/documents_parser/extractor.py index 99c388e4..dd19746c 100644 --- a/backend/documents_parser/extractor.py +++ b/backend/documents_parser/extractor.py @@ -10,11 +10,15 @@ from datatypes.epc.surveys.pashub_rdsap_site_notes import ( FloorConstruction, FloorMeasurement, General, + HeatingAndHotWater, MainBuildingConstruction, MainBuildingMeasurements, + MainHeating, PasHubRdSapSiteNotes, RoofSpace, RoofSpaceDetail, + SecondaryHeating, + WaterHeating, Window, ) @@ -278,6 +282,9 @@ class PasHubRdSapSiteNotesExtractor: return windows + def extract_heating_and_hot_water(self) -> HeatingAndHotWater: + raise NotImplementedError + def _parse_window(self, window_id: int, data: List[str]) -> Window: height_raw = self._get_in(data, "Window height:") width_raw = self._get_in(data, "Window width:") diff --git a/backend/documents_parser/tests/test_extractor.py b/backend/documents_parser/tests/test_extractor.py index 52dc2c87..2076b500 100644 --- a/backend/documents_parser/tests/test_extractor.py +++ b/backend/documents_parser/tests/test_extractor.py @@ -13,11 +13,15 @@ from datatypes.epc.surveys.pashub_rdsap_site_notes import ( FloorConstruction, FloorMeasurement, General, + HeatingAndHotWater, MainBuildingConstruction, MainBuildingMeasurements, + MainHeating, PasHubRdSapSiteNotes, RoofSpace, RoofSpaceDetail, + SecondaryHeating, + WaterHeating, ) FIXTURES = os.path.join(os.path.dirname(__file__), "fixtures") @@ -336,3 +340,71 @@ class TestWindows: width_m=2.3, orientation="North West", ) + + +class TestHeatingAndHotWater: + @pytest.fixture + def hhw(self) -> HeatingAndHotWater: + return PasHubRdSapSiteNotesExtractor( + load_text_fixture() + ).extract_heating_and_hot_water() + + def test_product_id_parses_to_int(self, hhw: HeatingAndHotWater) -> None: + assert hhw.main_heating.product_id == 16839 + + def test_summer_efficiency_parses_to_float(self, hhw: HeatingAndHotWater) -> None: + assert hhw.main_heating.summer_efficiency == 0.0 + + def test_condensing_true(self, hhw: HeatingAndHotWater) -> None: + assert hhw.main_heating.condensing is True + + def test_fghrs_false(self, hhw: HeatingAndHotWater) -> None: + # multi-line label + assert hhw.main_heating.flue_gas_heat_recovery_system is False + + def test_secondary_fuel(self, hhw: HeatingAndHotWater) -> None: + assert hhw.secondary_heating.secondary_fuel == "No Secondary Heating" + + def test_water_heating_no_cylinder(self, hhw: HeatingAndHotWater) -> None: + assert hhw.water_heating.cylinder_size == "No Cylinder" + assert hhw.water_heating.insulation_type is None + assert hhw.water_heating.has_thermostat is None + + def test_full_heating_and_hot_water(self, hhw: HeatingAndHotWater) -> None: + assert hhw == HeatingAndHotWater( + main_heating=MainHeating( + selection_method="PCDF Search", + system_type="Boiler with radiators or underfloor heating", + product_id=16839, + manufacturer="Vaillant", + model="ecoTEC pro 28", + orig_manufacturer="Vaillant", + fuel="Mains gas", + summer_efficiency=0.0, + type="Combi", + condensing=True, + year="2005 - 2015", + mount="Wall", + open_flue="Room-sealed", + fan_assist=True, + status="Normal status for an actual product", + central_heating_pump_age="Unknown", + controls="Programmer, room thermostat and TRVs", + flue_gas_heat_recovery_system=False, + weather_compensator=False, + emitter="Radiators", + emitter_temperature="Unknown", + ), + secondary_heating=SecondaryHeating( + secondary_fuel="No Secondary Heating", + ), + water_heating=WaterHeating( + type="Regular", + system="From main heating 1", + cylinder_size="No Cylinder", + cylinder_measured_heat_loss=None, + insulation_type=None, + insulation_thickness_mm=None, + has_thermostat=None, + ), + )