From 4830f82b589da75760aafd1f1c878bd02b956f31 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Thu, 21 May 2026 16:32:15 +0000 Subject: [PATCH] test: add failing tests for get_col_to_description_mappings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- ...lord_description_overrides_orchestrator.py | 19 +++++ ...lord_description_overrides_orchestrator.py | 69 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 orchestration/landlord_description_overrides_orchestrator.py create mode 100644 tests/orchestration/test_landlord_description_overrides_orchestrator.py diff --git a/orchestration/landlord_description_overrides_orchestrator.py b/orchestration/landlord_description_overrides_orchestrator.py new file mode 100644 index 00000000..fb3fc61b --- /dev/null +++ b/orchestration/landlord_description_overrides_orchestrator.py @@ -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() diff --git a/tests/orchestration/test_landlord_description_overrides_orchestrator.py b/tests/orchestration/test_landlord_description_overrides_orchestrator.py new file mode 100644 index 00000000..5660bf78 --- /dev/null +++ b/tests/orchestration/test_landlord_description_overrides_orchestrator.py @@ -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"]}