def test_handle_message_doesnt_explode_if_timestamp_missing(self, handler): consumer = realtime.Consumer(mock.sentinel.connection, "annotation", handler) message = mock.Mock() message.headers = {} consumer.handle_message({}, message)
def test_handle_message_records_queue_time_if_timestamp_present(self, handler, matchers, 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', matchers.InstanceOf(int))
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())
def consumer(self, handler): return realtime.Consumer(mock.sentinel.connection, "annotation", handler)