Use lodged window geometry for rich RdSAP-Schema-18.0 certs 🟥

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-11 11:41:19 +00:00
parent 51309328e6
commit 17cb06a2f9

View file

@ -1466,3 +1466,28 @@ class TestRdSap18_0ReducedFieldSynthesis:
# Assert
assert isinstance(result, EpcPropertyData)
def test_rich_cert_uses_lodged_window_area_for_geometry(self) -> None:
# Arrange — ADR-0028: 10/1000 18.0 certs lodge a per-window sap_windows
# array (window_area as a Measurement), all band-4 ("much more glazed").
# The placeholder 18.0 schema had NO sap_windows field, so this richest
# window data was dropped at parse and the cert modelled windowless. Those
# windows must use their lodged area as geometry (width = area, height =
# 1.0), not be synthesised.
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 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)