diff --git a/tests/repositories/historic_epc/test_historic_epc_resolver.py b/tests/repositories/historic_epc/test_historic_epc_resolver.py index aa4307276..37c242109 100644 --- a/tests/repositories/historic_epc/test_historic_epc_resolver.py +++ b/tests/repositories/historic_epc/test_historic_epc_resolver.py @@ -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