diff --git a/tests/repositories/historic_epc/test_historic_epc_resolver.py b/tests/repositories/historic_epc/test_historic_epc_resolver.py index d429d8ca1..c4b05f8b7 100644 --- a/tests/repositories/historic_epc/test_historic_epc_resolver.py +++ b/tests/repositories/historic_epc/test_historic_epc_resolver.py @@ -130,6 +130,25 @@ def test_record_for_uprn_is_none_when_uprn_not_in_shard(): assert HistoricEpcResolver(repo).record_for_uprn("999", "AB33 8AL") is None +def test_record_for_uprn_picks_latest_lodgement_when_relodged(): + # Arrange — the register re-lodged this UPRN; the newer observation wins. + repo = _FakeRepo( + { + "AB338AL": [ + _hist("47 GORDON ROAD", "100", lodgement_date="2008-01-15"), + _hist("47 GORDON ROAD, DORRIDGE", "100", lodgement_date="2010-06-02"), + ] + } + ) + + # Act + record = HistoricEpcResolver(repo).record_for_uprn("100", "AB33 8AL") + + # Assert + assert record is not None + assert record.lodgement_date == "2010-06-02" + + def test_resolve_uprn_is_none_when_all_scores_zero(): # Arrange — no candidate shares the user's building number => all hard-zero. repo = _FakeRepo(