mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Load BuildingMeasurements from SiteNotes JSON 🟥
This commit is contained in:
parent
5f9c3e9bea
commit
2ed741df5c
2 changed files with 80 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ from typing import List, Optional
|
|||
|
||||
from datatypes.epc.surveys.pashub_rdsap_site_notes import (
|
||||
BuildingConstruction,
|
||||
BuildingMeasurements,
|
||||
ExtensionConstruction,
|
||||
FloorConstruction,
|
||||
General,
|
||||
|
|
@ -183,6 +184,9 @@ class PasHubRdSapSiteNotesExtractor:
|
|||
) or "",
|
||||
)
|
||||
|
||||
def extract_building_measurements(self) -> BuildingMeasurements:
|
||||
raise NotImplementedError
|
||||
|
||||
def _parse_floor_construction(self, data: List[str]) -> FloorConstruction:
|
||||
return FloorConstruction(
|
||||
floor_type=self._get_in(data, "Floor type:") or "",
|
||||
|
|
|
|||
|
|
@ -6,10 +6,14 @@ import pytest
|
|||
from backend.documents_parser.extractor import PasHubRdSapSiteNotesExtractor
|
||||
from datatypes.epc.surveys.pashub_rdsap_site_notes import (
|
||||
BuildingConstruction,
|
||||
BuildingMeasurements,
|
||||
ExtensionConstruction,
|
||||
ExtensionMeasurements,
|
||||
FloorConstruction,
|
||||
FloorMeasurement,
|
||||
General,
|
||||
MainBuildingConstruction,
|
||||
MainBuildingMeasurements,
|
||||
PasHubRdSapSiteNotes,
|
||||
)
|
||||
|
||||
|
|
@ -161,3 +165,75 @@ class TestBuildingConstruction:
|
|||
)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class TestBuildingMeasurements:
|
||||
@pytest.fixture
|
||||
def measurements(self) -> BuildingMeasurements:
|
||||
return PasHubRdSapSiteNotesExtractor(
|
||||
load_text_fixture()
|
||||
).extract_building_measurements()
|
||||
|
||||
def test_main_building_has_two_floors(
|
||||
self, measurements: BuildingMeasurements
|
||||
) -> None:
|
||||
assert len(measurements.main_building.floors) == 2
|
||||
|
||||
def test_main_building_floor_area(
|
||||
self, measurements: BuildingMeasurements
|
||||
) -> None:
|
||||
assert measurements.main_building.floors[0].area_m2 == 35.68
|
||||
|
||||
def test_integer_token_parses_to_float(
|
||||
self, measurements: BuildingMeasurements
|
||||
) -> None:
|
||||
# "11" in the PDF (no decimal) should parse to 11.0
|
||||
assert measurements.main_building.floors[1].heat_loss_perimeter_m == 11.0
|
||||
|
||||
def test_extension_measurements_present(
|
||||
self, measurements: BuildingMeasurements
|
||||
) -> None:
|
||||
assert measurements.extensions is not None
|
||||
assert len(measurements.extensions) == 1
|
||||
|
||||
def test_extension_id(self, measurements: BuildingMeasurements) -> None:
|
||||
assert measurements.extensions is not None
|
||||
assert measurements.extensions[0].id == 1
|
||||
|
||||
def test_full_building_measurements(
|
||||
self, measurements: BuildingMeasurements
|
||||
) -> None:
|
||||
assert measurements == BuildingMeasurements(
|
||||
main_building=MainBuildingMeasurements(
|
||||
floors=[
|
||||
FloorMeasurement(
|
||||
name="Floor 1",
|
||||
area_m2=35.68,
|
||||
height_m=2.19,
|
||||
heat_loss_perimeter_m=13.44,
|
||||
pwl_m=10.62,
|
||||
),
|
||||
FloorMeasurement(
|
||||
name="Floor 0",
|
||||
area_m2=35.68,
|
||||
height_m=2.17,
|
||||
heat_loss_perimeter_m=11.0,
|
||||
pwl_m=10.62,
|
||||
),
|
||||
]
|
||||
),
|
||||
extensions=[
|
||||
ExtensionMeasurements(
|
||||
id=1,
|
||||
floors=[
|
||||
FloorMeasurement(
|
||||
name="Floor 0",
|
||||
area_m2=3.8,
|
||||
height_m=2.0,
|
||||
heat_loss_perimeter_m=5.7,
|
||||
pwl_m=0.0,
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue