def test_raises_retryable_exception_when_mesh_message_ack_raises_mesh_network_exception( ): mock_message = mock_mesh_message(acknowledge_error=mesh_client_error()) forwarder = build_forwarder(incoming_messages=[mock_message]) with pytest.raises(RetryableException): forwarder.forward_messages()
def test_records_mesh_error_when_counting_messages(): probe = MagicMock() network_error = mesh_client_error("Network error") forwarder = build_forwarder(count_error=network_error, probe=probe) with pytest.raises(RetryableException): forwarder.is_mailbox_empty() probe.assert_has_calls([ call.new_count_messages_event(), call.new_count_messages_event().record_mesh_client_network_error( network_error), call.new_count_messages_event().finish(), ])
def test_records_mesh_error_when_polling_messages(): probe = MagicMock() poll_inbox_event = MagicMock() probe.new_poll_inbox_event.return_value = poll_inbox_event client_error = mesh_client_error() forwarder = build_forwarder(probe=probe, read_error=client_error) with pytest.raises(RetryableException): forwarder.forward_messages() poll_inbox_event.assert_has_calls( [call.record_mesh_client_network_error(client_error), call.finish()], any_order=False, )
def test_records_error_when_mesh_message_ack_raises_mesh_network_exception(): probe = MagicMock() forward_message_event = MagicMock() probe.new_forward_message_event.return_value = forward_message_event network_error = mesh_client_error("Network error") mock_message = mock_mesh_message(acknowledge_error=network_error, ) forwarder = build_forwarder(incoming_messages=[mock_message], probe=probe) with pytest.raises(RetryableException): forwarder.forward_messages() forward_message_event.assert_has_calls( [ call.record_message_metadata(mock_message), call.record_mesh_client_network_error(network_error), call.finish(), ], any_order=False, )
def test_raises_retryable_exception_when_inbox_count_messages_raises_mesh_network_exception( ): forwarder = build_forwarder(count_error=mesh_client_error()) with pytest.raises(RetryableException): forwarder.is_mailbox_empty()
def test_raises_retryable_exception_when_inbox_read_messages_raises_mesh_network_exception( ): forwarder = build_forwarder(read_error=mesh_client_error()) with pytest.raises(RetryableException): forwarder.forward_messages()