From 0ef1687bd7b70a4ed7e123b11ebb26566014cd05 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Mon, 6 Jul 2026 13:26:07 +0000 Subject: [PATCH] =?UTF-8?q?Relay=20receives=20the=20spec's=20recorded=20ge?= =?UTF-8?q?tSCSTenantData=20envelope=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 --- ...relay_getscstenantdata_request_example.xml | 11 +++++++ .../test_tenant_data_sync_orchestrator.py | 29 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/abri/abri_relay_getscstenantdata_request_example.xml diff --git a/tests/abri/abri_relay_getscstenantdata_request_example.xml b/tests/abri/abri_relay_getscstenantdata_request_example.xml new file mode 100644 index 000000000..785710678 --- /dev/null +++ b/tests/abri/abri_relay_getscstenantdata_request_example.xml @@ -0,0 +1,11 @@ + + +
+ +
+ + + + + +
diff --git a/tests/orchestration/test_tenant_data_sync_orchestrator.py b/tests/orchestration/test_tenant_data_sync_orchestrator.py index 89e188b35..771abdb9d 100644 --- a/tests/orchestration/test_tenant_data_sync_orchestrator.py +++ b/tests/orchestration/test_tenant_data_sync_orchestrator.py @@ -1,3 +1,5 @@ +import xml.etree.ElementTree as ET +from pathlib import Path from unittest.mock import MagicMock, patch import pytest @@ -13,6 +15,7 @@ from orchestration.tenant_data_sync_orchestrator import ( TenantDataSyncSummary, ) +FIXTURE_DIR = Path(__file__).parents[1] / "abri" ENDPOINT_URL = "https://relay.example.test/api/DomnaRelay?code=test-function-key" PLACE_REF = PlaceRef("1004202A") DEAL_ID = "9876543210" @@ -25,6 +28,10 @@ CONFIG = AbriConfig( ) +def _load_fixture(name: str) -> bytes: + return (FIXTURE_DIR / name).read_bytes() + + def _tenancy_response( tenants_xml: str, tenancy_reference: str = "10042020051017" ) -> bytes: @@ -61,6 +68,28 @@ def orchestrator( ) +# --- outbound request: the spec's recorded envelope --- + + +def test_run_sends_the_recorded_getscstenantdata_envelope_to_the_relay_endpoint( + orchestrator: TenantDataSyncOrchestrator, mock_session: MagicMock +) -> None: + # Arrange + mock_session.post.return_value.content = _tenancy_response("") + + # Act + orchestrator.run(PLACE_REF, deal_id=DEAL_ID) + + # Assert + (url,) = mock_session.post.call_args.args + sent_body: bytes = mock_session.post.call_args.kwargs["data"] + expected_body = _load_fixture("abri_relay_getscstenantdata_request_example.xml") + assert url == ENDPOINT_URL + assert ET.canonicalize(xml_data=sent_body, strip_text=True) == ET.canonicalize( + xml_data=expected_body, strip_text=True + ) + + # --- happy path: signatories become associated deal contacts ---