From 14c777f37b03e15599081e7022a85a9a4aebf121 Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Thu, 25 Jun 2026 20:34:35 +0000 Subject: [PATCH] =?UTF-8?q?Map=20sap=5Fversion=20on=20full-SAP=20certs=20s?= =?UTF-8?q?o=20pre-SAP10=20rebaseline=20fires=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) --- .../epc/domain/tests/test_from_sap_schema.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/datatypes/epc/domain/tests/test_from_sap_schema.py b/datatypes/epc/domain/tests/test_from_sap_schema.py index d05b7d78c..dd8f021dd 100644 --- a/datatypes/epc/domain/tests/test_from_sap_schema.py +++ b/datatypes/epc/domain/tests/test_from_sap_schema.py @@ -78,6 +78,24 @@ class TestFromSapSchema17_1Tracer: assert result.total_floor_area_m2 == 68.0 +class TestFromSapSchema17_1RebaselineFields: + """The calc-affecting categoricals the WIP mapper dropped (ADR-0037). Their + absence left the full-SAP family un-rebaselined and mis-scored, producing the + portfolio-796 "impossible downgrade".""" + + def test_maps_sap_version_so_pre_sap10_rebaseline_can_fire(self) -> None: + # The full-SAP family lodges SAP 2012 (sap_version 9.92). Without it on + # the EpcPropertyData, CalculatorRebaseliner cannot fire trigger (a) + # (`sap_version < 10.2` → Effective = Calculated), so Effective + # Performance wrongly stays equal to the lodged SAP-2012 score while the + # plan models the SAP-10.2 calc — the impossible downgrade. + schema = from_dict(SapSchema17_1, load("sap_17_1.json")) + + result = EpcPropertyDataMapper.from_sap_schema_17_1(schema) + + assert result.sap_version == 9.92 + + class TestFullSapHasHotWaterCylinderFallback: """Some full-SAP certs (e.g. SAP-Schema-17.0 cert 8265-7433-3220-9736-7902) omit the top-level `has_hot_water_cylinder` and lodge it only under