diff --git a/backend/documents_parser/extractor.py b/backend/documents_parser/extractor.py index 59a84686..f7da5d46 100644 --- a/backend/documents_parser/extractor.py +++ b/backend/documents_parser/extractor.py @@ -15,6 +15,7 @@ from datatypes.epc.surveys.pashub_rdsap_site_notes import ( PasHubRdSapSiteNotes, RoofSpace, RoofSpaceDetail, + Window, ) @@ -260,6 +261,9 @@ class PasHubRdSapSiteNotesExtractor: extensions=extensions if extensions else None, ) + def extract_windows(self) -> List[Window]: + raise NotImplementedError + def _parse_insulation_thickness( self, val: Optional[str] ) -> tuple[Optional[int], Optional[str]]: diff --git a/backend/documents_parser/tests/test_extractor.py b/backend/documents_parser/tests/test_extractor.py index 0061e436..52dc2c87 100644 --- a/backend/documents_parser/tests/test_extractor.py +++ b/backend/documents_parser/tests/test_extractor.py @@ -292,3 +292,47 @@ class TestRoofSpace: ) ], ) + + +class TestWindows: + @pytest.fixture + def windows(self) -> list: + return PasHubRdSapSiteNotesExtractor(load_text_fixture()).extract_windows() + + def test_window_count(self, windows: list) -> None: + assert len(windows) == 8 + + def test_ids_are_sequential(self, windows: list) -> None: + assert [w.id for w in windows] == list(range(1, 9)) + + def test_first_window_location(self, windows: list) -> None: + assert windows[0].location == "Main Building" + + def test_extension_window_location(self, windows: list) -> None: + assert windows[3].location == "Extension 1" + + def test_height_parses_to_float(self, windows: list) -> None: + assert windows[0].height_m == 1.2 + + def test_draught_proofed_true(self, windows: list) -> None: + assert windows[0].draught_proofed is True + + def test_permanent_shutters_false(self, windows: list) -> None: + assert windows[0].permanent_shutters is False + + def test_first_window_full(self, windows: list) -> None: + from datatypes.epc.surveys.pashub_rdsap_site_notes import Window + assert windows[0] == Window( + id=1, + location="Main Building", + wall_type="External wall", + glazing_type="Double glazing, Unknown install date", + window_type="Window", + frame_type="Wooden or PVC", + glazing_gap="16 mm or more", + draught_proofed=True, + permanent_shutters=False, + height_m=1.2, + width_m=2.3, + orientation="North West", + )