Abri log_job raises a retriable transport error on an HTTP error status 🟥

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Daniel Roth 2026-07-03 14:27:14 +00:00
parent e0830169ad
commit 9fefdf81aa
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,10 @@
class AbriTransportError(Exception):
"""A transport-level relay failure; the request may be retried."""
class AbriResponseParseError(AbriTransportError):
"""An unparseable or unexpectedly-shaped relay response.
Transport-class (retriable): the job may or may not have been logged,
so the outcome must never be treated as success or rejection.
"""

View file

@ -4,6 +4,7 @@ from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
import requests
from domain.abri.models import (
AbriRequestRejected,
@ -13,6 +14,7 @@ from domain.abri.models import (
)
from infrastructure.abri.abri_client import AbriClient
from infrastructure.abri.config import AbriConfig
from infrastructure.abri.errors import AbriTransportError
FIXTURE_DIR = Path(__file__).parents[2] / "abri"
ENDPOINT_URL = "https://relay.example.test/api/DomnaRelay?code=test-function-key"
@ -128,3 +130,20 @@ def test_log_job_returns_rejection_with_openhousing_error_code_and_message_verba
"street name '', house number '0', house name '', post code ''"
),
)
# --- log_job: transport failures ---
def test_log_job_raises_transport_error_on_http_error_status(
client: AbriClient, mock_session: MagicMock
) -> None:
# Arrange
mock_session.post.return_value.content = b"<html>Server Error</html>"
mock_session.post.return_value.raise_for_status.side_effect = requests.HTTPError(
"500 Server Error"
)
# Act / Assert
with pytest.raises(AbriTransportError):
client.log_job(_spec_example_request())