本文整理汇总了Python中pubnub.pubnub_tornado.PubNubTornado.message_counts方法的典型用法代码示例。如果您正苦于以下问题:Python PubNubTornado.message_counts方法的具体用法?Python PubNubTornado.message_counts怎么用?Python PubNubTornado.message_counts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pubnub.pubnub_tornado.PubNubTornado
的用法示例。
在下文中一共展示了PubNubTornado.message_counts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestMessageCount
# 需要导入模块: from pubnub.pubnub_tornado import PubNubTornado [as 别名]
# 或者: from pubnub.pubnub_tornado.PubNubTornado import message_counts [as 别名]
class TestMessageCount(AsyncTestCase):
def setUp(self):
AsyncTestCase.setUp(self)
config = pnconf_mc_copy()
config.enable_subscribe = False
self.pn = PubNubTornado(config, custom_ioloop=self.io_loop)
@pn_vcr.use_cassette('tests/integrational/fixtures/tornado/message_count/single.yaml',
filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'l_cg', 'l_pub'])
@tornado.testing.gen_test
def test_single_channel(self):
chan = 'unique_tornado'
envelope = yield self.pn.publish().channel(chan).message('bla').future()
time = envelope.result.timetoken - 10
envelope = yield self.pn.message_counts().channel(chan).channel_timetokens([time]).future()
assert(isinstance(envelope, TornadoEnvelope))
assert not envelope.status.is_error()
assert envelope.result.channels[chan] == 1
assert isinstance(envelope.result, PNMessageCountResult)
assert isinstance(envelope.status, PNStatus)
self.pn.stop()
@pn_vcr.use_cassette('tests/integrational/fixtures/tornado/message_count/multi.yaml',
filter_query_parameters=['uuid', 'seqn', 'pnsdk', 'l_cg', 'l_pub'])
@tornado.testing.gen_test
def test_multiple_channels(self):
chan_1 = 'unique_asyncio_1'
chan_2 = 'unique_asyncio_2'
chans = ','.join([chan_1, chan_2])
envelope = yield self.pn.publish().channel(chan_1).message('something').future()
time = envelope.result.timetoken - 10
envelope = yield self.pn.message_counts().channel(chans).channel_timetokens([time, time]).future()
assert(isinstance(envelope, TornadoEnvelope))
assert not envelope.status.is_error()
assert envelope.result.channels[chan_1] == 1
assert envelope.result.channels[chan_2] == 0
assert isinstance(envelope.result, PNMessageCountResult)
assert isinstance(envelope.status, PNStatus)
self.pn.stop()