Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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))
Ejemplo n.º 3
0
    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())
Ejemplo n.º 4
0
 def consumer(self, handler):
     return realtime.Consumer(mock.sentinel.connection, "annotation",
                              handler)