Detect block-level asset conditions - additional test cases 🟥

This commit is contained in:
Daniel Roth 2026-01-22 09:06:05 +00:00
parent a07020d085
commit 187d7fbadd

View file

@ -1,5 +1,5 @@
from typing import Any
import pytest
from typing import Any
from io import BytesIO
from openpyxl import Workbook
from datetime import datetime
@ -123,33 +123,46 @@ def test_peabody_parser_parses_conditions(peabody_assets_xlsx_bytes):
assert all(isinstance(item, PeabodyProperty) for item in result)
def test_peabody_asset_is_block_level():
# arrange
asset_condition = PeabodyAssetCondition(
lo_reference="",
full_address="1-80 PRINCESS ALICE HOUSE LONDON",
location_type_code=0,
parent_lo_reference="",
element_code=0,
element="",
sub_element_code=0,
sub_element="",
material_code=0,
material_or_answer="",
renewal_quantity=0,
renewal_year=2026,
cloned="",
lo_type_code=0,
renewal_cost=None,
condition_survey_date=None
)
@pytest.fixture
def asset_condition_factory():
def _factory(full_address: str) -> PeabodyAssetCondition:
return PeabodyAssetCondition(
lo_reference="",
full_address=full_address,
location_type_code=0,
parent_lo_reference="",
element_code=0,
element="",
sub_element_code=0,
sub_element="",
material_code=0,
material_or_answer="",
renewal_quantity=0,
renewal_year=2026,
cloned="",
lo_type_code=0,
renewal_cost=None,
condition_survey_date=None,
)
expected_block_level = True
return _factory
# act
actual_block_level = asset_condition.is_block_level
@pytest.mark.parametrize(
"full_address, expected_block_level",
[
("1-80 PRINCESS ALICE HOUSE LONDON", True),
("FLATS A-D 7 ST CHARLES SQUARE LONDON", True),
("9A-9H HEDGEGATE COURT LONDON", True),
("BLOCK MILNE HOUSE LONDON", True),
("25 HAVERSHAM COURT GREENFORD", False),
("FLAT 10 SPARROW COURT SOUTHMERE DRIVE LONDON SE2 9ES", False)
],
)
def test_peabody_asset_is_block_level(
asset_condition_factory,
full_address,
expected_block_level,
):
asset_condition = asset_condition_factory(full_address)
# assert
assert expected_block_level == actual_block_level
assert asset_condition.is_block_level == expected_block_level