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


Python PubNubTornado.where_now方法代码示例

本文整理汇总了Python中pubnub.pubnub_tornado.PubNubTornado.where_now方法的典型用法代码示例。如果您正苦于以下问题:Python PubNubTornado.where_now方法的具体用法?Python PubNubTornado.where_now怎么用?Python PubNubTornado.where_now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pubnub.pubnub_tornado.PubNubTornado的用法示例。


在下文中一共展示了PubNubTornado.where_now方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestPubNubAsyncWhereNow

# 需要导入模块: from pubnub.pubnub_tornado import PubNubTornado [as 别名]
# 或者: from pubnub.pubnub_tornado.PubNubTornado import where_now [as 别名]
class TestPubNubAsyncWhereNow(AsyncTestCase):
    def setUp(self):
        super(TestPubNubAsyncWhereNow, self).setUp()
        self.pubnub = PubNubTornado(pnconf_sub_copy(), custom_ioloop=self.io_loop)

    @use_cassette_and_stub_time_sleep(
        'tests/integrational/fixtures/tornado/where_now/single_channel.yaml',
        filter_query_parameters=['uuid', 'pnsdk'])
    @tornado.testing.gen_test(timeout=15)
    def test_where_now_single_channel(self):
        ch = "where-now-tornado-ch"
        uuid = "where-now-tornado-uuid"
        self.pubnub.config.uuid = uuid

        yield connect_to_channel(self.pubnub, ch)
        yield gen.sleep(10)
        env = yield self.pubnub.where_now() \
            .uuid(uuid) \
            .future()

        channels = env.result.channels

        assert len(channels) == 1
        assert channels[0] == ch

        yield disconnect_from_channel(self.pubnub, ch)
        self.pubnub.stop()
        self.stop()

    @use_cassette_and_stub_time_sleep(
        'tests/integrational/fixtures/tornado/where_now/multiple_channels.yaml',
        filter_query_parameters=['uuid', 'pnsdk'])
    @tornado.testing.gen_test(timeout=15)
    def test_multiple_channels(self):
        ch1 = "where-now-tornado-ch1"
        ch2 = "where-now-tornado-ch2"
        uuid = "where-now-tornado-uuid"
        self.pubnub.config.uuid = uuid

        callback_messages = SubscribeListener()
        self.pubnub.add_listener(callback_messages)
        self.pubnub.subscribe().channels(ch1).execute()
        yield callback_messages.wait_for_connect()

        self.pubnub.subscribe().channels(ch2).execute()
        yield gen.sleep(5)

        env = yield self.pubnub.where_now() \
            .uuid(uuid) \
            .future()

        channels = env.result.channels

        assert len(channels) == 2
        assert ch1 in channels
        assert ch2 in channels

        yield disconnect_from_channel(self.pubnub, [ch1, ch2])
        self.pubnub.stop()
        self.stop()
开发者ID:,项目名称:,代码行数:62,代码来源:


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