Load Windows from SiteNotes JSON 🟥

This commit is contained in:
Daniel Roth 2026-04-16 14:15:11 +00:00
parent c0801b9e07
commit 4a415ab4a2
2 changed files with 48 additions and 0 deletions

View file

@ -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]]:

View file

@ -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",
)