Merge pull request #1393 from Hestia-Homes/fix/rdsap-21-0-0-percent-draughtproofed

Normalize RdSAP percent_draughtproofed on the 21.0.0 path
This commit is contained in:
Jun-te Kim 2026-07-01 15:17:50 +01:00 committed by GitHub
commit e95c3cf906
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 0 deletions

View file

@ -2174,6 +2174,10 @@ class EpcPropertyDataMapper:
open_chimneys_count=schema.open_chimneys_count or 0,
insulated_door_count=schema.insulated_door_count,
draughtproofed_door_count=schema.draughtproofed_door_count,
# 21.0.0 lodges percent_draughtproofed but the mapper dropped it,
# unlike every other path (17.0/…/21.0.1). Understated the §2
# draughtproofing/infiltration credit.
percent_draughtproofed=schema.percent_draughtproofed,
led_fixed_lighting_bulbs_count=schema.led_fixed_lighting_bulbs_count or 0,
cfl_fixed_lighting_bulbs_count=schema.cfl_fixed_lighting_bulbs_count or 0,
incandescent_fixed_lighting_bulbs_count=schema.incandescent_fixed_lighting_bulbs_count,

View file

@ -0,0 +1,34 @@
"""Regression: the RdSAP-Schema-21.0.0 mapper must carry the lodged
percent_draughtproofed, like every other API path (17.0//21.0.1).
PRD #1385 (mapper normalization). 21.0.0 was the last path still dropping
`percent_draughtproofed` (top-level int, lodged by the schema), understating the
§2 draughtproofing/infiltration credit.
"""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
from datatypes.epc.domain.mapper import EpcPropertyDataMapper
# The harvested 21.0.0 sample lodges percent_draughtproofed=100.
_FIXTURE = Path("backend/epc_api/json_samples/RdSAP-Schema-21.0.0/epc.json")
def _load() -> dict[str, Any]:
data: dict[str, Any] = json.loads(_FIXTURE.read_text())
assert data["schema_type"] == "RdSAP-Schema-21.0.0"
return data
def test_21_0_0_carries_percent_draughtproofed() -> None:
data = _load()
assert data["percent_draughtproofed"] == 100
epc = EpcPropertyDataMapper.from_api_response(data)
# Was dropped to None on the 21.0.0 path; now carried through.
assert epc.percent_draughtproofed == 100