当前位置: 首页>>代码示例>>Python>>正文


Python AMQPTransport.stop_consume_impl方法代码示例

本文整理汇总了Python中pyon.net.transport.AMQPTransport.stop_consume_impl方法的典型用法代码示例。如果您正苦于以下问题:Python AMQPTransport.stop_consume_impl方法的具体用法?Python AMQPTransport.stop_consume_impl怎么用?Python AMQPTransport.stop_consume_impl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyon.net.transport.AMQPTransport的用法示例。


在下文中一共展示了AMQPTransport.stop_consume_impl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_stop_consume_raises_warning_with_auto_delete

# 需要导入模块: from pyon.net.transport import AMQPTransport [as 别名]
# 或者: from pyon.net.transport.AMQPTransport import stop_consume_impl [as 别名]
    def test_stop_consume_raises_warning_with_auto_delete(self):
        transport = AMQPTransport(Mock())
        transport.stop_consume_impl = Mock()
        self.ch.on_channel_open(transport)
        #transport.channel_number = sentinel.channel_number

        self.ch._consumer_tag = sentinel.consumer_tag
        self.ch._recv_name = NameTrio(sentinel.ex, sentinel.queue, sentinel.binding)
        self.ch._fsm.current_state = self.ch.S_ACTIVE
        self.ch._consuming = True

        #self.ch._ensure_transport = MagicMock()
        self.ch._queue_auto_delete = True

        self.ch.stop_consume()

        self.assertTrue(self.ch._transport.stop_consume_impl.called)
        self.assertIn(self.ch._consumer_tag, self.ch._transport.stop_consume_impl.call_args[0])
开发者ID:ooici,项目名称:pyon,代码行数:20,代码来源:test_channel.py

示例2: TestAMQPTransportCommonMethods

# 需要导入模块: from pyon.net.transport import AMQPTransport [as 别名]
# 或者: from pyon.net.transport.AMQPTransport import stop_consume_impl [as 别名]

#.........这里部分代码省略.........
                                                   queue=sentinel.queue,
                                                   exchange=sentinel.exchange,
                                                   routing_key=sentinel.binding)

    def test_unbind_impl(self):
        self.tp.unbind_impl(sentinel.exchange, sentinel.queue, sentinel.binding)

        self.tp._sync_call.assert_called_once_with(self.tp._client.queue_unbind,
                                                   'callback',
                                                   queue=sentinel.queue,
                                                   exchange=sentinel.exchange,
                                                   routing_key=sentinel.binding)

    def test_ack_impl(self):
        self.tp.ack_impl(sentinel.dtag)

        self.tp._client.basic_ack.assert_called_once_with(sentinel.dtag)

    def test_reject_impl(self):
        self.tp.reject_impl(sentinel.dtag)

        self.tp._client.basic_reject.assert_called_once_with(sentinel.dtag, requeue=False)

    def test_start_consume_impl(self):
        rettag = self.tp.start_consume_impl(sentinel.callback, sentinel.queue)

        self.tp._client.basic_consume.assert_called_once_with(sentinel.callback,
                                                              queue=sentinel.queue,
                                                              no_ack=False,
                                                              exclusive=False)

        self.assertEquals(rettag, self.tp._client.basic_consume.return_value)

    def test_stop_consume_impl(self):
        self.tp.stop_consume_impl(sentinel.ctag)

        self.tp._sync_call.assert_called_once_with(self.tp._client.basic_cancel,
                                                   'callback',
                                                   sentinel.ctag)

    @patch('pyon.net.transport.sleep', Mock())      # patch to make sleep() be a mock call and therefore superfast
    def test_stop_consume_remains_in_consumers(self):
        self.tp._client._consumers = [sentinel.ctag]
        self.assertRaises(TransportError, self.tp.stop_consume_impl, sentinel.ctag)

    @patch('pyon.net.transport.sleep')
    def test_stop_consume_eventually_removed(self, sleepmock):
        self.tp._client._consumers.__contains__.side_effect = [True, False, False] # is checked once more at exit of method

        self.tp.stop_consume_impl(sentinel.ctag)
        sleepmock.assert_called_once_with(1)

    def test_setup_listener(self):
        cb = Mock()
        self.tp.setup_listener(sentinel.binding, cb)

        cb.assert_called_once_with(self.tp, sentinel.binding)

    def test_get_stats_impl(self):
        mo = Mock()
        self.tp._sync_call.return_value = mo
        ret = self.tp.get_stats_impl(sentinel.queue)

        self.tp._sync_call.assert_called_once_with(self.tp._client.queue_declare,
                                                   'callback',
                                                   queue=sentinel.queue,
开发者ID:caseybryant,项目名称:pyon,代码行数:70,代码来源:test_transport.py


注:本文中的pyon.net.transport.AMQPTransport.stop_consume_impl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。