Ejemplo n.º 1
0
    def test_errors_with_error_handler_fn(
        self, err, expectation, context, baseplate, name, message
    ):
        def handler_fn(ctx, body, msg):
            raise err

        error_handler_fn = mock.Mock()

        handler = KombuMessageHandler(baseplate, name, handler_fn, error_handler_fn)
        with expectation:
            handler.handle(message)
        error_handler_fn.assert_called_once_with(context, message.decode(), message, err)
        message.ack.assert_not_called()
        message.requeue.assert_not_called()
Ejemplo n.º 2
0
 def test_handle(self, context, span, baseplate, name, message):
     handler_fn = mock.Mock()
     handler = KombuMessageHandler(baseplate, name, handler_fn)
     handler.handle(message)
     baseplate.make_context_object.assert_called_once()
     baseplate.make_server_span.assert_called_once_with(context, name)
     baseplate.make_server_span().__enter__.assert_called_once()
     span.set_tag.assert_has_calls(
         [
             mock.call("kind", "consumer"),
             mock.call("amqp.routing_key", "routing-key"),
             mock.call("amqp.consumer_tag", "consumer-tag"),
             mock.call("amqp.delivery_tag", "delivery-tag"),
             mock.call("amqp.exchange", "exchange"),
         ],
         any_order=True,
     )
     handler_fn.assert_called_once_with(context, message.decode(), message)
     message.ack.assert_called_once()