mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
74 lines
2.7 KiB
Python
74 lines
2.7 KiB
Python
from backend.ecmk_fetcher.xml_processor import parse_rdsap
|
|
|
|
|
|
SAMPLE_XML = """<RdSAP-Report xmlns="https://epbr.digital.communities.gov.uk/xsd/rdsap">
|
|
<Report-Header>
|
|
<Property>
|
|
<Address>
|
|
<Address-Line-1>1</Address-Line-1>
|
|
<Address-Line-2>Fake Avenue</Address-Line-2>
|
|
<Post-Town>Random</Post-Town>
|
|
<Postcode>AB24 5CD</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>
|
|
|
|
<SAP-Floor-Dimensions>
|
|
<SAP-Floor-Dimension>
|
|
<Heat-Loss-Perimeter>25.31</Heat-Loss-Perimeter>
|
|
<Room-Height>2.46</Room-Height>
|
|
<Total-Floor-Area>43.61</Total-Floor-Area>
|
|
<Party-Wall-Length>0</Party-Wall-Length>
|
|
</SAP-Floor-Dimension>
|
|
|
|
<SAP-Floor-Dimension>
|
|
<Heat-Loss-Perimeter>26.16</Heat-Loss-Perimeter>
|
|
<Room-Height>2.44</Room-Height>
|
|
<Total-Floor-Area>42.33</Total-Floor-Area>
|
|
<Party-Wall-Length>0</Party-Wall-Length>
|
|
</SAP-Floor-Dimension>
|
|
</SAP-Floor-Dimensions>
|
|
|
|
<Roof-Construction>4</Roof-Construction>
|
|
<Roof-Insulation-Location>2</Roof-Insulation-Location>
|
|
<Roof-Insulation-Thickness>100mm</Roof-Insulation-Thickness>
|
|
</SAP-Building-Part>
|
|
</SAP-Building-Parts>
|
|
|
|
</SAP-Property-Details>
|
|
</SAP-Data>
|
|
</RdSAP-Report>
|
|
"""
|
|
|
|
|
|
def test_parse_rdsap_wide_flat_contract():
|
|
# arrange + act
|
|
result = parse_rdsap(SAMPLE_XML)
|
|
|
|
# assert
|
|
assert result == {
|
|
"address": "1, Fake Avenue, Random, AB24 5CD",
|
|
"property_type": "House",
|
|
# Main Dwelling - floor 0
|
|
"main_dwelling_floor_index_0_area_m2": 43.61,
|
|
"main_dwelling_floor_index_0_height_m": 2.46,
|
|
"main_dwelling_floor_index_0_heat_loss_perimeter_m": 25.31,
|
|
"main_dwelling_floor_index_0_party_wall_length_m": 0.0,
|
|
# Main Dwelling - floor 1
|
|
"main_dwelling_floor_index_1_area_m2": 42.33,
|
|
"main_dwelling_floor_index_1_height_m": 2.44,
|
|
"main_dwelling_floor_index_1_heat_loss_perimeter_m": 26.16,
|
|
"main_dwelling_floor_index_1_party_wall_length_m": 0.0,
|
|
# Roof (building-level, repeated across floors or stored once)
|
|
"main_dwelling_roof_construction": "4",
|
|
"main_dwelling_roof_insulation_location": "2",
|
|
"main_dwelling_roof_insulation_thickness": "100mm",
|
|
}
|