Return no historic UPRN for missing, ambiguous, or zero-score matches 🟩

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-29 14:52:42 +00:00
parent b47c90f9cd
commit 03687041c9

View file

@ -74,3 +74,41 @@ def test_resolve_uprn_returns_unambiguous_match():
assert uprn == "100"
assert address == "47 GORDON ROAD"
assert score > 0
def test_resolve_uprn_is_none_when_postcode_has_no_data():
# Arrange — valid postcode, but the backup has no shard for it.
resolver = HistoricEpcResolver(_FakeRepo({}))
# Act / Assert
assert resolver.resolve_uprn("47 Gordon Road", "AB33 8AL") is None
def test_resolve_uprn_is_none_on_ambiguous_tie():
# Arrange — two identical addresses with different UPRNs share rank-1.
repo = _FakeRepo(
{
"AB338AL": [
_hist("47 GORDON ROAD", "100"),
_hist("47 GORDON ROAD", "200"),
]
}
)
# Act / Assert
assert HistoricEpcResolver(repo).resolve_uprn("47 Gordon Road", "AB33 8AL") is None
def test_resolve_uprn_is_none_when_all_scores_zero():
# Arrange — no candidate shares the user's building number => all hard-zero.
repo = _FakeRepo(
{
"AB338AL": [
_hist("999 ELSEWHERE", "100"),
_hist("888 ELSEWHERE", "200"),
]
}
)
# Act / Assert
assert HistoricEpcResolver(repo).resolve_uprn("47 Gordon Road", "AB33 8AL") is None