def test_empty_queue_flush_is_not_sent(mock_send, zuqa_client): transport = Transport(client=zuqa_client, metadata={"x": "y"}) try: transport.start_thread() transport.flush() assert mock_send.call_count == 0 finally: transport.close()
def test_sync_transport_fail_and_recover(mock_send, caplog): transport = Transport(client=None) transport.start_thread() 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()