mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
A logged job's job_no is written to HubSpot and then the deal database 🟥
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
ce7b302c17
commit
6912dabf22
1 changed files with 30 additions and 0 deletions
|
|
@ -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")]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue