Abri log_job surfaces an OpenHousing rejection as a typed result with verbatim code and message 🟥

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-03 14:25:49 +00:00
parent 79ce9dc4b1
commit e473ea8a4f

View file

@ -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 ''"
),
)