mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Each tenancy signatory gets its own deal contact, with blank fields omitted 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
0ef1687bd7
commit
01e61a6275
2 changed files with 84 additions and 0 deletions
|
|
@ -0,0 +1,8 @@
|
|||
<Root>
|
||||
<Tenancy end_date="" start_date="05/12/2015">10071650064015<Tenant forenames="Harper" main-contact="no" person_title="Mrs" surname="Solecka">4007216<Mobile priority="1">09261195827</Mobile>
|
||||
</Tenant>
|
||||
<Tenant forenames="Naoimh" main-contact="yes" person_title="Miss" surname="Malyar">4007215<Mobile priority="10">09286114923</Mobile>
|
||||
<Telephone priority="20">02769674129</Telephone>
|
||||
</Tenant>
|
||||
</Tenancy>
|
||||
</Root>
|
||||
|
|
@ -136,3 +136,79 @@ def test_run_creates_an_associated_deal_contact_per_signatory_and_returns_a_summ
|
|||
)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
def test_run_creates_a_separate_contact_for_each_signatory(
|
||||
orchestrator: TenantDataSyncOrchestrator,
|
||||
mock_session: MagicMock,
|
||||
sdk_client: MagicMock,
|
||||
) -> None:
|
||||
# Arrange
|
||||
mock_session.post.return_value.content = _load_fixture(
|
||||
"abri_relay_getscstenantdata_multitenant_response.xml"
|
||||
)
|
||||
sdk_client.crm.contacts.basic_api.create.side_effect = [
|
||||
MagicMock(id="60123"),
|
||||
MagicMock(id="60124"),
|
||||
]
|
||||
|
||||
# Act
|
||||
result = orchestrator.run(PLACE_REF, deal_id=DEAL_ID)
|
||||
|
||||
# Assert
|
||||
assert result == TenantDataSyncSummary(
|
||||
tenancy_reference="10071650064015",
|
||||
contact_ids=("60123", "60124"),
|
||||
vulnerable_contact_count=0,
|
||||
)
|
||||
created_properties = [
|
||||
call.kwargs["simple_public_object_input_for_create"].properties
|
||||
for call in sdk_client.crm.contacts.basic_api.create.call_args_list
|
||||
]
|
||||
assert created_properties == [
|
||||
{
|
||||
"firstname": "Harper",
|
||||
"lastname": "Solecka",
|
||||
"mobilephone": "09261195827",
|
||||
"is_vulnerable": "false",
|
||||
},
|
||||
{
|
||||
"firstname": "Naoimh",
|
||||
"lastname": "Malyar",
|
||||
"mobilephone": "09286114923",
|
||||
"phone": "02769674129",
|
||||
"is_vulnerable": "false",
|
||||
},
|
||||
]
|
||||
associated_contact_ids = [
|
||||
call.kwargs["to_object_id"]
|
||||
for call in sdk_client.crm.associations.v4.basic_api.create.call_args_list
|
||||
]
|
||||
assert associated_contact_ids == ["60123", "60124"]
|
||||
|
||||
|
||||
def test_run_still_creates_a_contact_for_an_all_blank_signatory(
|
||||
orchestrator: TenantDataSyncOrchestrator,
|
||||
mock_session: MagicMock,
|
||||
sdk_client: MagicMock,
|
||||
) -> None:
|
||||
# Arrange
|
||||
mock_session.post.return_value.content = _tenancy_response(
|
||||
'<Tenant forenames="" main-contact="no" person_title="" surname="">4007216'
|
||||
'<Mobile priority="1"></Mobile></Tenant>'
|
||||
)
|
||||
|
||||
# Act
|
||||
result = orchestrator.run(PLACE_REF, deal_id=DEAL_ID)
|
||||
|
||||
# Assert
|
||||
assert result == TenantDataSyncSummary(
|
||||
tenancy_reference="10042020051017",
|
||||
contact_ids=("60123",),
|
||||
vulnerable_contact_count=0,
|
||||
)
|
||||
sdk_client.crm.contacts.basic_api.create.assert_called_once_with(
|
||||
simple_public_object_input_for_create=SimplePublicObjectInputForCreate(
|
||||
properties={"is_vulnerable": "false"}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue