Small fixes
This commit is contained in:
parent
54fbcb1ea6
commit
083f8a982e
24 changed files with 1505 additions and 79 deletions
|
|
@ -16,6 +16,7 @@ from pipeline.transform.merge import (
|
|||
_best_listing_match,
|
||||
_coalesce_direct_epc_columns,
|
||||
_dedupe_collapsed_properties,
|
||||
_fill_property_level_no_defaults,
|
||||
_filter_to_active_english_postcodes,
|
||||
_join_area_side_tables,
|
||||
_finalize_listings,
|
||||
|
|
@ -943,6 +944,61 @@ def test_match_direct_epc_matches_by_uprn_across_postcodes() -> None:
|
|||
assert matches["_direct_epc_match_method"].to_list() == ["uprn"]
|
||||
|
||||
|
||||
def test_match_direct_epc_ignores_nonunique_building_uprn() -> None:
|
||||
# A parent/building UPRN that resolves to several distinct (address,
|
||||
# postcode) flats cannot act as a 1:1 exact-match key — it would mis-link
|
||||
# the listing to one arbitrary flat. The listing must fall through to the
|
||||
# street-address matcher, which resolves the specific flat.
|
||||
matches = _match_direct_epc(
|
||||
_listing_matches(
|
||||
[
|
||||
{
|
||||
"_listing_uprn": "100000000001",
|
||||
"_listing_match_address": "FLAT 2 EXAMPLE COURT",
|
||||
"_listing_match_postcode": "AA11AA",
|
||||
}
|
||||
]
|
||||
),
|
||||
_direct_epc_candidates(
|
||||
[
|
||||
{
|
||||
"_direct_epc_uprn": "100000000001",
|
||||
"_direct_epc_match_address": "FLAT 1 EXAMPLE COURT",
|
||||
"_direct_epc_address": "Flat 1, Example Court",
|
||||
},
|
||||
{
|
||||
"_direct_epc_uprn": "100000000001",
|
||||
"_direct_epc_match_address": "FLAT 2 EXAMPLE COURT",
|
||||
"_direct_epc_address": "Flat 2, Example Court",
|
||||
},
|
||||
]
|
||||
),
|
||||
)
|
||||
|
||||
assert matches.height == 1
|
||||
# Resolved by address, not the ambiguous building UPRN, and to the right flat.
|
||||
assert matches["_direct_epc_match_method"].to_list() != ["uprn"]
|
||||
assert matches["_direct_epc_address"].to_list() == ["Flat 2, Example Court"]
|
||||
|
||||
|
||||
def test_fill_property_level_no_defaults_defaults_unmatched_to_no() -> None:
|
||||
# EPC-unmatched properties arrive with null was_council_house / Listed
|
||||
# building; they must publish "No" (not null), while a genuine "Yes" is
|
||||
# preserved.
|
||||
frame = pl.LazyFrame(
|
||||
{
|
||||
LISTED_BUILDING_FEATURE: ["Yes", None, "No"],
|
||||
"was_council_house": ["Yes", None, "No"],
|
||||
}
|
||||
)
|
||||
|
||||
out = _fill_property_level_no_defaults(frame).collect()
|
||||
|
||||
assert out["was_council_house"].to_list() == ["Yes", "No", "No"]
|
||||
assert out[LISTED_BUILDING_FEATURE].to_list() == ["Yes", "No", "No"]
|
||||
assert out["was_council_house"].null_count() == 0
|
||||
|
||||
|
||||
def test_match_direct_epc_matches_by_address_in_same_postcode() -> None:
|
||||
matches = _match_direct_epc(
|
||||
_listing_matches([{"_listing_match_address": "1 EXAMPLE ROAD"}]),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue