Amending an appointment needs only the deal's changed date and time 🟪

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-07 10:07:23 +00:00
parent 8daaa0974d
commit 8d70679ab0
2 changed files with 21 additions and 16 deletions

View file

@ -128,6 +128,15 @@ class DealDatabaseGateway(Protocol):
def job_no_for_deal(self, deal_id: str) -> Optional[str]: ...
@dataclass(frozen=True)
class AppointmentChange:
"""The deal fields a changed survey booking contributes to an AmendJob."""
deal_id: str
confirmed_survey_date: date
confirmed_survey_time: Optional[str]
AmendJobOrchestrationResult = Union[AppointmentAmended, AbriRequestRejected]
@ -230,19 +239,17 @@ class AbriOrchestrator:
),
)
def amend_job(
self, booking: ConfirmedSurveyBooking
) -> AmendJobOrchestrationResult:
job_no = self._deal_database.job_no_for_deal(booking.deal_id)
def amend_job(self, change: AppointmentChange) -> AmendJobOrchestrationResult:
job_no = self._deal_database.job_no_for_deal(change.deal_id)
if job_no is None:
raise JobNoNotYetRecordedError(deal_id=booking.deal_id)
raise JobNoNotYetRecordedError(deal_id=change.deal_id)
return self._abri.amend_job(
AmendJobRequest(
job_no=job_no,
appointment_date=booking.confirmed_survey_date,
appointment_date=change.confirmed_survey_date,
appointment_time=slot_for_confirmed_time(
booking.confirmed_survey_time
change.confirmed_survey_time
),
)
)

View file

@ -6,14 +6,14 @@ from unittest.mock import MagicMock, patch
import pytest
from domain.abri.models import AbriRequestRejected, AppointmentAmended, PlaceRef
from domain.abri.models import AbriRequestRejected, AppointmentAmended
from infrastructure.abri.abri_client import AbriClient
from infrastructure.abri.config import AbriConfig
from infrastructure.hubspot.deal_contacts_client import HubspotDealContactsClient
from infrastructure.hubspot.deal_properties_client import HubspotDealPropertiesClient
from orchestration.abri_orchestrator import (
AbriOrchestrator,
ConfirmedSurveyBooking,
AppointmentChange,
JobNoNotYetRecordedError,
)
@ -29,10 +29,8 @@ CONFIG = AbriConfig(
default_resource="NAULKH",
)
BOOKING = ConfirmedSurveyBooking(
CHANGE = AppointmentChange(
deal_id=DEAL_ID,
place_ref=PlaceRef("1007165"),
deal_name="49 Admers Crescent",
confirmed_survey_date=date(2026, 6, 24),
confirmed_survey_time="14:30",
)
@ -101,7 +99,7 @@ def test_amend_job_sends_an_amendoptiappt_envelope_for_the_deals_recorded_job(
)
# Act
orchestrator.amend_job(BOOKING)
orchestrator.amend_job(CHANGE)
# Assert
(url,) = mock_session.post.call_args.args
@ -134,7 +132,7 @@ def test_amend_job_returns_the_amended_appointment(
)
# Act
result = orchestrator.amend_job(BOOKING)
result = orchestrator.amend_job(CHANGE)
# Assert
assert result == AppointmentAmended(
@ -153,7 +151,7 @@ def test_amend_job_raises_a_retriable_error_when_no_job_no_has_been_recorded(
) -> None:
# Act / Assert
with pytest.raises(JobNoNotYetRecordedError):
orchestrator.amend_job(BOOKING)
orchestrator.amend_job(CHANGE)
assert mock_session.post.call_count == 0
@ -172,7 +170,7 @@ def test_amend_job_returns_the_openhousing_rejection_verbatim(
)
# Act
result = orchestrator.amend_job(BOOKING)
result = orchestrator.amend_job(CHANGE)
# Assert
assert isinstance(result, AbriRequestRejected)