Model/backend/condition/tests/mapping/test_lbwf_mapper.py
2026-01-27 15:59:06 +00:00

366 lines
14 KiB
Python

from datetime import date
from backend.condition.domain.aspect_condition import AspectCondition
from backend.condition.domain.aspect_type import AspectType
from backend.condition.domain.element_type import ElementType
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_asset_condition import (
LbwfAssetCondition,
)
from backend.condition.domain.element import Element
from backend.condition.tests.custom_asserts import CustomAsserts
def test_lbwf_mapper_maps_house():
# arrange
lbwf_house = LbwfHouse(
uprn=1,
reference=100,
address="123 Fake Street, London, A10 1AB",
epc="F",
shdf="NO",
house="HOUSE",
fail_decency=2025,
assets=[
LbwfAssetCondition(
prop_ref=100,
domna=100,
address="123 Fake Street, London, A10 1AB",
ownership="LBWF_OWNED",
prop_status="OCCP",
prop_type="HOU",
prop_sub_type="TERRACED",
element_group="ASSETS",
element_code="AHR_CAT",
element_code_description="Accessible Housing Register Category",
attribute_code="F",
attribute_code_description="General Needs",
element_date_value=None,
element_numerical_value=None,
element_text_value=None,
quantity=1,
install_date=None,
remaining_life=None,
element_comments=None,
),
LbwfAssetCondition(
prop_ref=100,
domna=100,
address="123 Fake Street, London, A10 1AB",
ownership="LBWF_OWNED",
prop_status="OCCP",
prop_type="HOU",
prop_sub_type="TERRACED",
element_group="ASSETS",
element_code="FLVL",
element_code_description="Floor Level of Front Door",
attribute_code="0G",
attribute_code_description="Ground Floor",
element_date_value=None,
element_numerical_value=None,
element_text_value=None,
quantity=1,
install_date=None,
remaining_life=None,
element_comments=None,
),
LbwfAssetCondition(
prop_ref=100,
domna=100,
address="123 Fake Street, London, A10 1AB",
ownership="LBWF_OWNED",
prop_status="OCCP",
prop_type="HOU",
prop_sub_type="TERRACED",
element_group="ASSETS",
element_code="ASBESTOS",
element_code_description="Asbestos Present",
attribute_code="YES",
attribute_code_description="Yes",
element_date_value=None,
element_numerical_value=None,
element_text_value=None,
quantity=None,
install_date=None,
remaining_life=None,
element_comments="Source of Data = ACT",
),
LbwfAssetCondition(
prop_ref=100,
domna=100,
address="123 Fake Street, London, A10 1AB",
ownership="LBWF_OWNED",
prop_status="OCCP",
prop_type="HOU",
prop_sub_type="TERRACED",
element_group="ASSETS",
element_code="HHSRSASB",
element_code_description="Asbestos (and MMF)",
attribute_code="TYPRISK",
attribute_code_description="Category 4 - Typical Risk",
element_date_value=None,
element_numerical_value=None,
element_text_value=None,
quantity=None,
install_date=None,
remaining_life=None,
element_comments="Source of Data = ACT",
),
LbwfAssetCondition(
prop_ref=100,
domna=100,
address="123 Fake Street, London, A10 1AB",
ownership="LBWF_OWNED",
prop_status="OCCP",
prop_type="HOU",
prop_sub_type="TERRACED",
element_group="ASSETS",
element_code="INTBTHRLOC",
element_code_description="Location of Bathroom in Property",
attribute_code="ENTRANCE",
attribute_code_description="Bathroom on Entrance Level in Property",
element_date_value=None,
element_numerical_value=None,
element_text_value=None,
quantity=1,
install_date=None,
remaining_life=None,
element_comments="Source of Data = Codeman",
),
LbwfAssetCondition(
prop_ref=100,
domna=100,
address="123 Fake Street, London, A10 1AB",
ownership="LBWF_OWNED",
prop_status="OCCP",
prop_type="HOU",
prop_sub_type="TERRACED",
element_group="ASSETS",
element_code="INTCHEXTNT",
element_code_description="Extent of Central Heating in Property",
attribute_code="NONE",
attribute_code_description="No Central Heating in Property",
element_date_value=None,
element_numerical_value=None,
element_text_value=None,
quantity=1,
install_date=None,
remaining_life=None,
element_comments="Source of Data = Codeman",
),
LbwfAssetCondition(
prop_ref=100,
domna=100,
address="123 Fake Street, London, A10 1AB",
ownership="LBWF_OWNED",
prop_status="OCCP",
prop_type="HOU",
prop_sub_type="TERRACED",
element_group="ASSETS",
element_code="HHSRSFIRE",
element_code_description="Fire",
attribute_code="TYPRISK",
attribute_code_description="Category 4 - Typical Risk",
element_date_value=None,
element_numerical_value=None,
element_text_value=None,
quantity=1,
install_date=None,
remaining_life=None,
element_comments="Source of Data = Morgan Sindall",
),
LbwfAssetCondition(
prop_ref=100,
domna=100,
address="123 Fake Street, London, A10 1AB",
ownership="LBWF_OWNED",
prop_status="OCCP",
prop_type="HOU",
prop_sub_type="TERRACED",
element_group="ASSETS",
element_code="EXTWALLFN1",
element_code_description="Wall Finish 1 in External Area",
attribute_code="SMTHRENDER",
attribute_code_description="Render or Pebbledash in External Area",
element_date_value=None,
element_numerical_value=None,
element_text_value=None,
quantity=1,
install_date=date(2009, 4, 1),
remaining_life=26,
element_comments="Source of Data = Codeman",
),
LbwfAssetCondition(
prop_ref=100,
domna=100,
address="123 Fake Street, London, A10 1AB",
ownership="LBWF_OWNED",
prop_status="OCCP",
prop_type="HOU",
prop_sub_type="TERRACED",
element_group="ASSETS",
element_code="EXTWALLFN2",
element_code_description="Wall Finish 2 in External Area",
attribute_code="SMTHRENDER",
attribute_code_description="Smooth Render Wall Finish 2 in External Area",
element_date_value=None,
element_numerical_value=None,
element_text_value=None,
quantity=1,
install_date=date(2009, 4, 1),
remaining_life=26,
element_comments="Source of Data = Codeman",
),
],
)
mapper = LbwfMapper()
survey_year = 2026
expected_condition_survey = PropertyConditionSurvey(
uprn=1,
elements=[
Element(
element_type=ElementType.ACCESSIBLE_HOUSING_REGISTER,
element_instance=1,
aspect_conditions=[
AspectCondition(
aspect_type=AspectType.CATEGORY,
aspect_instance=1,
value="General Needs",
quantity=1,
install_date=None,
renewal_year=None,
comments=None,
)
],
),
Element(
element_type=ElementType.FLOOR_LEVEL_FRONT_DOOR,
element_instance=1,
aspect_conditions=[
AspectCondition(
aspect_type=AspectType.LOCATION,
aspect_instance=1,
value="Ground Floor",
quantity=1,
install_date=None,
renewal_year=None,
comments=None,
)
],
),
Element(
element_type=ElementType.ASBESTOS,
element_instance=1,
aspect_conditions=[
AspectCondition(
aspect_type=AspectType.PRESENCE,
aspect_instance=1,
value="Yes",
quantity=None,
install_date=None,
renewal_year=None,
comments="Source of Data = ACT",
)
],
),
Element(
element_type=ElementType.HHSRS_ASBESTOS_AND_MMF,
element_instance=1,
aspect_conditions=[
AspectCondition(
aspect_type=AspectType.RISK,
aspect_instance=1,
value="Category 4 - Typical Risk",
quantity=None,
renewal_year=None,
comments="Source of Data = ACT",
)
],
),
Element(
element_type=ElementType.BATHROOM,
element_instance=1,
aspect_conditions=[
AspectCondition(
aspect_type=AspectType.LOCATION,
aspect_instance=1,
value="Bathroom on Entrance Level in Property",
quantity=1,
install_date=None,
renewal_year=None,
comments="Source of Data = Codeman",
)
],
),
Element(
element_type=ElementType.CENTRAL_HEATING,
element_instance=1,
aspect_conditions=[
AspectCondition(
aspect_type=AspectType.EXTENT,
aspect_instance=1,
value="No Central Heating in Property",
quantity=1,
install_date=None,
renewal_year=None,
comments="Source of Data = Codeman",
)
],
),
Element(
element_type=ElementType.HHSRS_FIRE,
element_instance=1,
aspect_conditions=[
AspectCondition(
aspect_type=AspectType.RISK,
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
actual_condition_survey: PropertyConditionSurvey = (
mapper.map_asset_conditions_for_property(lbwf_house, survey_year)
)
# assert
assert CustomAsserts.assert_property_condition_surveys_equal(
actual_condition_survey, expected_condition_survey
)