mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Transient HubSpot failures are retried under the shared rate-limit policy 🟥
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
81d25caead
commit
8d684c57c7
1 changed files with 29 additions and 0 deletions
|
|
@ -499,3 +499,32 @@ def test_run_fails_fast_when_association_fails_and_reports_the_orphaned_contact(
|
|||
assert "corr-abc-123" in str(error) # scrubbed diagnostics carried through
|
||||
assert "Solecka" not in rendered_traceback
|
||||
assert "09261195827" not in rendered_traceback
|
||||
|
||||
|
||||
def test_run_retries_a_rate_limited_hubspot_call_before_succeeding(
|
||||
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</Tenant>'
|
||||
)
|
||||
rate_limited = ContactsApiException(status=429, reason="Too Many Requests")
|
||||
rate_limited.headers = {"x-hubspot-ratelimit-interval-milliseconds": "0"}
|
||||
sdk_client.crm.contacts.basic_api.create.side_effect = [
|
||||
rate_limited,
|
||||
MagicMock(id="60123"),
|
||||
]
|
||||
|
||||
# Act
|
||||
result = orchestrator.run(PLACE_REF, deal_id=DEAL_ID)
|
||||
|
||||
# Assert
|
||||
assert result == TenantDataSyncSummary(
|
||||
tenancy_reference="10042020051017",
|
||||
contact_ids=("60123",),
|
||||
vulnerable_contact_count=0,
|
||||
)
|
||||
assert sdk_client.crm.contacts.basic_api.create.call_count == 2
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue