mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Raise PostcodeNotFound for an unusable postcode 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
cd503411d2
commit
49becf1ada
1 changed files with 20 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ from botocore.exceptions import ClientError
|
|||
|
||||
from backend.utils.addressMatch import AddressMatch
|
||||
from datatypes.epc.domain.historic_epc import HistoricEpc
|
||||
from repositories.historic_epc.historic_epc_repository import PostcodeNotFound
|
||||
from repositories.historic_epc.historic_epc_s3_repository import (
|
||||
HistoricEpcS3Repository,
|
||||
)
|
||||
|
|
@ -108,3 +109,22 @@ def test_non_missing_read_error_propagates():
|
|||
with _valid_postcode():
|
||||
with pytest.raises(ClientError):
|
||||
repo.get_for_postcode("AB33 8AL")
|
||||
|
||||
|
||||
def test_empty_postcode_raises_postcode_not_found():
|
||||
# Arrange
|
||||
repo = HistoricEpcS3Repository(read_csv_gz=lambda bucket, key: _df([]))
|
||||
|
||||
# Act / Assert — an unusable key, distinct from a valid-but-absent postcode.
|
||||
with pytest.raises(PostcodeNotFound):
|
||||
repo.get_for_postcode(" ")
|
||||
|
||||
|
||||
def test_invalid_postcode_raises_postcode_not_found():
|
||||
# Arrange
|
||||
repo = HistoricEpcS3Repository(read_csv_gz=lambda bucket, key: _df([]))
|
||||
|
||||
# Act / Assert
|
||||
with patch.object(AddressMatch, "is_valid_postcode", return_value=False):
|
||||
with pytest.raises(PostcodeNotFound):
|
||||
repo.get_for_postcode("NONSENSE")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue