本文整理汇总了Python中pyon.net.endpoint.Publisher.close方法的典型用法代码示例。如果您正苦于以下问题:Python Publisher.close方法的具体用法?Python Publisher.close怎么用?Python Publisher.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.net.endpoint.Publisher
的用法示例。
在下文中一共展示了Publisher.close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_xp_durable_send
# 需要导入模块: from pyon.net.endpoint import Publisher [as 别名]
# 或者: from pyon.net.endpoint.Publisher import close [as 别名]
def test_xp_durable_send(self):
xp = self.container.ex_manager.create_xp('an_xp')
#self.addCleanup(xp.delete)
xq = self.container.ex_manager.create_xn_queue('no_matter', xp)
self.addCleanup(xq.delete)
xq.bind('one')
pub = Publisher(to_name=xp.create_route('one'))
pub.publish('test')
pub.close()
try:
url = self.container.ex_manager._get_management_url("queues", "%2f", xq.queue, "get")
res = self.container.ex_manager._make_management_call(url,
use_ems=False,
method='post',
data=json.dumps({'count':1, 'requeue':True,'encoding':'auto'}))
self.assertEquals(len(res), 1)
self.assertIn('properties', res[0])
self.assertIn('delivery_mode', res[0]['properties'])
self.assertEquals(2, res[0]['properties']['delivery_mode'])
except Exception, e:
# Rabbit 3.x does not support this command anymore apparently.
self.assertIn('Method Not Allowed', e.message)
示例2: TestPublisher
# 需要导入模块: from pyon.net.endpoint import Publisher [as 别名]
# 或者: from pyon.net.endpoint.Publisher import close [as 别名]
class TestPublisher(PyonTestCase):
def setUp(self):
self._node = Mock(spec=NodeB)
self._pub = Publisher(node=self._node, to_name="testpub")
self._ch = Mock(spec=SendChannel)
self._node.channel.return_value = self._ch
def test_publish(self):
self.assertEquals(self._node.channel.call_count, 0)
self._pub.publish("pub")
self._node.channel.assert_called_once_with(self._pub.channel_type)
self.assertEquals(self._ch.send.call_count, 1)
self._pub.publish("pub2")
self._node.channel.assert_called_once_with(self._pub.channel_type)
self.assertEquals(self._ch.send.call_count, 2)
def test_publish_with_new_name(self):
self.assertEquals(self._node.channel.call_count, 0)
self._pub.publish(sentinel.msg, to_name=sentinel.to_name)
self.assertEquals(self._ch.send.call_count, 1)
self._pub.publish(sentinel.msg, to_name=sentinel.to_name)
self.assertEquals(self._ch.send.call_count, 2)
def test_close(self):
self._pub.publish(sentinel.msg)
self._pub._pub_ep.close = Mock()
self._pub.close()
self._pub._pub_ep.close.assert_called_once_with()