From 450ecfb9b4aea3915b0dcb1fbfb3f3aafdc3f39d Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Mon, 29 Jun 2026 22:58:35 +0000 Subject: [PATCH] =?UTF-8?q?Lock=20full-SAP=2016.x=20tariff=20translation?= =?UTF-8?q?=20via=20the=20assessment=5Ftype=20gate=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Confirming regression test for the prime-lead suspicion (SAP-16.x meter over-rating). A full-SAP-shaped 16.x cert lodges the SAP energy_tariff code space; the assessment_type=SAP gate routes it to the full-SAP mapper, which translates the code (1=standard → STANDARD) rather than raw-passing it to the RdSAP normaliser (where 1="dual" → SEVEN_HOUR, the over-rating bug). No fix needed — the gate already prevents the drop; this pins that behaviour. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../epc/domain/tests/test_from_sap_schema.py | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/datatypes/epc/domain/tests/test_from_sap_schema.py b/datatypes/epc/domain/tests/test_from_sap_schema.py index ec9981009..957cc4a44 100644 --- a/datatypes/epc/domain/tests/test_from_sap_schema.py +++ b/datatypes/epc/domain/tests/test_from_sap_schema.py @@ -870,6 +870,27 @@ class TestFullSapSchema16xRouting: assert epc.door_count == 1 assert epc.dwelling_type == "Detached house" + def test_full_sap_16_x_electricity_tariff_is_translated_not_passed_through( + self, + ) -> None: + # A full-SAP 16.x cert lodges the SAP `energy_tariff` code space, not the + # RdSAP `meter_type` one. Routing it through the full-SAP mapper (via the + # assessment_type=SAP gate) must apply `_sap_17_1_meter_type`: tariff 1 = + # standard → STANDARD. Were it raw-passed to the RdSAP normaliser, code 1 + # = "dual" → SEVEN_HOUR (the prime-lead over-rating bug this guards). + from domain.sap10_calculator.tables.table_12a import ( + Tariff, + tariff_from_meter_type, + ) + + data = load("sap_16_0_full.json") # electricity_tariff = 1 (standard) + + epc = EpcPropertyDataMapper.from_api_response(data) + + assert tariff_from_meter_type(epc.sap_energy_source.meter_type) is ( + Tariff.STANDARD + ) + def test_reduced_16_x_cert_unaffected_by_full_sap_routing(self) -> None: # Arrange — a reduced 16.2 cert (assessment_type RdSAP) must stay on the # RdSAP path, keeping its top-level property_type.