コード例 #1
0
def test_calls_acknowledge_on_underlying_client_message():
    client_message = mock_client_message()
    message = MeshMessage(client_message)

    message.acknowledge()

    client_message.acknowledge.assert_called_once()
コード例 #2
0
def test_mesh_network_error_raised_when_ack_raises_http_error():
    client_message = mock_client_message(
        acknowledge_error=mesh_client_http_error())

    message = MeshMessage(client_message)

    with pytest.raises(MeshClientNetworkError) as e:
        message.acknowledge()

    assert str(
        e.value) == f"400 HTTP Error: Bad request for url: {TEST_INBOX_URL}"
コード例 #3
0
def test_mesh_network_error_raised_when_ack_raises_connection_error():
    client_message = mock_client_message(
        acknowledge_error=mesh_client_connection_error("an error"))

    message = MeshMessage(client_message)

    with pytest.raises(MeshClientNetworkError) as e:
        message.acknowledge()

    assert str(e.value) == (
        f"ConnectionError received when attempting to connect to: {TEST_INBOX_URL}"
        " caused by: an error")