Runner-up number fills the contact's secondary phone number 🟥

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-06 13:28:56 +00:00
parent 1752a6cf10
commit 10636c1752
5 changed files with 55 additions and 1 deletions

View file

@ -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, ...]

View file

@ -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=(),
)

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<response>
<success>false</success>
<code>RelayError</code>
<message>No Tenancy Found for Query FOR EACH re-tncy-place WHERE re-tncy-place.org-code = &apos;01&apos;
and re-tncy-place.place-ref = &apos;1004202A&apos;
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</message>
</response>

View file

@ -0,0 +1,7 @@
<Root>
<Tenancy end_date="" start_date="15/12/2008">10042020051017<Tenant forenames="Amanjeet" main-contact="yes" person_title="Mrs" surname="Okello">1368473<Mobile priority="10">09853460810</Mobile>
<Telephone priority="101">02473757484</Telephone>
<Vulnerability>Blindness</Vulnerability>
</Tenant>
</Tenancy>
</Root>

View file

@ -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(
'<Tenant forenames="Amanjeet" main-contact="yes" person_title="Mrs"'
' surname="Okello">1368473'
'<Mobile priority="5">07000000005</Mobile>' # best mobile
'<Mobile priority="20">07000000020</Mobile>'
'<Telephone priority="7">01000000007</Telephone>' # best leftover
'<Telephone priority="3">01000000003</Telephone>' # best landline
"</Tenant>"
)
# 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,