From 55284a1807b5e898ac79d36348c38d8ac078a0ab Mon Sep 17 00:00:00 2001 From: Khalim Conn-Kowlessar Date: Sat, 4 Jul 2026 14:43:47 +0000 Subject: [PATCH] =?UTF-8?q?A=20shard=20with=20an=20unexpected=20extra=20co?= =?UTF-8?q?lumn=20still=20maps=20to=20HistoricEpc=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- .../test_historic_epc_s3_repository.py | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/repositories/historic_epc/test_historic_epc_s3_repository.py b/tests/repositories/historic_epc/test_historic_epc_s3_repository.py index 030e39c12..198ee1a60 100644 --- a/tests/repositories/historic_epc/test_historic_epc_s3_repository.py +++ b/tests/repositories/historic_epc/test_historic_epc_s3_repository.py @@ -144,6 +144,28 @@ def test_malformed_postcode_raises_postcode_not_found(): repo.get_for_postcode(Postcode("NONSENSE")) +def test_shard_with_unexpected_extra_column_still_maps(): + # Arrange — the upstream dump can gain columns the domain type doesn't + # know; mapping must ignore them rather than explode at construction. + buffer = StringIO() + writer = csv.DictWriter(buffer, fieldnames=_COLS + ["SOMETHING_NEW"]) + writer.writeheader() + row = {col: "" for col in _COLS} + row["ADDRESS"] = "47 GORDON ROAD" + row["UPRN"] = "100" + row["SOMETHING_NEW"] = "surprise" + writer.writerow(row) + body = gzip.compress(buffer.getvalue().encode()) + repo = _repo(_FakeBoto(body=body)) + + # Act + records = repo.get_for_postcode(Postcode("AB33 8AL")) + + # Assert + assert records[0].address == "47 GORDON ROAD" + assert records[0].uprn == "100" + + def test_uprn_trailing_dot_zero_is_stripped(): # Arrange — pandas reads an integer UPRN column written with a decimal as # float, so the cell stringifies to "151020766.0"; the domain UPRN must be