diff --git a/datatypes/epc/domain/mapper.py b/datatypes/epc/domain/mapper.py index 7c867ed3..a1631ee2 100644 --- a/datatypes/epc/domain/mapper.py +++ b/datatypes/epc/domain/mapper.py @@ -1206,8 +1206,14 @@ class EpcPropertyDataMapper: orientation=w.orientation, window_type=w.window_type, glazing_type=w.glazing_type, - window_width=0.0, - window_height=0.0, + # ADR-0027: the 7 rich certs lodge a real per-window + # window_area (Measurement) — use it directly as + # geometry (width = area, height = 1.0, matching the + # synthesis convention) rather than the placeholder + # windowless 0x0 that modelled these data-richest certs + # as having no glazing at all. + window_width=_measurement_value(w.window_area), + window_height=1.0, draught_proofed=False, window_location=w.window_location, window_wall_type=0, diff --git a/datatypes/epc/domain/tests/test_from_rdsap_schema.py b/datatypes/epc/domain/tests/test_from_rdsap_schema.py index fb4cce54..924fdc30 100644 --- a/datatypes/epc/domain/tests/test_from_rdsap_schema.py +++ b/datatypes/epc/domain/tests/test_from_rdsap_schema.py @@ -1399,3 +1399,28 @@ class TestRdSap20_0_0ReducedFieldSynthesis: # Assert assert isinstance(result, EpcPropertyData) + + def test_rich_cert_uses_lodged_window_area_for_geometry(self) -> None: + # Arrange — ADR-0027: 7/1000 certs DO lodge a per-window sap_windows + # array (window_area as a Measurement). Those windows must use their + # lodged area as geometry (width = area, height = 1.0) rather than being + # synthesised — and must NOT be modelled windowless (width=height=0, + # the prior placeholder behaviour for the certs that actually carry the + # richest window data). + corpus = _load_20_0_0_corpus() + if not corpus: + pytest.skip("no RdSAP-Schema-20.0.0 corpus harvested") + cert = next((c for c in corpus if c.get("sap_windows")), None) + if cert is None: + pytest.skip("no corpus cert lodging sap_windows") + lodged = cert["sap_windows"] + expected_total = sum(w["window_area"]["value"] for w in lodged) + + # Act + result = EpcPropertyDataMapper.from_api_response(cert) + + # Assert — one domain window per lodged window, total glazed area + # (width x height, height=1) preserved from the lodged measurement. + assert len(result.sap_windows) == len(lodged) + total_area = sum(w.window_width * w.window_height for w in result.sap_windows) + assert total_area == pytest.approx(expected_total)