本文整理汇总了Python中pyon.net.transport.AMQPTransport.start_consume_impl方法的典型用法代码示例。如果您正苦于以下问题:Python AMQPTransport.start_consume_impl方法的具体用法?Python AMQPTransport.start_consume_impl怎么用?Python AMQPTransport.start_consume_impl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.net.transport.AMQPTransport
的用法示例。
在下文中一共展示了AMQPTransport.start_consume_impl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestAMQPTransportCommonMethods
# 需要导入模块: from pyon.net.transport import AMQPTransport [as 别名]
# 或者: from pyon.net.transport.AMQPTransport import start_consume_impl [as 别名]
#.........这里部分代码省略.........
self.tp._sync_call.assert_called_once_with(self.tp._client.queue_delete,
'callback',
queue=sentinel.queue)
def test_bind_impl(self):
self.tp.bind_impl(sentinel.exchange, sentinel.queue, sentinel.binding)
self.tp._sync_call.assert_called_once_with(self.tp._client.queue_bind,
'callback',
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)