Rename window frame material column 🟩

This commit is contained in:
Daniel Roth 2026-04-27 16:11:32 +00:00
parent 01ebb2e0e1
commit 51bd18e0d7
7 changed files with 51 additions and 20 deletions

View file

@ -593,7 +593,7 @@ class EpcWindowModel(SQLModel, table=True):
id: Optional[int] = Field(default=None, primary_key=True)
epc_property_id: int = Field(foreign_key="epc_property.id", nullable=False)
pvc_frame: str
frame_material: Optional[str] = Field(default=None)
glazing_gap: str
orientation: str
window_type: str
@ -615,7 +615,7 @@ class EpcWindowModel(SQLModel, table=True):
td = window.window_transmission_details
return cls(
epc_property_id=epc_property_id,
pvc_frame=str(window.pvc_frame),
frame_material=window.frame_material,
glazing_gap=str(window.glazing_gap),
orientation=str(window.orientation),
window_type=str(window.window_type),

View file

@ -11,6 +11,9 @@ from datatypes.epc.domain.mapper import EpcPropertyDataMapper
FIXTURE_PATH = os.path.join(
os.path.dirname(__file__), "fixtures", "elmhurst_site_notes_1_text.json"
)
FIXTURE_PATH_2 = os.path.join(
os.path.dirname(__file__), "fixtures", "elmhurst_site_notes_2_text.json"
)
@pytest.fixture(scope="module")
@ -21,6 +24,14 @@ def result() -> EpcPropertyData:
return EpcPropertyDataMapper.from_elmhurst_site_notes(site_notes)
@pytest.fixture(scope="module")
def result2() -> EpcPropertyData:
with open(FIXTURE_PATH_2) as f:
pages = json.load(f)
site_notes = ElmhurstSiteNotesExtractor(pages).extract()
return EpcPropertyDataMapper.from_elmhurst_site_notes(site_notes)
class TestAddress:
def test_address_line_1(self, result: EpcPropertyData) -> None:
assert result.address_line_1 == "19, Queens Road"
@ -330,3 +341,16 @@ class TestEnergyPerformance:
def test_co2_emissions_current(self, result: EpcPropertyData) -> None:
assert result.co2_emissions_current == 1.683
class TestWindowFrameMaterial:
def test_frame_material_from_elmhurst(self, result2: EpcPropertyData) -> None:
assert result2.sap_windows[0].frame_material == "PVC"
def test_glazing_gap_from_elmhurst(self, result2: EpcPropertyData) -> None:
assert result2.sap_windows[0].glazing_gap == "16 mm or more"
class TestLowEnergyLighting:
def test_low_energy_fixed_lighting_bulbs_count(self, result2: EpcPropertyData) -> None:
assert result2.low_energy_fixed_lighting_bulbs_count == 5

View file

@ -71,7 +71,7 @@ class TestPdfToEpcPropertyData:
),
sap_windows=[
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North West",
window_type="Window",
@ -84,7 +84,7 @@ class TestPdfToEpcPropertyData:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North West",
window_type="Window",
@ -97,7 +97,7 @@ class TestPdfToEpcPropertyData:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North East",
window_type="Window",
@ -110,7 +110,7 @@ class TestPdfToEpcPropertyData:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North",
window_type="Window",
@ -123,7 +123,7 @@ class TestPdfToEpcPropertyData:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North East",
window_type="Window",
@ -136,7 +136,7 @@ class TestPdfToEpcPropertyData:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North West",
window_type="Window",
@ -149,7 +149,7 @@ class TestPdfToEpcPropertyData:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North West",
window_type="Window",
@ -162,7 +162,7 @@ class TestPdfToEpcPropertyData:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North East",
window_type="Window",

View file

@ -95,7 +95,7 @@ class WindowTransmissionDetails:
@dataclass
class SapWindow:
pvc_frame: str
frame_material: Optional[str]
glazing_gap: Union[int, str]
orientation: Union[int, str]
window_type: Union[int, str]

View file

@ -268,6 +268,9 @@ class EpcPropertyDataMapper:
"None" if not survey.renewables.wwhrs_present else "Present"
),
any_unheated_rooms=survey.heated_habitable_rooms < survey.habitable_rooms,
low_energy_fixed_lighting_bulbs_count=(
survey.lighting.low_energy_count if not survey.lighting.led_cfl_count_known else None
),
energy_rating_current=survey.current_sap_rating,
energy_rating_potential=survey.potential_sap_rating,
environmental_impact_current=survey.current_ei_rating,
@ -941,7 +944,7 @@ class EpcPropertyDataMapper:
# 20.0.0 SapWindow lacks frame/gap/draught fields present in later schemas
sap_windows=[
SapWindow(
pvc_frame="",
frame_material=None,
glazing_gap=0,
orientation=w.orientation,
window_type=w.window_type,
@ -1118,7 +1121,7 @@ class EpcPropertyDataMapper:
),
sap_windows=[
SapWindow(
pvc_frame=w.pvc_frame,
frame_material="PVC" if w.pvc_frame == "true" else None,
glazing_gap=w.glazing_gap,
orientation=w.orientation,
window_type=w.window_type,
@ -1352,7 +1355,7 @@ class EpcPropertyDataMapper:
# SAP windows
sap_windows=[
SapWindow(
pvc_frame=w.pvc_frame,
frame_material="PVC" if w.pvc_frame == "true" else None,
glazing_gap=w.glazing_gap,
orientation=w.orientation,
window_type=w.window_type,
@ -1613,7 +1616,7 @@ def _map_extension_building_part(
def _map_sap_window(window: Window) -> SapWindow:
return SapWindow(
pvc_frame=window.frame_type,
frame_material=window.frame_type,
glazing_gap=window.glazing_gap,
orientation=window.orientation,
window_type=window.window_type,
@ -1740,7 +1743,7 @@ def _map_elmhurst_building_part(survey: ElmhurstSiteNotes) -> SapBuildingPart:
def _map_elmhurst_window(w: ElmhurstWindow) -> SapWindow:
return SapWindow(
pvc_frame=w.frame_type or "",
frame_material=w.frame_type or None,
glazing_gap=w.glazing_gap or "",
orientation=w.orientation,
window_type="Window",

View file

@ -481,6 +481,10 @@ class TestFromRdSapSchema21_0_1:
# draught_proofed: "true"
assert result.sap_windows[0].draught_proofed is True
def test_window_frame_material_false(self, result: EpcPropertyData) -> None:
# pvc_frame: "false" in fixture → frame_material should be None
assert result.sap_windows[0].frame_material is None
# --- sap building parts ---
def test_building_part_count(self, result: EpcPropertyData) -> None:

View file

@ -398,7 +398,7 @@ class TestFromSiteNotesExample1:
# Windows
sap_windows=[
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="South East",
window_type="Window",
@ -411,7 +411,7 @@ class TestFromSiteNotesExample1:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="South East",
window_type="Window",
@ -424,7 +424,7 @@ class TestFromSiteNotesExample1:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North West",
window_type="Window",
@ -437,7 +437,7 @@ class TestFromSiteNotesExample1:
permanent_shutters_present=False,
),
SapWindow(
pvc_frame="Wooden or PVC",
frame_material="Wooden or PVC",
glazing_gap="16 mm or more",
orientation="North West",
window_type="Window",