當前位置: 首頁>>代碼示例>>Python>>正文


Python PubNubTornado.message_counts方法代碼示例

本文整理匯總了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()
開發者ID:pubnub,項目名稱:python,代碼行數:45,代碼來源:test_message_count.py


注:本文中的pubnub.pubnub_tornado.PubNubTornado.message_counts方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。