本文整理汇总了Python中pyon.event.event.EventSubscriber._topic方法的典型用法代码示例。如果您正苦于以下问题:Python EventSubscriber._topic方法的具体用法?Python EventSubscriber._topic怎么用?Python EventSubscriber._topic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.event.event.EventSubscriber
的用法示例。
在下文中一共展示了EventSubscriber._topic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestEventSubscriber
# 需要导入模块: from pyon.event.event import EventSubscriber [as 别名]
# 或者: from pyon.event.event.EventSubscriber import _topic [as 别名]
class TestEventSubscriber(IonUnitTestCase):
def setUp(self):
self._node = Mock(spec=NodeB)
self._cb = lambda *args, **kwargs: False
self._sub = EventSubscriber(node=self._node, callback=self._cb)
def test_init(self):
self.assertEquals(self._sub._recv_name.exchange, "%s.pyon.events" % bootstrap.get_sys_name())
self.assertEquals(self._sub._recv_name.queue, None)
self.assertEquals(self._sub._binding, "*.#")
self.assertEquals(self._sub._callback, self._cb)
def test_init_with_xp(self):
sub = EventSubscriber(node=self._node, callback=self._cb, xp_name=sentinel.xp)
self.assertEquals(sub._recv_name.exchange, sentinel.xp)
self.assertEquals(sub._recv_name.queue, None)
def test_init_with_event_name(self):
sub = EventSubscriber(node=self._node, callback=self._cb, event_name=sentinel.event_name)
self.assertEquals(sub._binding, "%s.#" % str(sentinel.event_name))
def test_init_with_origin(self):
sub = EventSubscriber(node=self._node, callback=self._cb, event_name=sentinel.event_name, origin=sentinel.origin)
self.assertEquals(sub._binding, "%s.%s" % (str(sentinel.event_name), str(sentinel.origin)))
def test_init_with_queue_name(self):
sub = EventSubscriber(node=self._node, callback=self._cb, xp_name=sentinel.xp, queue_name=str(sentinel.queue))
self.assertEquals(sub._recv_name.exchange, sentinel.xp)
self.assertEquals(sub._recv_name.queue, "%s.%s" % (bootstrap.get_sys_name(), str(sentinel.queue)))
def test_init_with_queue_name_with_sysname(self):
queue_name = "%s-dacshund" % bootstrap.get_sys_name()
sub = EventSubscriber(node=self._node, callback=self._cb, xp_name=sentinel.xp, queue_name=queue_name)
self.assertEquals(sub._recv_name.exchange, sentinel.xp)
self.assertEquals(sub._recv_name.queue, queue_name)
def test__topic(self):
self.assertEquals(self._sub._topic(None), "*.#")
def test__topic_with_name(self):
self._sub._event_name = "pancakes"
self.assertEquals(self._sub._topic(None), "pancakes.#")
def test__topic_with_origin(self):
self.assertEquals(self._sub._topic(sentinel.origin), "*.%s" % str(sentinel.origin))
def test__topic_with_name_and_origin(self):
self._sub._event_name = "pancakes"
self.assertEquals(self._sub._topic(sentinel.origin), "pancakes.%s" % str(sentinel.origin))