def test_connects_directly(self, sleep): connector = Mock() data_transport = DataTransport(connector) data_transport.send = Mock() data_transport.deliver_event(Event("test")) connector.connect.assert_called_once() assert sleep.call_count == 0
def test_connects_after_retries(self, sleep): data_transport = DataTransport( FailsAfterNTimes(2, with_exception=ConnectionError)) data_transport.send = Mock() data_transport.deliver_event(Event("test")) data_transport.send.assert_called_once_with("decoded test") assert sleep.call_count == DataTransport.retry_n_times - 1, sleep.call_count
def test_connects_after_retries(self, sleep): data_transport = DataTransport( FailsAfterNTimes(2, with_exception=ConnectionError) ) data_transport.send = Mock() data_transport.deliver_event(Event("test")) data_transport.send.assert_called_once_with("decoded test") assert ( sleep.call_count == DataTransport.retry_n_times - 1 ), sleep.call_count