mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Start writing peabody mapper. Now rethink model before continuing
This commit is contained in:
parent
1634e04dda
commit
a7201b0dc4
4 changed files with 55 additions and 2 deletions
|
|
@ -1,5 +1,4 @@
|
|||
from typing import Any, List, Optional
|
||||
from datetime import datetime, date
|
||||
|
||||
from backend.condition.domain.asset_condition import AssetCondition
|
||||
from backend.condition.domain.element import Element
|
||||
|
|
|
|||
14
backend/condition/domain/mapping/peabody_mapper.py
Normal file
14
backend/condition/domain/mapping/peabody_mapper.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from typing import Any, List, Optional
|
||||
|
||||
from backend.condition.domain.asset_condition import AssetCondition
|
||||
from backend.condition.domain.element import Element
|
||||
from backend.condition.domain.mapping.mapper import Mapper
|
||||
from backend.condition.parsing.records.peabody.peabody_asset_condition import PeabodyAssetCondition
|
||||
from backend.condition.parsing.records.peabody.peabody_property import PeabodyProperty
|
||||
from utils.logger import setup_logger
|
||||
|
||||
logger = setup_logger()
|
||||
|
||||
class PeabodyMapper(Mapper):
|
||||
def map_asset_conditions_for_property(self, client_data: Any, survey_year: Optional[int]) -> List[AssetCondition]:
|
||||
raise NotImplementedError
|
||||
|
|
@ -35,7 +35,9 @@ class PeabodyParser(Parser):
|
|||
try:
|
||||
asset = PeabodyParser._map_row_to_asset_record(row, asset_header_indexes)
|
||||
if not asset.is_block_level:
|
||||
assets.append(asset)
|
||||
# Block-level condition surveys are out of scope for now
|
||||
# until we have a wider think on how to handle block
|
||||
assets.append(asset) # TODO: handle block-level assets
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error mapping Peabody row to asset record: {e}")
|
||||
|
|
|
|||
38
backend/condition/tests/mapping/test_peabody_mapper.py
Normal file
38
backend/condition/tests/mapping/test_peabody_mapper.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
from datetime import datetime
|
||||
|
||||
from backend.condition.domain.mapping.peabody_mapper import PeabodyMapper
|
||||
from backend.condition.domain.element import Element
|
||||
from backend.condition.parsing.records.peabody.peabody_asset_condition import PeabodyAssetCondition
|
||||
from backend.condition.parsing.records.peabody.peabody_property import PeabodyProperty
|
||||
from backend.condition.domain.asset_condition import AssetCondition
|
||||
|
||||
def test_peabody_mapper_maps_property():
|
||||
# arrange
|
||||
peabody_property = PeabodyProperty(
|
||||
uprn=1,
|
||||
assets=[
|
||||
PeabodyAssetCondition(
|
||||
lo_reference="1000RAND0000",
|
||||
full_address="FLAT 1 RANDOM SQUARE FAKE STREET LONDON E1 1EE",
|
||||
location_type_code=1,
|
||||
parent_lo_reference="RAND1000",
|
||||
element_code=50,
|
||||
element="Internal",
|
||||
sub_element_code=3,
|
||||
sub_element="CCU",
|
||||
material_code=2,
|
||||
material_or_answer="RCD/MCB CCU",
|
||||
renewal_quantity=1,
|
||||
renewal_year=2038,
|
||||
renewal_cost=500,
|
||||
cloned="N",
|
||||
lo_type_code=1,
|
||||
condition_survey_date=datetime(2024,2,15,0,0,0),
|
||||
)
|
||||
]
|
||||
)
|
||||
|
||||
# act
|
||||
|
||||
# assert
|
||||
assert False #temp
|
||||
Loading…
Add table
Reference in a new issue