mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Tenant-data fixtures carry fictional names and Ofcom-reserved phone numbers 🟪
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
8fd808ffd9
commit
578de8845a
3 changed files with 43 additions and 43 deletions
|
|
@ -1,8 +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>
|
||||
<Tenancy end_date="" start_date="05/12/2015">10071650064015<Tenant forenames="Ann" main-contact="no" person_title="Mrs" surname="Bloggs">4007216<Mobile priority="1">07700900456</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 forenames="Beth" main-contact="yes" person_title="Miss" surname="Sample">4007215<Mobile priority="10">07700900789</Mobile>
|
||||
<Telephone priority="20">01632960456</Telephone>
|
||||
</Tenant>
|
||||
</Tenancy>
|
||||
</Root>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<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>
|
||||
<Tenancy end_date="" start_date="15/12/2008">10042020051017<Tenant forenames="Jane" main-contact="yes" person_title="Mrs" surname="Doe">1368473<Mobile priority="10">07700900123</Mobile>
|
||||
<Telephone priority="101">01632960123</Telephone>
|
||||
<Vulnerability>Blindness</Vulnerability>
|
||||
</Tenant>
|
||||
</Tenancy>
|
||||
|
|
|
|||
|
|
@ -106,9 +106,9 @@ def test_run_creates_an_associated_deal_contact_per_signatory_and_returns_a_summ
|
|||
) -> None:
|
||||
# Arrange
|
||||
mock_session.post.return_value.content = _tenancy_response(
|
||||
'<Tenant forenames="Amanjeet" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Okello">1368473<Mobile priority="10">09853460810</Mobile>'
|
||||
'<Telephone priority="101">02473757484</Telephone></Tenant>'
|
||||
'<Tenant forenames="Jane" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Doe">1368473<Mobile priority="10">07700900123</Mobile>'
|
||||
'<Telephone priority="101">01632960123</Telephone></Tenant>'
|
||||
)
|
||||
|
||||
# Act
|
||||
|
|
@ -123,10 +123,10 @@ def test_run_creates_an_associated_deal_contact_per_signatory_and_returns_a_summ
|
|||
sdk_client.crm.contacts.basic_api.create.assert_called_once_with(
|
||||
simple_public_object_input_for_create=SimplePublicObjectInputForCreate(
|
||||
properties={
|
||||
"firstname": "Amanjeet",
|
||||
"lastname": "Okello",
|
||||
"mobilephone": "09853460810",
|
||||
"phone": "02473757484",
|
||||
"firstname": "Jane",
|
||||
"lastname": "Doe",
|
||||
"mobilephone": "07700900123",
|
||||
"phone": "01632960123",
|
||||
"is_vulnerable": "false",
|
||||
}
|
||||
)
|
||||
|
|
@ -173,16 +173,16 @@ def test_run_creates_a_separate_contact_for_each_signatory(
|
|||
]
|
||||
assert created_properties == [
|
||||
{
|
||||
"firstname": "Harper",
|
||||
"lastname": "Solecka",
|
||||
"mobilephone": "09261195827",
|
||||
"firstname": "Ann",
|
||||
"lastname": "Bloggs",
|
||||
"mobilephone": "07700900456",
|
||||
"is_vulnerable": "false",
|
||||
},
|
||||
{
|
||||
"firstname": "Naoimh",
|
||||
"lastname": "Malyar",
|
||||
"mobilephone": "09286114923",
|
||||
"phone": "02769674129",
|
||||
"firstname": "Beth",
|
||||
"lastname": "Sample",
|
||||
"mobilephone": "07700900789",
|
||||
"phone": "01632960456",
|
||||
"is_vulnerable": "false",
|
||||
},
|
||||
]
|
||||
|
|
@ -200,8 +200,8 @@ def test_run_picks_the_best_priority_number_of_each_kind_for_a_contact(
|
|||
) -> None:
|
||||
# Arrange
|
||||
mock_session.post.return_value.content = _tenancy_response(
|
||||
'<Tenant forenames="Amanjeet" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Okello">1368473'
|
||||
'<Tenant forenames="Jane" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Doe">1368473'
|
||||
"<Mobile>07000000099</Mobile>" # no priority: sorts last
|
||||
'<Mobile priority="1"> </Mobile>' # blank number: ignored
|
||||
'<Mobile priority="20">07000000020</Mobile>'
|
||||
|
|
@ -232,8 +232,8 @@ def test_run_fills_secondary_phone_number_with_the_best_leftover_number(
|
|||
) -> None:
|
||||
# Arrange
|
||||
mock_session.post.return_value.content = _tenancy_response(
|
||||
'<Tenant forenames="Amanjeet" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Okello">1368473'
|
||||
'<Tenant forenames="Jane" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Doe">1368473'
|
||||
'<Mobile priority="5">07000000005</Mobile>' # best mobile
|
||||
'<Mobile priority="20">07000000020</Mobile>'
|
||||
'<Telephone priority="7">01000000007</Telephone>' # best leftover
|
||||
|
|
@ -248,8 +248,8 @@ def test_run_fills_secondary_phone_number_with_the_best_leftover_number(
|
|||
sdk_client.crm.contacts.basic_api.create.assert_called_once_with(
|
||||
simple_public_object_input_for_create=SimplePublicObjectInputForCreate(
|
||||
properties={
|
||||
"firstname": "Amanjeet",
|
||||
"lastname": "Okello",
|
||||
"firstname": "Jane",
|
||||
"lastname": "Doe",
|
||||
"mobilephone": "07000000005",
|
||||
"phone": "01000000003",
|
||||
"secondary_phone_number": "01000000007",
|
||||
|
|
@ -269,14 +269,14 @@ def test_run_records_vulnerabilities_on_the_tenants_own_contact(
|
|||
) -> None:
|
||||
# Arrange
|
||||
mock_session.post.return_value.content = _tenancy_response(
|
||||
'<Tenant forenames="Harper" main-contact="no" person_title="Mrs"'
|
||||
' surname="Solecka">4007216'
|
||||
'<Tenant forenames="Ann" main-contact="no" person_title="Mrs"'
|
||||
' surname="Bloggs">4007216'
|
||||
"<Vulnerability>Blindness</Vulnerability>"
|
||||
"<Vulnerability>Hard of hearing</Vulnerability>"
|
||||
"<Vulnerability>BLINDNESS</Vulnerability>" # within-tenant duplicate
|
||||
"</Tenant>"
|
||||
'<Tenant forenames="Naoimh" main-contact="yes" person_title="Miss"'
|
||||
' surname="Malyar">4007215</Tenant>'
|
||||
'<Tenant forenames="Beth" main-contact="yes" person_title="Miss"'
|
||||
' surname="Sample">4007215</Tenant>'
|
||||
)
|
||||
sdk_client.crm.contacts.basic_api.create.side_effect = [
|
||||
MagicMock(id="60123"),
|
||||
|
|
@ -298,14 +298,14 @@ def test_run_records_vulnerabilities_on_the_tenants_own_contact(
|
|||
]
|
||||
assert created_properties == [
|
||||
{
|
||||
"firstname": "Harper",
|
||||
"lastname": "Solecka",
|
||||
"firstname": "Ann",
|
||||
"lastname": "Bloggs",
|
||||
"is_vulnerable": "true",
|
||||
"vulnerability_description": "Blindness\nHard of hearing",
|
||||
},
|
||||
{
|
||||
"firstname": "Naoimh",
|
||||
"lastname": "Malyar",
|
||||
"firstname": "Beth",
|
||||
"lastname": "Sample",
|
||||
"is_vulnerable": "false",
|
||||
},
|
||||
]
|
||||
|
|
@ -435,7 +435,7 @@ def _pii_echoing_api_error() -> ContactsApiException:
|
|||
api_error.body = json.dumps(
|
||||
{
|
||||
"status": "error",
|
||||
"message": 'Invalid value "09853460810" for mobilephone (Amanjeet Okello)',
|
||||
"message": 'Invalid value "07700900123" for mobilephone (Jane Doe)',
|
||||
"correlationId": "corr-abc-123",
|
||||
"category": "VALIDATION_ERROR",
|
||||
}
|
||||
|
|
@ -451,8 +451,8 @@ def test_run_raises_an_error_scrubbed_of_the_hubspot_response_body(
|
|||
) -> None:
|
||||
# Arrange
|
||||
mock_session.post.return_value.content = _tenancy_response(
|
||||
'<Tenant forenames="Amanjeet" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Okello">1368473<Mobile priority="10">09853460810</Mobile></Tenant>'
|
||||
'<Tenant forenames="Jane" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Doe">1368473<Mobile priority="10">07700900123</Mobile></Tenant>'
|
||||
)
|
||||
sdk_client.crm.contacts.basic_api.create.side_effect = _pii_echoing_api_error()
|
||||
|
||||
|
|
@ -465,9 +465,9 @@ def test_run_raises_an_error_scrubbed_of_the_hubspot_response_body(
|
|||
assert "400" in str(exc_info.value)
|
||||
assert "VALIDATION_ERROR" in str(exc_info.value)
|
||||
assert "corr-abc-123" in str(exc_info.value)
|
||||
assert "Amanjeet" not in rendered_traceback
|
||||
assert "Okello" not in rendered_traceback
|
||||
assert "09853460810" not in rendered_traceback
|
||||
assert "Jane" not in rendered_traceback
|
||||
assert "Doe" not in rendered_traceback
|
||||
assert "07700900123" not in rendered_traceback
|
||||
|
||||
|
||||
def test_run_fails_fast_when_association_fails_and_reports_the_orphaned_contact(
|
||||
|
|
@ -497,8 +497,8 @@ def test_run_fails_fast_when_association_fails_and_reports_the_orphaned_contact(
|
|||
assert sdk_client.crm.contacts.basic_api.create.call_count == 1 # fail fast
|
||||
rendered_traceback = "".join(traceback.format_exception(error))
|
||||
assert "corr-abc-123" in str(error) # scrubbed diagnostics carried through
|
||||
assert "Solecka" not in rendered_traceback
|
||||
assert "09261195827" not in rendered_traceback
|
||||
assert "Bloggs" not in rendered_traceback
|
||||
assert "07700900456" not in rendered_traceback
|
||||
|
||||
|
||||
def test_run_retries_a_rate_limited_hubspot_call_before_succeeding(
|
||||
|
|
@ -508,8 +508,8 @@ def test_run_retries_a_rate_limited_hubspot_call_before_succeeding(
|
|||
) -> None:
|
||||
# Arrange
|
||||
mock_session.post.return_value.content = _tenancy_response(
|
||||
'<Tenant forenames="Amanjeet" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Okello">1368473</Tenant>'
|
||||
'<Tenant forenames="Jane" main-contact="yes" person_title="Mrs"'
|
||||
' surname="Doe">1368473</Tenant>'
|
||||
)
|
||||
rate_limited = ContactsApiException(status=429, reason="Too Many Requests")
|
||||
rate_limited.headers = {"x-hubspot-ratelimit-interval-milliseconds": "0"}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue