Strip trailing .0 from historic EPC UPRN 🟥

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jun-te Kim 2026-06-29 14:48:46 +00:00
parent 66b776e0aa
commit be2b71c235

View file

@ -128,3 +128,17 @@ def test_invalid_postcode_raises_postcode_not_found():
with patch.object(AddressMatch, "is_valid_postcode", return_value=False):
with pytest.raises(PostcodeNotFound):
repo.get_for_postcode("NONSENSE")
def test_uprn_trailing_dot_zero_is_stripped():
# Arrange — pandas reads an integer UPRN column as float, so the CSV cell
# arrives as "151020766.0"; the domain UPRN must be the bare integer string.
df = _df([_row("47 GORDON ROAD", "151020766.0")])
repo = HistoricEpcS3Repository(read_csv_gz=lambda bucket, key: df)
# Act
with _valid_postcode():
records = repo.get_for_postcode("AB33 8AL")
# Assert
assert records[0].uprn == "151020766"