mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
test: add failing tests for get_col_to_description_mappings
Drive the contract for LandlordDescriptionOverridesOrchestrator. get_col_to_description_mappings: given a list of UserAddress sharing the same landlord_additional_info keys, return each key mapped to the list of values found across all addresses. Tests are red — the method still raises NotImplementedError. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
68809a68c1
commit
4830f82b58
2 changed files with 88 additions and 0 deletions
19
orchestration/landlord_description_overrides_orchestrator.py
Normal file
19
orchestration/landlord_description_overrides_orchestrator.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from repositories.user_address.user_address_repository import UserAddressRepository
|
||||
from domain.addresses.user_address import UserAddress
|
||||
|
||||
|
||||
class LandlordDescriptionOverridesOrchestrator:
|
||||
def __init__(self, user_address_repo: UserAddressRepository) -> None:
|
||||
self._user_address_repo = user_address_repo
|
||||
|
||||
def get_user_address(
|
||||
self,
|
||||
input_s3_uri: str,
|
||||
) -> list[UserAddress]:
|
||||
return self._user_address_repo.load_batch(input_s3_uri)
|
||||
|
||||
def get_col_to_description_mappings(
|
||||
self, list_of_user_address: list[UserAddress]
|
||||
) -> dict[str, list[str]]:
|
||||
|
||||
raise NotImplementedError()
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from domain.addresses.user_address import UserAddress
|
||||
from domain.postcode import Postcode
|
||||
from orchestration.landlord_description_overrides_orchestrator import (
|
||||
LandlordDescriptionOverridesOrchestrator,
|
||||
)
|
||||
from repositories.user_address.user_address_repository import UserAddressRepository
|
||||
|
||||
|
||||
class _StubUserAddressRepository(UserAddressRepository):
|
||||
"""``get_col_to_description_mappings`` never touches the repo."""
|
||||
|
||||
def load_batch(self, s3_uri: str) -> list[UserAddress]:
|
||||
raise NotImplementedError()
|
||||
|
||||
def save_batch(self, addresses: list[UserAddress], path_prefix: str) -> str:
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
def _make_user_address(landlord_additional_info: dict[str, str]) -> UserAddress:
|
||||
return UserAddress(
|
||||
user_address="1 High St",
|
||||
postcode=Postcode("AA1 1AA"),
|
||||
landlord_additional_info=landlord_additional_info,
|
||||
)
|
||||
|
||||
|
||||
def _orchestrator() -> LandlordDescriptionOverridesOrchestrator:
|
||||
return LandlordDescriptionOverridesOrchestrator(
|
||||
user_address_repo=_StubUserAddressRepository()
|
||||
)
|
||||
|
||||
|
||||
def test_collects_every_value_per_shared_key() -> None:
|
||||
# arrange: every address carries the same keys, all values distinct.
|
||||
addresses = [
|
||||
_make_user_address({"description": "cosy", "condition": "new"}),
|
||||
_make_user_address({"description": "spacious", "condition": "worn"}),
|
||||
_make_user_address({"description": "bright", "condition": "fair"}),
|
||||
]
|
||||
|
||||
# act
|
||||
mappings = _orchestrator().get_col_to_description_mappings(addresses)
|
||||
|
||||
# assert
|
||||
assert mappings == {
|
||||
"description": ["cosy", "spacious", "bright"],
|
||||
"condition": ["new", "worn", "fair"],
|
||||
}
|
||||
|
||||
|
||||
def test_empty_address_list_yields_empty_mapping() -> None:
|
||||
# arrange / act
|
||||
mappings = _orchestrator().get_col_to_description_mappings([])
|
||||
|
||||
# assert
|
||||
assert mappings == {}
|
||||
|
||||
|
||||
def test_single_address_yields_single_value_per_key() -> None:
|
||||
# arrange
|
||||
addresses = [_make_user_address({"description": "cosy"})]
|
||||
|
||||
# act
|
||||
mappings = _orchestrator().get_col_to_description_mappings(addresses)
|
||||
|
||||
# assert
|
||||
assert mappings == {"description": ["cosy"]}
|
||||
Loading…
Add table
Reference in a new issue