rename tenant data sync to abri tenant data sync

This commit is contained in:
Daniel Roth 2026-07-06 14:05:42 +00:00
parent 578de8845a
commit 76896f9a8e
2 changed files with 23 additions and 27 deletions

View file

@ -85,7 +85,7 @@ class TenantDataSyncError(Exception):
)
class TenantDataSyncOrchestrator:
class AbriTenantDataSyncOrchestrator:
"""Syncs an Abri tenancy's signatories to a HubSpot deal.
Tenant data flows straight from Abri to HubSpot; nothing is persisted
@ -110,9 +110,7 @@ class TenantDataSyncOrchestrator:
associated_ids: List[str] = []
for tenant_index, tenant in enumerate(tenancy.tenants):
try:
contact_id = self._hubspot.create_contact(
_contact_properties(tenant)
)
contact_id = self._hubspot.create_contact(_contact_properties(tenant))
contact_ids.append(contact_id)
self._hubspot.associate_contact_to_deal(
deal_id=deal_id, contact_id=contact_id

View file

@ -15,9 +15,9 @@ from infrastructure.hubspot.deal_contacts_client import HubspotDealContactsClien
from infrastructure.abri.abri_client import AbriClient
from infrastructure.abri.config import AbriConfig
from infrastructure.abri.errors import AbriResponseParseError, AbriTransportError
from orchestration.tenant_data_sync_orchestrator import (
from orchestration.abri_tenant_data_sync_orchestrator import (
TenantDataSyncError,
TenantDataSyncOrchestrator,
AbriTenantDataSyncOrchestrator,
TenantDataSyncSummary,
)
@ -62,13 +62,13 @@ def sdk_client() -> MagicMock:
@pytest.fixture()
def orchestrator(
mock_session: MagicMock, sdk_client: MagicMock
) -> TenantDataSyncOrchestrator:
) -> AbriTenantDataSyncOrchestrator:
with patch(
"infrastructure.abri.abri_client.requests.Session",
return_value=mock_session,
):
abri_client = AbriClient(config=CONFIG)
return TenantDataSyncOrchestrator(
return AbriTenantDataSyncOrchestrator(
abri_client=abri_client,
hubspot=HubspotDealContactsClient(sdk_client=sdk_client),
)
@ -78,7 +78,7 @@ def orchestrator(
def test_run_sends_the_recorded_getscstenantdata_envelope_to_the_relay_endpoint(
orchestrator: TenantDataSyncOrchestrator, mock_session: MagicMock
orchestrator: AbriTenantDataSyncOrchestrator, mock_session: MagicMock
) -> None:
# Arrange
mock_session.post.return_value.content = _tenancy_response("")
@ -100,7 +100,7 @@ def test_run_sends_the_recorded_getscstenantdata_envelope_to_the_relay_endpoint(
def test_run_creates_an_associated_deal_contact_per_signatory_and_returns_a_summary(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -145,7 +145,7 @@ 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,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -194,7 +194,7 @@ def test_run_creates_a_separate_contact_for_each_signatory(
def test_run_picks_the_best_priority_number_of_each_kind_for_a_contact(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -216,17 +216,15 @@ def test_run_picks_the_best_priority_number_of_each_kind_for_a_contact(
orchestrator.run(PLACE_REF, deal_id=DEAL_ID)
# Assert
created_properties = (
sdk_client.crm.contacts.basic_api.create.call_args.kwargs[
"simple_public_object_input_for_create"
].properties
)
created_properties = sdk_client.crm.contacts.basic_api.create.call_args.kwargs[
"simple_public_object_input_for_create"
].properties
assert created_properties["mobilephone"] == "07000000005"
assert created_properties["phone"] == "01000000007"
def test_run_fills_secondary_phone_number_with_the_best_leftover_number(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -263,7 +261,7 @@ def test_run_fills_secondary_phone_number_with_the_best_leftover_number(
def test_run_records_vulnerabilities_on_the_tenants_own_contact(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -312,7 +310,7 @@ def test_run_records_vulnerabilities_on_the_tenants_own_contact(
def test_run_still_creates_a_contact_for_an_all_blank_signatory(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -342,7 +340,7 @@ def test_run_still_creates_a_contact_for_an_all_blank_signatory(
def test_run_treats_a_tenancy_with_no_signatories_as_a_valid_zero_contact_outcome(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -365,7 +363,7 @@ def test_run_treats_a_tenancy_with_no_signatories_as_a_valid_zero_contact_outcom
def test_run_returns_the_abri_rejection_verbatim_and_makes_no_hubspot_calls(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -398,7 +396,7 @@ def test_run_returns_the_abri_rejection_verbatim_and_makes_no_hubspot_calls(
],
)
def test_run_raises_a_retriable_parse_error_on_an_unexpectedly_shaped_response(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
body: bytes,
@ -413,7 +411,7 @@ def test_run_raises_a_retriable_parse_error_on_an_unexpectedly_shaped_response(
def test_run_raises_a_transport_error_when_the_relay_is_unreachable(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -445,7 +443,7 @@ def _pii_echoing_api_error() -> ContactsApiException:
def test_run_raises_an_error_scrubbed_of_the_hubspot_response_body(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -471,7 +469,7 @@ def test_run_raises_an_error_scrubbed_of_the_hubspot_response_body(
def test_run_fails_fast_when_association_fails_and_reports_the_orphaned_contact(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None:
@ -502,7 +500,7 @@ def test_run_fails_fast_when_association_fails_and_reports_the_orphaned_contact(
def test_run_retries_a_rate_limited_hubspot_call_before_succeeding(
orchestrator: TenantDataSyncOrchestrator,
orchestrator: AbriTenantDataSyncOrchestrator,
mock_session: MagicMock,
sdk_client: MagicMock,
) -> None: