mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
insulation location can be string 🟩
This commit is contained in:
parent
9e43b9d16e
commit
6333c36a29
2 changed files with 57 additions and 4 deletions
|
|
@ -207,6 +207,41 @@ ND_THICKNESS_XML = """<RdSAP-Report xmlns="https://epbr.digital.communities.gov.
|
||||||
</RdSAP-Report>
|
</RdSAP-Report>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
ND_INSULATION_LOCATION_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>ND</Roof-Insulation-Location>
|
||||||
|
<Roof-Insulation-Thickness>250</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():
|
def test_parse_rdsap_nd_thickness():
|
||||||
# 'ND' (not determined) is a valid value in the wild for Roof-Insulation-Thickness
|
# 'ND' (not determined) is a valid value in the wild for Roof-Insulation-Thickness
|
||||||
|
|
@ -223,6 +258,21 @@ def test_parse_rdsap_nd_thickness():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_parse_rdsap_nd_location():
|
||||||
|
# 'ND' (not determined) is a valid value in the wild for Roof-Insulation-Location
|
||||||
|
# — it should be retained as-is rather than raising
|
||||||
|
|
||||||
|
# arrange + act
|
||||||
|
result: SapPropertyDetails = parse_rdsap(ND_INSULATION_LOCATION_XML)
|
||||||
|
|
||||||
|
# assert
|
||||||
|
assert result["building_parts"][0]["roof"] == {
|
||||||
|
"construction": 4,
|
||||||
|
"insulation_location": "ND",
|
||||||
|
"insulation_thickness_mm": 250,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_flatten_full():
|
def test_flatten_full():
|
||||||
# Two building parts; Main Dwelling has two floors + full roof,
|
# Two building parts; Main Dwelling has two floors + full roof,
|
||||||
# Extension has one floor + partial roof (no thickness)
|
# Extension has one floor + partial roof (no thickness)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ class Floor(TypedDict):
|
||||||
|
|
||||||
class Roof(TypedDict, total=False):
|
class Roof(TypedDict, total=False):
|
||||||
construction: int # TODO: map to str
|
construction: int # TODO: map to str
|
||||||
insulation_location: int # TODO: map to str
|
insulation_location: int | str # TODO: map to str
|
||||||
insulation_thickness_mm: float | str
|
insulation_thickness_mm: float | str
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -158,9 +158,12 @@ def parse_rdsap(xml_string: str) -> SapPropertyDetails:
|
||||||
)
|
)
|
||||||
|
|
||||||
if roof_ins_loc_text is not None:
|
if roof_ins_loc_text is not None:
|
||||||
roof_dict["insulation_location"] = _parse_int(
|
try:
|
||||||
roof_ins_loc_text, "Roof-Insulation-Location"
|
roof_dict["insulation_location"] = _parse_int(
|
||||||
)
|
roof_ins_loc_text, "Roof-Insulation-Location"
|
||||||
|
)
|
||||||
|
except ValueError:
|
||||||
|
roof_dict["insulation_location"] = roof_ins_loc_text
|
||||||
|
|
||||||
thickness = _parse_thickness_mm(roof_thickness_text)
|
thickness = _parse_thickness_mm(roof_thickness_text)
|
||||||
if thickness is not None:
|
if thickness is not None:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue