From 4ea5367da68bc231d1a907623782f730b4214e42 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Thu, 11 Jun 2026 12:21:17 +0000 Subject: [PATCH] =?UTF-8?q?Dispatch=20and=20map=20RdSAP-Schema-17.1=20cert?= =?UTF-8?q?s=20end-to-end=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 | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/datatypes/epc/domain/tests/test_from_rdsap_schema.py b/datatypes/epc/domain/tests/test_from_rdsap_schema.py index 6afea563..b71c58a8 100644 --- a/datatypes/epc/domain/tests/test_from_rdsap_schema.py +++ b/datatypes/epc/domain/tests/test_from_rdsap_schema.py @@ -1705,3 +1705,42 @@ class TestRdSap18_0ReducedFieldSynthesis: # Assert assert result.sap_heating.number_baths == expected_baths assert result.sap_heating.mixer_shower_count == expected_mixers + + +# --------------------------------------------------------------------------- +# RdSAP 17.1 Reduced-Field Synthesis (ADR-0028 — inherit-and-validate). 17.1 is +# the same pre-SAP10 reduced family as 18.0/20.0.0 and reuses the same inherited +# 20.0.0 coefficients via the shared `_synthesise_reduced_field_windows` core; +# its own band-4 rich certs validate the transfer. Each test name pins one +# synthesis assumption (Validation-Cohort rule: no same-spec lodged figure). +# --------------------------------------------------------------------------- + +_CORPUS_17_1 = os.path.join( + os.path.dirname(__file__), + "../../../../backend/epc_api/json_samples/RdSAP-Schema-17.1/corpus.jsonl", +) + + +def _load_17_1_corpus() -> list[Dict[str, Any]]: + if not os.path.exists(_CORPUS_17_1): + return [] + with open(_CORPUS_17_1) as f: + return [json.loads(line) for line in f if line.strip()] + + +class TestRdSap17_1ReducedFieldSynthesis: + + def test_cert_dispatches_and_maps_without_missing_required_field(self) -> None: + # Arrange — the placeholder 17.1 schema over-constrains (only 4/1000 + # parse) and `from_api_response` never dispatched RdSAP-Schema-17.1. + # Dispatch + required→optional must let a real cert through end-to-end. + corpus = _load_17_1_corpus() + if not corpus: + pytest.skip("no RdSAP-Schema-17.1 corpus harvested") + cert = corpus[0] + + # Act + result = EpcPropertyDataMapper.from_api_response(cert) + + # Assert + assert isinstance(result, EpcPropertyData)