mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Return empty list for a postcode with no historic EPC shard 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a372f2995f
commit
6a095a2cf2
1 changed files with 18 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ from contextlib import contextmanager
|
|||
from unittest.mock import patch
|
||||
|
||||
import pandas as pd
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
from backend.utils.addressMatch import AddressMatch
|
||||
from datatypes.epc.domain.historic_epc import HistoricEpc
|
||||
|
|
@ -56,3 +57,20 @@ def test_get_for_postcode_maps_reader_rows_to_historic_epc_records():
|
|||
assert isinstance(records[0], HistoricEpc)
|
||||
assert records[0].address == "47 GORDON ROAD"
|
||||
assert records[0].uprn == "100"
|
||||
|
||||
|
||||
def test_valid_postcode_with_no_stored_object_returns_empty_list():
|
||||
# Arrange — a valid postcode whose shard does not exist in S3.
|
||||
def missing(bucket: str, key: str) -> pd.DataFrame:
|
||||
raise ClientError(
|
||||
{"Error": {"Code": "NoSuchKey", "Message": "missing"}}, "GetObject"
|
||||
)
|
||||
|
||||
repo = HistoricEpcS3Repository(read_csv_gz=missing)
|
||||
|
||||
# Act
|
||||
with _valid_postcode():
|
||||
records = repo.get_for_postcode("AB33 8AL")
|
||||
|
||||
# Assert — a miss is the normal, expected outcome, not an exception.
|
||||
assert records == []
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue