A changed booking amends the deal's OpenHousing appointment 🟩

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-07 10:01:01 +00:00
parent a93346ec7f
commit 9bae8df6ea
4 changed files with 33 additions and 4 deletions

View file

@ -233,7 +233,19 @@ class AbriOrchestrator:
def amend_job(
self, booking: ConfirmedSurveyBooking
) -> AmendJobOrchestrationResult:
raise NotImplementedError
job_no = self._deal_database.job_no_for_deal(booking.deal_id)
if job_no is None:
raise JobNoNotYetRecordedError(deal_id=booking.deal_id)
return self._abri.amend_job(
AmendJobRequest(
job_no=job_no,
appointment_date=booking.confirmed_survey_date,
appointment_time=slot_for_confirmed_time(
booking.confirmed_survey_time
),
)
)
def log_job(self, booking: ConfirmedSurveyBooking) -> LogJobOrchestrationResult:
descriptions = build_job_descriptions(booking.deal_name)

View file

@ -22,7 +22,7 @@ All tenant details below are fictional (Ofcom-reserved number ranges).
import os
from pathlib import Path
from typing import Any, List, cast
from typing import Any, List, Optional, cast
from dotenv import dotenv_values
from hubspot.client import Client # type: ignore[reportMissingTypeStubs]
@ -101,11 +101,14 @@ def _stubbed_abri_client() -> AbriClient:
class _UnusedDealDatabase:
"""Satisfies the gateway dependency; the tenant-data flow never writes it."""
"""Satisfies the gateway dependency; the tenant-data flow never touches it."""
def record_job_no(self, deal_id: str, job_no: str) -> None:
raise AssertionError("tenant-data sync must not touch the deal database")
def job_no_for_deal(self, deal_id: str) -> Optional[str]:
raise AssertionError("tenant-data sync must not touch the deal database")
def _archive_contacts(sdk_client: Client) -> None:
if not CONTACT_IDS_TO_ARCHIVE:

View file

@ -3,7 +3,7 @@ import traceback
import xml.etree.ElementTree as ET
from datetime import date
from pathlib import Path
from typing import List, Tuple
from typing import List, Optional, Tuple
from unittest.mock import MagicMock, patch
import pytest
@ -57,6 +57,16 @@ class FakeDealDatabase:
def record_job_no(self, deal_id: str, job_no: str) -> None:
self.recorded_job_nos.append((deal_id, job_no))
def job_no_for_deal(self, deal_id: str) -> Optional[str]:
return next(
(
job_no
for recorded_deal_id, job_no in self.recorded_job_nos
if recorded_deal_id == deal_id
),
None,
)
@pytest.fixture()
def mock_session() -> MagicMock:

View file

@ -2,6 +2,7 @@ import json
import traceback
import xml.etree.ElementTree as ET
from pathlib import Path
from typing import Optional
from unittest.mock import MagicMock, patch
import pytest
@ -66,6 +67,9 @@ class FakeDealDatabase:
def record_job_no(self, deal_id: str, job_no: str) -> None:
raise AssertionError("tenant-data sync must not touch the deal database")
def job_no_for_deal(self, deal_id: str) -> Optional[str]:
raise AssertionError("tenant-data sync must not touch the deal database")
@pytest.fixture()
def orchestrator(