diff --git a/tests/infrastructure/abri/test_abri_client.py b/tests/infrastructure/abri/test_abri_client.py index 55aa5deb5..6ab6c7698 100644 --- a/tests/infrastructure/abri/test_abri_client.py +++ b/tests/infrastructure/abri/test_abri_client.py @@ -320,3 +320,31 @@ def test_amend_job_raises_retriable_parse_error_when_the_amendment_is_unconfirme # Act / Assert with pytest.raises(AbriResponseParseError): client.amend_job(_spec_example_amend_request()) + + +# --- amend_job: transport failures --- + + +def test_amend_job_raises_transport_error_on_http_error_status( + client: AbriClient, mock_session: MagicMock +) -> None: + # Arrange + mock_session.post.return_value.content = b"Server Error" + mock_session.post.return_value.raise_for_status.side_effect = requests.HTTPError( + "500 Server Error" + ) + + # Act / Assert + with pytest.raises(AbriTransportError): + client.amend_job(_spec_example_amend_request()) + + +def test_amend_job_raises_transport_error_when_the_relay_is_unreachable( + client: AbriClient, mock_session: MagicMock +) -> None: + # Arrange + mock_session.post.side_effect = requests.ConnectionError("connection refused") + + # Act / Assert + with pytest.raises(AbriTransportError): + client.amend_job(_spec_example_amend_request())