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


Python PubNubTornado.list_channels_in_channel_group方法代碼示例

本文整理匯總了Python中pubnub.pubnub_tornado.PubNubTornado.list_channels_in_channel_group方法的典型用法代碼示例。如果您正苦於以下問題:Python PubNubTornado.list_channels_in_channel_group方法的具體用法?Python PubNubTornado.list_channels_in_channel_group怎麽用?Python PubNubTornado.list_channels_in_channel_group使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pubnub.pubnub_tornado.PubNubTornado的用法示例。


在下文中一共展示了PubNubTornado.list_channels_in_channel_group方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestChannelGroups

# 需要導入模塊: from pubnub.pubnub_tornado import PubNubTornado [as 別名]
# 或者: from pubnub.pubnub_tornado.PubNubTornado import list_channels_in_channel_group [as 別名]
class TestChannelGroups(AsyncTestCase):
    def setUp(self):
        super(TestChannelGroups, self).setUp()
        self.pubnub = PubNubTornado(pnconf, custom_ioloop=self.io_loop)

    @use_cassette_and_stub_time_sleep(
        'tests/integrational/fixtures/tornado/groups/add_remove_single_channel.yaml',
        filter_query_parameters=['uuid', 'pnsdk'])
    @tornado.testing.gen_test
    def test_add_remove_single_channel(self):
        ch = "channel-groups-tornado-ch"
        gr = "channel-groups-tornado-cg"

        # add
        env = yield self.pubnub.add_channel_to_channel_group() \
            .channels(ch).channel_group(gr).future()

        assert isinstance(env.result, PNChannelGroupsAddChannelResult)

        yield gen.sleep(1)

        # list
        env = yield self.pubnub.list_channels_in_channel_group().channel_group(gr).future()
        assert isinstance(env.result, PNChannelGroupsListResult)
        assert len(env.result.channels) == 1
        assert env.result.channels[0] == ch

        # remove
        env = yield self.pubnub.remove_channel_from_channel_group() \
            .channels(ch).channel_group(gr).future()

        assert isinstance(env.result, PNChannelGroupsRemoveChannelResult)

        yield gen.sleep(1)

        # list
        env = yield self.pubnub.list_channels_in_channel_group().channel_group(gr).future()
        assert isinstance(env.result, PNChannelGroupsListResult)
        assert len(env.result.channels) == 0

        self.pubnub.stop()
        self.stop()

    @use_cassette_and_stub_time_sleep(
        'tests/integrational/fixtures/tornado/groups/add_remove_multiple_channel.yaml',
        filter_query_parameters=['uuid', 'pnsdk'])
    @tornado.testing.gen_test
    def test_add_remove_multiple_channels(self):
        ch1 = "channel-groups-tornado-ch1"
        ch2 = "channel-groups-tornado-ch2"
        gr = "channel-groups-tornado-cg"

        # add
        env = yield self.pubnub.add_channel_to_channel_group() \
            .channels([ch1, ch2]).channel_group(gr).future()

        assert isinstance(env.result, PNChannelGroupsAddChannelResult)

        yield gen.sleep(1)

        # list
        env = yield self.pubnub.list_channels_in_channel_group().channel_group(gr).future()
        assert isinstance(env.result, PNChannelGroupsListResult)
        assert len(env.result.channels) == 2
        assert ch1 in env.result.channels
        assert ch2 in env.result.channels

        # remove
        env = yield self.pubnub.remove_channel_from_channel_group() \
            .channels([ch1, ch2]).channel_group(gr).future()

        assert isinstance(env.result, PNChannelGroupsRemoveChannelResult)

        yield gen.sleep(1)

        # list
        env = yield self.pubnub.list_channels_in_channel_group().channel_group(gr).future()
        assert isinstance(env.result, PNChannelGroupsListResult)
        assert len(env.result.channels) == 0

        self.pubnub.stop()
        self.stop()

    @use_cassette_and_stub_time_sleep(
        'tests/integrational/fixtures/tornado/groups/add_channel_remove_group.yaml',
        filter_query_parameters=['uuid', 'seqn', 'pnsdk'])
    @tornado.testing.gen_test
    def test_add_channel_remove_group(self):
        ch = "channel-groups-tornado-ch"
        gr = "channel-groups-tornado-cg"

        # add
        env = yield self.pubnub.add_channel_to_channel_group() \
            .channels(ch).channel_group(gr).future()

        assert isinstance(env.result, PNChannelGroupsAddChannelResult)

        yield gen.sleep(1)

        # list
#.........這裏部分代碼省略.........
開發者ID:,項目名稱:,代碼行數:103,代碼來源:


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