mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Map lbwf data to new structure 🟥
This commit is contained in:
parent
61caf8c495
commit
d6112f3dc8
2 changed files with 141 additions and 108 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, Optional, Tuple
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
from backend.condition.domain.aspect_condition import AspectCondition
|
from backend.condition.domain.aspect_condition import AspectCondition
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@ from xml.dom.minidom import Element
|
||||||
import pytest
|
import pytest
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
|
from backend.condition.domain.aspect_condition import AspectCondition
|
||||||
from backend.condition.domain.aspect_type import AspectType
|
from backend.condition.domain.aspect_type import AspectType
|
||||||
from backend.condition.domain.element_type import ElementType
|
from backend.condition.domain.element_type import ElementType
|
||||||
from backend.condition.domain.mapping.lbwf.lbwf_mapper import LbwfMapper
|
from backend.condition.domain.mapping.lbwf.lbwf_mapper import LbwfMapper
|
||||||
|
from backend.condition.domain.property_condition_survey import PropertyConditionSurvey
|
||||||
from backend.condition.parsing.records.lbwf.lbwf_house import LbwfHouse
|
from backend.condition.parsing.records.lbwf.lbwf_house import LbwfHouse
|
||||||
from backend.condition.parsing.records.lbwf.lbwf_asset_condition import (
|
from backend.condition.parsing.records.lbwf.lbwf_asset_condition import (
|
||||||
LbwfAssetCondition,
|
LbwfAssetCondition,
|
||||||
|
|
@ -219,115 +221,146 @@ def test_lbwf_mapper_maps_house():
|
||||||
|
|
||||||
survey_year = 2026
|
survey_year = 2026
|
||||||
|
|
||||||
expected_assets: List[Element] = [
|
expected_condition_survey = PropertyConditionSurvey(
|
||||||
Element(
|
uprn=1,
|
||||||
uprn=1,
|
elements=[
|
||||||
element_type=ElementType.ACCESSIBLE_HOUSING_REGISTER,
|
Element(
|
||||||
aspect_type=AspectType.CATEGORY,
|
element_type=ElementType.ACCESSIBLE_HOUSING_REGISTER,
|
||||||
element_instance=None,
|
element_instance=1,
|
||||||
value="General Needs",
|
aspect_conditions=[
|
||||||
quantity=1,
|
AspectCondition(
|
||||||
renewal_year=None,
|
aspect_type=AspectType.CATEGORY,
|
||||||
install_date=None,
|
aspect_instance=1,
|
||||||
comments=None,
|
value="General Needs",
|
||||||
),
|
quantity=1,
|
||||||
Element(
|
install_date=None,
|
||||||
uprn=1,
|
renewal_year=None,
|
||||||
element_type=ElementType.FLOOR_LEVEL_FRONT_DOOR,
|
comments=None,
|
||||||
aspect_type=AspectType.LOCATION,
|
)
|
||||||
element_instance=None,
|
],
|
||||||
value="Ground Floor",
|
),
|
||||||
quantity=1,
|
Element(
|
||||||
renewal_year=None,
|
element_type=ElementType.FLOOR_LEVEL_FRONT_DOOR,
|
||||||
install_date=None,
|
element_instance=1,
|
||||||
comments=None,
|
aspect_conditions=[
|
||||||
),
|
AspectCondition(
|
||||||
Element(
|
aspect_type=AspectType.LOCATION,
|
||||||
uprn=1,
|
aspect_instance=1,
|
||||||
element_type=ElementType.ASBESTOS,
|
value="Ground Floor",
|
||||||
aspect_type=AspectType.PRESENCE,
|
quantity=1,
|
||||||
element_instance=None,
|
install_date=None,
|
||||||
value="Yes",
|
renewal_year=None,
|
||||||
quantity=None,
|
comments=None,
|
||||||
renewal_year=None,
|
)
|
||||||
install_date=None,
|
],
|
||||||
comments="Source of Data = ACT",
|
),
|
||||||
),
|
Element(
|
||||||
Element(
|
element_type=ElementType.ASBESTOS,
|
||||||
uprn=1,
|
element_instance=1,
|
||||||
element_type=ElementType.HHSRS_ASBESTOS_AND_MMF,
|
aspect_conditions=[
|
||||||
aspect_type=AspectType.RISK,
|
AspectCondition(
|
||||||
element_instance=None,
|
aspect_type=AspectType.PRESENCE,
|
||||||
value="Category 4 - Typical Risk",
|
aspect_instance=1,
|
||||||
quantity=None,
|
value="Yes",
|
||||||
renewal_year=None,
|
quantity=None,
|
||||||
install_date=None,
|
install_date=None,
|
||||||
comments="Source of Data = ACT",
|
renewal_year=None,
|
||||||
),
|
comments=None,
|
||||||
Element(
|
)
|
||||||
uprn=1,
|
],
|
||||||
element_type=ElementType.BATHROOM,
|
),
|
||||||
aspect_type=AspectType.LOCATION,
|
Element(
|
||||||
element_instance=None,
|
element_type=ElementType.HHSRS_ASBESTOS_AND_MMF,
|
||||||
value="Bathroom on Entrance Level in Property",
|
element_instance=1,
|
||||||
quantity=1,
|
aspect_conditions=[
|
||||||
renewal_year=None,
|
AspectCondition(
|
||||||
install_date=None,
|
aspect_type=AspectType.RISK,
|
||||||
comments="Source of Data = Codeman",
|
aspect_instance=1,
|
||||||
),
|
value="Category 4 - Typical Risk",
|
||||||
Element(
|
quantity=None,
|
||||||
uprn=1,
|
renewal_year=None,
|
||||||
element_type=ElementType.CENTRAL_HEATING,
|
comments="Source of Data = ACT",
|
||||||
aspect_type=AspectType.EXTENT,
|
)
|
||||||
element_instance=None,
|
],
|
||||||
value="No Central Heating in Property",
|
),
|
||||||
quantity=1,
|
Element(
|
||||||
renewal_year=None,
|
element_type=ElementType.BATHROOM,
|
||||||
install_date=None,
|
element_instance=1,
|
||||||
comments="Source of Data = Codeman",
|
aspect_conditions=[
|
||||||
),
|
AspectCondition(
|
||||||
Element(
|
aspect_type=AspectType.LOCATION,
|
||||||
uprn=1,
|
aspect_instance=1,
|
||||||
element_type=ElementType.HHSRS_FIRE,
|
value="Bathroom on Entrance Level in Property",
|
||||||
aspect_type=AspectType.RISK,
|
quantity=1,
|
||||||
element_instance=None,
|
install_date=None,
|
||||||
value="Category 4 - Typical Risk",
|
renewal_year=None,
|
||||||
quantity=1,
|
comments="Source of Data = Codeman",
|
||||||
renewal_year=None,
|
)
|
||||||
install_date=None,
|
],
|
||||||
comments="Source of Data = Morgan Sindall",
|
),
|
||||||
),
|
Element(
|
||||||
Element(
|
element_type=ElementType.CENTRAL_HEATING,
|
||||||
uprn=1,
|
element_instance=1,
|
||||||
element_type=ElementType.EXTERNAL_WALL,
|
aspect_conditions=[
|
||||||
aspect_type=AspectType.FINISH,
|
AspectCondition(
|
||||||
element_instance=1,
|
aspect_type=AspectType.EXTENT,
|
||||||
value="Render or Pebbledash in External Area",
|
aspect_instance=1,
|
||||||
quantity=1,
|
value="No Central Heating in Property",
|
||||||
renewal_year=2052,
|
quantity=1,
|
||||||
install_date=date(2009, 4, 1),
|
install_date=None,
|
||||||
comments="Source of Data = Codeman",
|
renewal_year=None,
|
||||||
),
|
comments="Source of Data = Codeman",
|
||||||
Element(
|
)
|
||||||
uprn=1,
|
],
|
||||||
element_type=ElementType.EXTERNAL_WALL,
|
),
|
||||||
aspect_type=AspectType.FINISH,
|
Element(
|
||||||
element_instance=2,
|
element_type=ElementType.HHSRS_FIRE,
|
||||||
value="Smooth Render Wall Finish 2 in External Area",
|
element_instance=1,
|
||||||
quantity=1,
|
aspect_conditions=[
|
||||||
renewal_year=2052,
|
AspectCondition(
|
||||||
install_date=date(2009, 4, 1),
|
aspect_type=AspectType.RISK,
|
||||||
comments="Source of Data = Codeman",
|
aspect_instance=1,
|
||||||
),
|
value="Category 4 - Typical Risk",
|
||||||
]
|
quantity=1,
|
||||||
|
install_date=None,
|
||||||
|
renewal_year=None,
|
||||||
|
comments="Source of Data = Morgan Sindall",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Element(
|
||||||
|
element_type=ElementType.EXTERNAL_WALL,
|
||||||
|
element_instance=1,
|
||||||
|
aspect_conditions=[
|
||||||
|
AspectCondition(
|
||||||
|
aspect_type=AspectType.FINISH,
|
||||||
|
aspect_instance=1,
|
||||||
|
value="Render or Pebbledash in External Area",
|
||||||
|
quantity=1,
|
||||||
|
install_date=date(2009, 4, 1),
|
||||||
|
renewal_year=2052,
|
||||||
|
comments="Source of Data = Codeman",
|
||||||
|
),
|
||||||
|
AspectCondition(
|
||||||
|
aspect_type=AspectType.FINISH,
|
||||||
|
aspect_instance=2,
|
||||||
|
value="Smooth Render Wall Finish 2 in External Area",
|
||||||
|
quantity=1,
|
||||||
|
install_date=date(2009, 4, 1),
|
||||||
|
renewal_year=2052,
|
||||||
|
comments="Source of Data = Codeman",
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
date=date(2000, 1, 1), # what should this be?
|
||||||
|
source="LBWF",
|
||||||
|
)
|
||||||
|
|
||||||
# act
|
# act
|
||||||
actual_assets: List[Element] = mapper.map_asset_conditions_for_property(
|
actual_condition_survey: PropertyConditionSurvey = (
|
||||||
lbwf_house, survey_year
|
mapper.map_asset_conditions_for_property(lbwf_house)
|
||||||
)
|
)
|
||||||
|
|
||||||
# assert
|
# assert
|
||||||
assert len(actual_assets) == len(expected_assets)
|
assert actual_condition_survey == expected_condition_survey
|
||||||
|
|
||||||
for i, (actual, expected) in enumerate(zip(actual_assets, expected_assets)):
|
|
||||||
assert actual == expected, f"Mismatch at index {i}"
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue