From 10636c17522e6414c6044231640ecf2932166a01 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Mon, 6 Jul 2026 13:28:56 +0000 Subject: [PATCH] =?UTF-8?q?Runner-up=20number=20fills=20the=20contact's=20?= =?UTF-8?q?secondary=20phone=20number=20=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- domain/abri/models.py | 4 ++- infrastructure/abri/abri_client.py | 1 + ...y_getscstenantdata_relayerror_response.xml | 10 ++++++ ...elay_getscstenantdata_success_response.xml | 7 ++++ .../test_tenant_data_sync_orchestrator.py | 34 +++++++++++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tests/abri/abri_relay_getscstenantdata_relayerror_response.xml create mode 100644 tests/abri/abri_relay_getscstenantdata_success_response.xml diff --git a/domain/abri/models.py b/domain/abri/models.py index ceb03c34f..d96d27fda 100644 --- a/domain/abri/models.py +++ b/domain/abri/models.py @@ -57,13 +57,15 @@ class Tenant: Person title, per-person references, the main-contact flag and tenancy dates are deliberately dropped at parse time (data minimisation); mobile and telephone are the single best number of each kind, pre-selected by - priority. + priority, and secondary_number is the best of the numbers they left + unused. """ forenames: str surname: str mobile: Optional[str] telephone: Optional[str] + secondary_number: Optional[str] vulnerabilities: Tuple[str, ...] diff --git a/infrastructure/abri/abri_client.py b/infrastructure/abri/abri_client.py index 3d5a7f537..8594e2473 100644 --- a/infrastructure/abri/abri_client.py +++ b/infrastructure/abri/abri_client.py @@ -216,6 +216,7 @@ class AbriClient: surname=(element.get("surname") or "").strip(), mobile=_select_phone_number(element.findall("Mobile")), telephone=_select_phone_number(element.findall("Telephone")), + secondary_number=None, vulnerabilities=(), ) diff --git a/tests/abri/abri_relay_getscstenantdata_relayerror_response.xml b/tests/abri/abri_relay_getscstenantdata_relayerror_response.xml new file mode 100644 index 000000000..bc6da7b89 --- /dev/null +++ b/tests/abri/abri_relay_getscstenantdata_relayerror_response.xml @@ -0,0 +1,10 @@ + + + false + RelayError + No Tenancy Found for Query FOR EACH re-tncy-place WHERE re-tncy-place.org-code = '01' +and re-tncy-place.place-ref = '1004202A' +and re-tncy-place.start-date LE TODAY +and (re-tncy-place.end-date GE TODAY OR re-tncy-place.end-date = ?)and re-tncy-place.prime-place NO-LOCK, +EACH re-tenancy OF re-tncy-place NO-LOCK + diff --git a/tests/abri/abri_relay_getscstenantdata_success_response.xml b/tests/abri/abri_relay_getscstenantdata_success_response.xml new file mode 100644 index 000000000..8f3080898 --- /dev/null +++ b/tests/abri/abri_relay_getscstenantdata_success_response.xml @@ -0,0 +1,7 @@ + + 10042020051017136847309853460810 + 02473757484 + Blindness + + + diff --git a/tests/orchestration/test_tenant_data_sync_orchestrator.py b/tests/orchestration/test_tenant_data_sync_orchestrator.py index 329f04a90..946e34cdb 100644 --- a/tests/orchestration/test_tenant_data_sync_orchestrator.py +++ b/tests/orchestration/test_tenant_data_sync_orchestrator.py @@ -219,6 +219,40 @@ def test_run_picks_the_best_priority_number_of_each_kind_for_a_contact( assert created_properties["phone"] == "01000000007" +def test_run_fills_secondary_phone_number_with_the_best_leftover_number( + orchestrator: TenantDataSyncOrchestrator, + mock_session: MagicMock, + sdk_client: MagicMock, +) -> None: + # Arrange + mock_session.post.return_value.content = _tenancy_response( + '1368473' + '07000000005' # best mobile + '07000000020' + '01000000007' # best leftover + '01000000003' # best landline + "" + ) + + # Act + orchestrator.run(PLACE_REF, deal_id=DEAL_ID) + + # Assert + sdk_client.crm.contacts.basic_api.create.assert_called_once_with( + simple_public_object_input_for_create=SimplePublicObjectInputForCreate( + properties={ + "firstname": "Amanjeet", + "lastname": "Okello", + "mobilephone": "07000000005", + "phone": "01000000003", + "secondary_phone_number": "01000000007", + "is_vulnerable": "false", + } + ) + ) + + def test_run_still_creates_a_contact_for_an_all_blank_signatory( orchestrator: TenantDataSyncOrchestrator, mock_session: MagicMock,