本文整理匯總了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()