diff --git a/tests/infrastructure/abri/test_abri_client.py b/tests/infrastructure/abri/test_abri_client.py index 0e0f8abb8..aaaeb7d38 100644 --- a/tests/infrastructure/abri/test_abri_client.py +++ b/tests/infrastructure/abri/test_abri_client.py @@ -5,7 +5,12 @@ from unittest.mock import MagicMock, patch import pytest -from domain.abri.models import JobLogged, LogJobRequest, PlaceRef +from domain.abri.models import ( + AbriRequestRejected, + JobLogged, + LogJobRequest, + PlaceRef, +) from infrastructure.abri.abri_client import AbriClient from infrastructure.abri.config import AbriConfig @@ -99,3 +104,27 @@ def test_log_job_sends_the_recorded_logjob_envelope_to_the_relay_endpoint( assert ET.canonicalize(xml_data=sent_body, strip_text=True) == ET.canonicalize( xml_data=expected_body, strip_text=True ) + + +# --- log_job: rejection --- + + +def test_log_job_returns_rejection_with_openhousing_error_code_and_message_verbatim( + client: AbriClient, mock_session: MagicMock +) -> None: + # Arrange + mock_session.post.return_value.content = _load_fixture( + "abri_relay_logjob_relayerror_response.xml" + ) + + # Act + result = client.log_job(_spec_example_request()) + + # Assert + assert result == AbriRequestRejected( + code="RelayError", + message=( + "No property was found with UPRN/place_ref '1007176aa', " + "street name '', house number '0', house name '', post code ''" + ), + )