diff --git a/tests/orchestration/test_abri_log_job_orchestrator.py b/tests/orchestration/test_abri_log_job_orchestrator.py index 2cfb265f8..6bab8181a 100644 --- a/tests/orchestration/test_abri_log_job_orchestrator.py +++ b/tests/orchestration/test_abri_log_job_orchestrator.py @@ -7,7 +7,7 @@ from unittest.mock import MagicMock, patch import pytest from hubspot.crm.deals import SimplePublicObjectInput # type: ignore[reportMissingTypeStubs] -from domain.abri.models import PlaceRef +from domain.abri.models import AbriRequestRejected, PlaceRef from infrastructure.abri.abri_client import AbriClient from infrastructure.abri.config import AbriConfig from infrastructure.hubspot.deal_properties_client import HubspotDealPropertiesClient @@ -149,3 +149,28 @@ def test_run_writes_the_job_no_to_the_hubspot_deal_and_then_the_database( ), ) assert deal_database.recorded_job_nos == [(DEAL_ID, "AD0226519")] + + +# --- rejection passthrough: OpenHousing's actual reason, nothing recorded --- + + +def test_run_returns_the_openhousing_rejection_verbatim_and_records_nothing( + orchestrator: AbriLogJobOrchestrator, + mock_session: MagicMock, + sdk_client: MagicMock, + deal_database: FakeDealDatabase, +) -> None: + # Arrange + mock_session.post.return_value.content = _load_fixture( + "abri_relay_logjob_relayerror_response.xml" + ) + + # Act + result = orchestrator.run(BOOKING) + + # Assert + assert isinstance(result, AbriRequestRejected) + assert result.code == "RelayError" + assert result.message.startswith("No property was found with UPRN/place_ref") + assert sdk_client.mock_calls == [] + assert deal_database.recorded_job_nos == []