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