From 6912dabf2211a95dab657cd90b5dc2329c3dedf9 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Mon, 6 Jul 2026 15:52:35 +0000 Subject: [PATCH] =?UTF-8?q?A=20logged=20job's=20job=5Fno=20is=20written=20?= =?UTF-8?q?to=20HubSpot=20and=20then=20the=20deal=20database=20?= =?UTF-8?q?=F0=9F=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- .../test_abri_log_job_orchestrator.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/orchestration/test_abri_log_job_orchestrator.py b/tests/orchestration/test_abri_log_job_orchestrator.py index afdc02f39..2cfb265f8 100644 --- a/tests/orchestration/test_abri_log_job_orchestrator.py +++ b/tests/orchestration/test_abri_log_job_orchestrator.py @@ -5,6 +5,7 @@ from typing import List, Tuple from unittest.mock import MagicMock, patch import pytest +from hubspot.crm.deals import SimplePublicObjectInput # type: ignore[reportMissingTypeStubs] from domain.abri.models import PlaceRef from infrastructure.abri.abri_client import AbriClient @@ -13,6 +14,7 @@ from infrastructure.hubspot.deal_properties_client import HubspotDealPropertiesC from orchestration.abri_log_job_orchestrator import ( AbriLogJobOrchestrator, ConfirmedSurveyBooking, + LogJobSummary, ) FIXTURE_DIR = Path(__file__).parents[1] / "abri" @@ -119,3 +121,31 @@ def test_run_sends_a_logjob_envelope_built_from_the_deals_fields( "resource": "NAULKH", "resource_group": "Surveyors", } + + +# --- happy path: the returned job_no lands in HubSpot, then the database --- + + +def test_run_writes_the_job_no_to_the_hubspot_deal_and_then_the_database( + orchestrator: AbriLogJobOrchestrator, + mock_session: MagicMock, + sdk_client: MagicMock, + deal_database: FakeDealDatabase, +) -> None: + # Arrange + mock_session.post.return_value.content = _load_fixture( + "abri_relay_logjob_success_response.xml" + ) + + # Act + result = orchestrator.run(BOOKING) + + # Assert + assert result == LogJobSummary(deal_id=DEAL_ID, job_no="AD0226519") + sdk_client.crm.deals.basic_api.update.assert_called_once_with( + DEAL_ID, + simple_public_object_input=SimplePublicObjectInput( + properties={"client_booking_reference": "AD0226519"} + ), + ) + assert deal_database.recorded_job_nos == [(DEAL_ID, "AD0226519")]