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


Python EventSubscriber._topic方法代码示例

本文整理汇总了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))
开发者ID:tgiguere,项目名称:pyon,代码行数:51,代码来源:test_event.py


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