Ignore block level assets during parsing

This commit is contained in:
Daniel Roth 2026-01-22 09:15:37 +00:00
parent 80f3325cf0
commit f8db0cadba
3 changed files with 27 additions and 6 deletions

View file

@ -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

View file

@ -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"
]

View file

@ -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