Exemplo n.º 1
0
class DescribeBind(_BaseTestCase):
    __contexts__ = (('partial',
                     patch(mod + '.partial',
                           return_value=sentinel.callback)), )

    def configure(self):
        self.kwargs = {
            'queue': sentinel.queue,
            'exchange': sentinel.exchange,
            'routing_key': sentinel.routing_key,
            'method_frame': sentinel.method_frame
        }
        self.agent = ConsumerAgent(sentinel.consumer, sentinel.broker,
                                   sentinel.bindings)
        self.agent.declare_queue = MagicMock()

    def execute(self):
        self.agent.bind(**self.kwargs)

    def should_create_on_queue_declare_ok_callback(self):
        self.ctx.partial.assert_called_once_with(self.agent.bind_queue,
                                                 sentinel.queue,
                                                 sentinel.exchange,
                                                 sentinel.routing_key)

    def should_declare_queue(self):
        self.agent.declare_queue.assert_called_once_with(
            sentinel.callback, self.kwargs['queue'])
Exemplo n.º 2
0
class DescribeBind(_BaseTestCase):
    __contexts__ = (
        ('partial', patch(mod + '.partial', return_value=sentinel.callback)),
    )

    def configure(self):
        self.kwargs = {
            'queue': sentinel.queue,
            'exchange': sentinel.exchange,
            'routing_key': sentinel.routing_key,
            'method_frame': sentinel.method_frame
        }
        self.agent = ConsumerAgent(sentinel.consumer, sentinel.broker,
                                   sentinel.bindings)
        self.agent.declare_queue = MagicMock()

    def execute(self):
        self.agent.bind(**self.kwargs)

    def should_create_on_queue_declare_ok_callback(self):
        self.ctx.partial.assert_called_once_with(self.agent.bind_queue,
                                                 sentinel.queue,
                                                 sentinel.exchange,
                                                 sentinel.routing_key)

    def should_declare_queue(self):
        self.agent.declare_queue.assert_called_once_with(
            sentinel.callback, self.kwargs['queue'])