From 187d7fbadd2284f58c31e89f30e91f13352ceb7e Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Thu, 22 Jan 2026 09:06:05 +0000 Subject: [PATCH] =?UTF-8?q?Detect=20block-level=20asset=20conditions=20-?= =?UTF-8?q?=20additional=20test=20cases=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tests/parsing/test_peabody_parser.py | 69 +++++++++++-------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/backend/condition/tests/parsing/test_peabody_parser.py b/backend/condition/tests/parsing/test_peabody_parser.py index 830e8f2c..63ed0799 100644 --- a/backend/condition/tests/parsing/test_peabody_parser.py +++ b/backend/condition/tests/parsing/test_peabody_parser.py @@ -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 - - \ No newline at end of file + assert asset_condition.is_block_level == expected_block_level \ No newline at end of file