insulation thickness can be string 🟥

This commit is contained in:
Daniel Roth 2026-04-15 14:26:09 +00:00
parent 155eab86e4
commit 160dec11b1
2 changed files with 53 additions and 0 deletions

View file

@ -172,6 +172,57 @@ def test_parse_rdsap_contract():
}
ND_THICKNESS_XML = """<RdSAP-Report xmlns="https://epbr.digital.communities.gov.uk/xsd/rdsap">
<Report-Header>
<Property>
<Address>
<Address-Line-1>1</Address-Line-1>
<Post-Town>Somewhere</Post-Town>
<Postcode>AB1 2CD</Postcode>
</Address>
</Property>
</Report-Header>
<SAP-Data>
<SAP-Property-Details>
<Property-Type>0</Property-Type>
<SAP-Building-Parts>
<SAP-Building-Part>
<Identifier>Main Dwelling</Identifier>
<Roof-Construction>4</Roof-Construction>
<Roof-Insulation-Location>2</Roof-Insulation-Location>
<Roof-Insulation-Thickness>ND</Roof-Insulation-Thickness>
<SAP-Floor-Dimensions>
<SAP-Floor-Dimension>
<Heat-Loss-Perimeter quantity="metres">10.0</Heat-Loss-Perimeter>
<Room-Height quantity="metres">2.5</Room-Height>
<Total-Floor-Area quantity="square metres">50.0</Total-Floor-Area>
<Floor>0</Floor>
<Party-Wall-Length>0</Party-Wall-Length>
</SAP-Floor-Dimension>
</SAP-Floor-Dimensions>
</SAP-Building-Part>
</SAP-Building-Parts>
</SAP-Property-Details>
</SAP-Data>
</RdSAP-Report>
"""
def test_parse_rdsap_nd_thickness():
# 'ND' (not determined) is a valid value in the wild for Roof-Insulation-Thickness
# — it should be retained as-is rather than raising
# arrange + act
result: SapPropertyDetails = parse_rdsap(ND_THICKNESS_XML)
# assert
assert result["building_parts"][0]["roof"] == {
"construction": 4,
"insulation_location": 2,
"insulation_thickness_mm": "ND",
}
def test_flatten_full():
# Two building parts; Main Dwelling has two floors + full roof,
# Extension has one floor + partial roof (no thickness)

View file

@ -1 +1,3 @@
PROPERTY_TYPE_LOOKUP = {0: "House", 1: "Bungalow", 2: "Flat", 3: "Maisonette"}
ROOF_CONSTRUCTION_LOOKUP = {}
ROOF_INSULATION_LOCATION_LOOKUP = {}