mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-27 23:35:01 +00:00
Map a Calico roof-covering row to a renewal year 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
735e83cef2
commit
99280b6a64
7 changed files with 89 additions and 0 deletions
0
domain/condition/mapping/calico/__init__.py
Normal file
0
domain/condition/mapping/calico/__init__.py
Normal file
12
domain/condition/mapping/calico/calico_element_map.py
Normal file
12
domain/condition/mapping/calico/calico_element_map.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
from domain.condition.aspect_type import AspectType
|
||||
from domain.condition.element_type import ElementType
|
||||
from domain.condition.mapping.element_mapping import ElementMapping
|
||||
|
||||
# Calico's component path -> the shared taxonomy. Held as data (like the LBWF /
|
||||
# Peabody element maps) so extending Calico to further components is a data edit.
|
||||
CALICO_ELEMENT_MAP: dict[str, ElementMapping] = {
|
||||
"Roof Covering": ElementMapping(
|
||||
elementType=ElementType.ROOF,
|
||||
aspect_type=AspectType.MATERIAL,
|
||||
),
|
||||
}
|
||||
11
domain/condition/mapping/calico/calico_mapper.py
Normal file
11
domain/condition/mapping/calico/calico_mapper.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
from typing import Any, Optional
|
||||
|
||||
from domain.condition.mapping.mapper import Mapper
|
||||
from domain.condition.property_condition_survey import PropertyConditionSurvey
|
||||
|
||||
|
||||
class CalicoMapper(Mapper):
|
||||
def map_asset_conditions_for_property(
|
||||
self, client_property_data: Any, survey_year: Optional[int] = None
|
||||
) -> PropertyConditionSurvey:
|
||||
raise NotImplementedError
|
||||
0
domain/condition/records/calico/__init__.py
Normal file
0
domain/condition/records/calico/__init__.py
Normal file
20
domain/condition/records/calico/calico_asset_condition.py
Normal file
20
domain/condition/records/calico/calico_asset_condition.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
from dataclasses import dataclass
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
|
||||
@dataclass
|
||||
class CalicoAssetCondition:
|
||||
"""One component row from a Calico stock-condition export.
|
||||
|
||||
Calico's current export carries a single component (``path == "Roof
|
||||
Covering"``); ``covering_type`` is the material (e.g. "Concrete Tiles") and
|
||||
``remaining_life`` is Calico's Decent-Homes-derived years-remaining figure.
|
||||
"""
|
||||
|
||||
asset_reference: int
|
||||
path: str
|
||||
covering_type: Optional[str] = None
|
||||
fitted_date: Optional[date] = None
|
||||
quantity: Optional[int] = None
|
||||
remaining_life: Optional[int] = None
|
||||
10
domain/condition/records/calico/calico_property.py
Normal file
10
domain/condition/records/calico/calico_property.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
from dataclasses import dataclass
|
||||
from typing import List
|
||||
|
||||
from domain.condition.records.calico.calico_asset_condition import CalicoAssetCondition
|
||||
|
||||
|
||||
@dataclass
|
||||
class CalicoProperty:
|
||||
uprn: int
|
||||
assets: List[CalicoAssetCondition]
|
||||
36
tests/condition/mapping/test_calico_mapper.py
Normal file
36
tests/condition/mapping/test_calico_mapper.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
from datetime import date
|
||||
|
||||
from domain.condition.aspect_type import AspectType
|
||||
from domain.condition.element_type import ElementType
|
||||
from domain.condition.mapping.calico.calico_mapper import CalicoMapper
|
||||
from domain.condition.records.calico.calico_asset_condition import CalicoAssetCondition
|
||||
from domain.condition.records.calico.calico_property import CalicoProperty
|
||||
|
||||
|
||||
def test_calico_mapper_sets_renewal_year_to_export_year_plus_remaining_life():
|
||||
# Arrange
|
||||
calico_property = CalicoProperty(
|
||||
uprn=100093305101,
|
||||
assets=[
|
||||
CalicoAssetCondition(
|
||||
asset_reference=443,
|
||||
path="Roof Covering",
|
||||
covering_type="Concrete Tiles",
|
||||
fitted_date=date(1998, 4, 1),
|
||||
quantity=55,
|
||||
remaining_life=36,
|
||||
)
|
||||
],
|
||||
)
|
||||
export_year = 2026
|
||||
|
||||
# Act
|
||||
survey = CalicoMapper().map_asset_conditions_for_property(
|
||||
calico_property, export_year
|
||||
)
|
||||
|
||||
# Assert
|
||||
roof_material = survey.elements[0].aspect_conditions[0]
|
||||
assert roof_material.aspect_type is AspectType.MATERIAL
|
||||
assert survey.elements[0].element_type is ElementType.ROOF
|
||||
assert roof_material.renewal_year == export_year + 36
|
||||
Loading…
Add table
Reference in a new issue