From f8db0cadbafa33fee75419c8fb38c55cadf04f75 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Thu, 22 Jan 2026 09:15:37 +0000 Subject: [PATCH] Ignore block level assets during parsing --- backend/condition/parsing/peabody_parser.py | 7 +++--- .../peabody/peabody_asset_condition.py | 2 +- .../tests/parsing/test_peabody_parser.py | 24 +++++++++++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/backend/condition/parsing/peabody_parser.py b/backend/condition/parsing/peabody_parser.py index d2229e1c..b053f2ea 100644 --- a/backend/condition/parsing/peabody_parser.py +++ b/backend/condition/parsing/peabody_parser.py @@ -33,9 +33,10 @@ class PeabodyParser(Parser): assets: List[PeabodyAssetCondition] = [] for row in asset_rows: try: - assets.append( - PeabodyParser._map_row_to_asset_record(row, asset_header_indexes) - ) + asset = PeabodyParser._map_row_to_asset_record(row, asset_header_indexes) + if not asset.is_block_level: + assets.append(asset) + except Exception as e: logger.error(f"Error mapping Peabody row to asset record: {e}") continue diff --git a/backend/condition/parsing/records/peabody/peabody_asset_condition.py b/backend/condition/parsing/records/peabody/peabody_asset_condition.py index 71fa1e9d..b1624999 100644 --- a/backend/condition/parsing/records/peabody/peabody_asset_condition.py +++ b/backend/condition/parsing/records/peabody/peabody_asset_condition.py @@ -32,7 +32,7 @@ class PeabodyAssetCondition: block_level_patterns = [ r"\bBLOCK\b", # "BLOCK MILNE HOUSE" - r"\bFLATS\b", # "FLATS A-D ..." + r"\bFLATS\b", # "FLATS A-D ..." r"\b\d+[A-Z]?-\d+[A-Z]?\b", # "1-80", "9A-9H" ] diff --git a/backend/condition/tests/parsing/test_peabody_parser.py b/backend/condition/tests/parsing/test_peabody_parser.py index 63ed0799..fb0e9d51 100644 --- a/backend/condition/tests/parsing/test_peabody_parser.py +++ b/backend/condition/tests/parsing/test_peabody_parser.py @@ -33,7 +33,25 @@ def peabody_assets_xlsx_bytes() -> BytesIO: ]) survey_records_d_and_lower.append([ "B000RAND", - "1-11 RANDOM HOUSE LONDON", + "1 RANDOM HOUSE LONDON", + 3, + "RAND2EST", + 110, + "ROOFS", + 1, + "Primary Roof", + 9, + "Other", + 3, + 2054, + 330, + "N", + 3, + datetime(2025,12,4,9,17,0) + ]) + survey_records_d_and_lower.append([ + "B000BLOCK", + "1100 BLOCK", 3, "RAND2EST", 110, @@ -51,7 +69,7 @@ def peabody_assets_xlsx_bytes() -> BytesIO: ]) survey_records_d_and_lower.append([ "B000FAKE", - "3-10 FAKE CLOSE LONDON", + "3 FAKE CLOSE LONDON", 3, "FAKEEST", 100, @@ -163,6 +181,8 @@ def test_peabody_asset_is_block_level( full_address, expected_block_level, ): + # arrange asset_condition = asset_condition_factory(full_address) + # act + assert assert asset_condition.is_block_level == expected_block_level \ No newline at end of file