本文整理汇总了Python中pyon.net.transport.AMQPTransport.get_stats_impl方法的典型用法代码示例。如果您正苦于以下问题:Python AMQPTransport.get_stats_impl方法的具体用法?Python AMQPTransport.get_stats_impl怎么用?Python AMQPTransport.get_stats_impl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.net.transport.AMQPTransport
的用法示例。
在下文中一共展示了AMQPTransport.get_stats_impl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestAMQPTransportCommonMethods
# 需要导入模块: from pyon.net.transport import AMQPTransport [as 别名]
# 或者: from pyon.net.transport.AMQPTransport import get_stats_impl [as 别名]
#.........这里部分代码省略.........
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,
passive=True)
self.assertEquals(ret, (mo.method.message_count, mo.method.consumer_count))
def test_purge_impl(self):
self.tp.purge_impl(sentinel.queue)
self.tp._sync_call.assert_called_once_with(self.tp._client.queue_purge,
'callback',
queue=sentinel.queue)
def test_qos_impl(self):
self.tp.qos_impl()
self.tp._sync_call.assert_called_once_with(self.tp._client.basic_qos,
'callback',
prefetch_size=0,
prefetch_count=0,
global_=False)
@patch('pyon.net.transport.BasicProperties')
def test_publish_impl(self, bpmock):
self.tp.publish_impl(sentinel.exchange, sentinel.routing_key, sentinel.body, sentinel.properties)
self.tp._client.basic_publish.assert_called_once_with(exchange=sentinel.exchange,
routing_key=sentinel.routing_key,
body=sentinel.body,
properties=bpmock(headers=sentinel.properties,
delivery_mode=None),
immediate=False,
mandatory=False)
@patch('pyon.net.transport.BasicProperties')
def test_publish_impl_durable(self, bpmock):
self.tp.publish_impl(sentinel.exchange, sentinel.routing_key, sentinel.body, sentinel.properties, durable_msg=True)
self.tp._client.basic_publish.assert_called_once_with(exchange=sentinel.exchange,
routing_key=sentinel.routing_key,
body=sentinel.body,
properties=bpmock(headers=sentinel.properties,
delivery_mode=2),
immediate=False,
mandatory=False)