def send_request(self, request): # Translate requests.request into a test app call method = getattr(self.app, request.method.lower()) return method( url=request.url, headers=request.headers, params=request.data, status=Any.int(), )
def test_it_adds_timeout_options_for_failfast(self, Connection): realtime.get_connection({}, fail_fast=True) Connection.assert_called_once_with( Any.string(), transport_options={ "max_retries": Any.int(), "interval_start": Any(), "interval_step": Any(), "interval_max": Any(), }, )
def test_handle_message_records_queue_time_if_timestamp_present( self, handler, statsd_client): consumer = realtime.Consumer(mock.sentinel.connection, "annotation", handler, statsd_client=statsd_client) message = mock.Mock() message.headers = {"timestamp": datetime.utcnow().isoformat() + "Z"} consumer.handle_message({}, message) statsd_client.timing.assert_called_once_with("streamer.msg.queueing", Any.int())