Map to domain from site notes - test mapping of full object 🟩

This commit is contained in:
Daniel Roth 2026-04-13 13:02:57 +00:00
parent 517e1287a8
commit f875714c2b

View file

@ -4,7 +4,20 @@ from typing import Any, Dict
import pytest
from datatypes.epc.domain import Dwelling
from datatypes.epc.domain import (
Dwelling,
FloorDimensions,
FloorDetails,
HotWaterSystem,
LightingDetails,
MainHeatingSystem,
PropertyDetails,
RenewablesDetails,
RoofDetails,
VentilationDetails,
WallDetails,
WindowDetails,
)
from datatypes.epc.domain.mapper import DwellingMapper
from datatypes.epc.schema.tests.helpers import from_dict
from datatypes.epc.surveys.pashub_rdsap_site_notes import PasHubRdSapSiteNotes
@ -264,6 +277,101 @@ class TestFromExample1:
def test_waste_water_heat_recovery(self, dwelling: Dwelling) -> None:
assert dwelling.waste_water_heat_recovery == "None"
def test_full_mapping(self, dwelling: Dwelling) -> None:
assert dwelling == Dwelling(
property_details=PropertyDetails(
property_type="House",
built_form="Mid-terrace",
tenure="Rented Social",
number_of_storeys=2,
construction_age_band="I: 1996 - 2002",
transaction_type="None of the Above",
terrain_type="Suburban",
mains_gas_available=True,
electricity_smart_meter=True,
gas_smart_meter=True,
),
floor_dimensions=[
FloorDimensions(total_floor_area_m2=24.78, height_m=2.37, heat_loss_perimeter_m=14.21, party_wall_length_m=6.15),
FloorDimensions(total_floor_area_m2=24.78, height_m=2.35, heat_loss_perimeter_m=14.21, party_wall_length_m=6.15),
],
walls=WallDetails(
construction_type="Cavity",
insulation_type="As built",
thickness_mm=280,
party_wall_construction_type="Cavity Masonry, Unfilled",
),
roof=RoofDetails(
construction_type="Pitched roof (Slates or tiles), Access to loft",
insulation_at="Joists",
insulation_thickness_mm=100,
has_rooms_in_roof=False,
),
floor=FloorDetails(
construction_type="Suspended, not timber",
insulation_type="As Built",
),
windows=[
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="South East", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=1.36, width_m=1.0),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="South East", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=1.33, width_m=0.96),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North West", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=1.04, width_m=0.96),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North West", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=1.02, width_m=0.97),
],
main_heating=MainHeatingSystem(
fuel="Mains gas",
system_type="Boiler with radiators or underfloor heating",
boiler_type="Regular",
manufacturer="Vaillant",
model="ecoFIT sustain 415",
condensing=True,
controls="Programmer, room thermostat and TRVs",
flue_gas_heat_recovery=False,
weather_compensator=False,
emitter="Radiators",
),
hot_water=HotWaterSystem(
source="From main heating 1",
cylinder_size="Normal (90-130 litres)",
insulation_type="Factory fitted",
insulation_thickness_mm=12,
has_thermostat=True,
),
secondary_heating=None,
ventilation=VentilationDetails(
ventilation_type="Natural",
number_of_open_flues=0,
number_of_closed_flues=0,
number_of_boiler_flues=0,
number_of_other_flues=0,
number_of_extract_fans=2,
number_of_passive_vents=0,
number_of_flueless_gas_fires=0,
has_fixed_air_conditioning=False,
pressure_test="No test",
draught_lobby=False,
),
renewables=RenewablesDetails(
has_photovoltaic=False,
has_solar_hot_water=False,
has_wind_turbines=False,
has_hydro=False,
number_of_pv_batteries=0,
),
lighting=LightingDetails(
number_of_led_bulbs=5,
number_of_cfl_bulbs=4,
number_of_incandescent_bulbs=0,
),
number_of_habitable_rooms=2,
number_of_external_doors=2,
number_of_open_chimneys=0,
number_of_blocked_chimneys=0,
has_conservatory=False,
number_of_baths=1,
number_of_showers=1,
waste_water_heat_recovery="None",
)
class TestFromExample2:
"""With extensions; combi boiler (no cylinder); mechanical extract ventilation."""
@ -348,3 +456,103 @@ class TestFromExample2:
def test_showers(self, dwelling: Dwelling) -> None:
assert dwelling.number_of_showers == 1
def test_full_mapping(self, dwelling: Dwelling) -> None:
assert dwelling == Dwelling(
property_details=PropertyDetails(
property_type="House",
built_form="Mid-terrace",
tenure="Rented Social",
number_of_storeys=2,
construction_age_band="1950-1966",
transaction_type="Grant-Scheme (ECO, RHI, etc.)",
terrain_type="Suburban",
mains_gas_available=True,
electricity_smart_meter=True,
gas_smart_meter=True,
),
floor_dimensions=[
FloorDimensions(total_floor_area_m2=35.68, height_m=2.19, heat_loss_perimeter_m=13.44, party_wall_length_m=10.62),
FloorDimensions(total_floor_area_m2=35.68, height_m=2.17, heat_loss_perimeter_m=11.0, party_wall_length_m=10.62),
FloorDimensions(total_floor_area_m2=3.8, height_m=2.0, heat_loss_perimeter_m=5.7, party_wall_length_m=0.0),
],
walls=WallDetails(
construction_type="Cavity",
insulation_type="Filled Cavity",
thickness_mm=310,
party_wall_construction_type="Cavity Masonry, Filled",
),
roof=RoofDetails(
construction_type="Pitched roof (Slates or tiles), Access to loft",
insulation_at="Joists",
insulation_thickness_mm=100,
has_rooms_in_roof=False,
),
floor=FloorDetails(
construction_type="Solid",
insulation_type="As Built",
),
windows=[
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North West", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=1.2, width_m=2.3),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North West", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=1.2, width_m=1.0),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North East", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=0.9, width_m=1.0),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=0.9, width_m=1.0),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North East", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=0.9, width_m=1.7),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North West", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=0.9, width_m=2.3),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North West", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=1.0, width_m=1.2),
WindowDetails(glazing_type="Double glazing, Unknown install date", orientation="North East", frame_type="Wooden or PVC", glazing_gap="16 mm or more", draught_proofed=True, height_m=0.9, width_m=1.0),
],
main_heating=MainHeatingSystem(
fuel="Mains gas",
system_type="Boiler with radiators or underfloor heating",
boiler_type="Combi",
manufacturer="Vaillant",
model="ecoTEC pro 28",
condensing=True,
controls="Programmer, room thermostat and TRVs",
flue_gas_heat_recovery=False,
weather_compensator=False,
emitter="Radiators",
),
hot_water=HotWaterSystem(
source="From main heating 1",
cylinder_size="No Cylinder",
insulation_type=None,
insulation_thickness_mm=None,
has_thermostat=None,
),
secondary_heating=None,
ventilation=VentilationDetails(
ventilation_type="Mechanical Extract - Decentralised",
number_of_open_flues=0,
number_of_closed_flues=0,
number_of_boiler_flues=0,
number_of_other_flues=0,
number_of_extract_fans=0,
number_of_passive_vents=0,
number_of_flueless_gas_fires=0,
has_fixed_air_conditioning=False,
pressure_test="No test",
draught_lobby=False,
),
renewables=RenewablesDetails(
has_photovoltaic=False,
has_solar_hot_water=False,
has_wind_turbines=False,
has_hydro=False,
number_of_pv_batteries=0,
),
lighting=LightingDetails(
number_of_led_bulbs=0,
number_of_cfl_bulbs=1,
number_of_incandescent_bulbs=4,
),
number_of_habitable_rooms=3,
number_of_external_doors=2,
number_of_open_chimneys=0,
number_of_blocked_chimneys=0,
has_conservatory=False,
number_of_baths=1,
number_of_showers=1,
waste_water_heat_recovery="None",
)