From bfedcd54dc4bc096609e1ee016ae084878bb14d2 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Thu, 11 Jun 2026 11:49:38 +0000 Subject: [PATCH] =?UTF-8?q?Synthesise=20glazing=20from=20the=20glazed=5Far?= =?UTF-8?q?ea=20band=20for=20windowless=2018.0=20certs=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../domain/tests/test_from_rdsap_schema.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/datatypes/epc/domain/tests/test_from_rdsap_schema.py b/datatypes/epc/domain/tests/test_from_rdsap_schema.py index b111c3f0..3c64edc2 100644 --- a/datatypes/epc/domain/tests/test_from_rdsap_schema.py +++ b/datatypes/epc/domain/tests/test_from_rdsap_schema.py @@ -1491,3 +1491,37 @@ class TestRdSap18_0ReducedFieldSynthesis: 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) + + def test_band_normal_synthesises_total_glazing_at_0_148_of_floor_area( + self, + ) -> None: + # Arrange — ADR-0028 (inherit-and-validate): 18.0 lodges only a + # glazed_area *band* (1 = Normal, 958/1000), not window m². The inherited + # 20.0.0 coefficient — synthesised total glazing = 0.148 x total_floor_area + # — is reused unchanged; validated against 18.0's own band-4 rich certs + # (observed 0.223 ~ 0.148 x 1.51). A band-1 cert with no per-window array. + corpus = _load_18_0_corpus() + if not corpus: + pytest.skip("no RdSAP-Schema-18.0 corpus harvested") + cert = next( + ( + c + for c in corpus + if not c.get("sap_windows") and c.get("glazed_area") == 1 + ), + None, + ) + if cert is None: + pytest.skip("no band-1 corpus cert without sap_windows") + tfa = float(cert["total_floor_area"]) + + # Act + result = EpcPropertyDataMapper.from_api_response(cert) + + # Assert — 4 windows (N/E/S/W avg-orientation split), each height 1.0, + # total width-sum (= total area, height=1) at 0.148 x TFA. + assert len(result.sap_windows) == 4 + assert all(w.window_height == 1.0 for w in result.sap_windows) + assert sorted(w.orientation for w in result.sap_windows) == [1, 3, 5, 7] + total_area = sum(w.window_width * w.window_height for w in result.sap_windows) + assert total_area == pytest.approx(0.148 * tfa)