コード例 #1
0
def test_empty_queue_flush_is_not_sent(mock_send):
    transport = Transport(metadata={"x": "y"}, max_flush_time=5)
    try:
        transport.flush()
        assert mock_send.call_count == 0
    finally:
        transport.close()
コード例 #2
0
def test_empty_queue_flush_is_not_sent(mock_send, elasticapm_client):
    transport = Transport(client=elasticapm_client)
    try:
        transport.start_thread()
        transport.flush()
        assert mock_send.call_count == 0
    finally:
        transport.close()
コード例 #3
0
def test_sync_transport_fail_and_recover(mock_send, caplog):
    transport = Transport()
    try:
        mock_send.side_effect = TransportException("meh")
        transport.queue("x", {})
        transport.flush()
        assert transport.state.did_fail()
        # first retry should be allowed immediately
        assert transport.state.should_try()

        # recover
        mock_send.side_effect = None
        transport.queue("x", {})
        transport.flush()
        assert not transport.state.did_fail()
    finally:
        transport.close()