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


Python Client.inGroup方法代碼示例

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


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

示例1: Test_Client_groups

# 需要導入模塊: from b3.clients import Client [as 別名]
# 或者: from b3.clients.Client import inGroup [as 別名]
class Test_Client_groups(B3TestCase):

    def setUp(self):
        B3TestCase.setUp(self)
        self.client = Client(console=self.console)
        self.group_guest = self.console.storage.getGroup(Group(keyword="guest"))
        self.group_user = self.console.storage.getGroup(Group(keyword="user"))
        self.group_reg = self.console.storage.getGroup(Group(keyword="reg"))
        self.group_mod = self.console.storage.getGroup(Group(keyword="mod"))
        self.group_admin = self.console.storage.getGroup(Group(keyword="admin"))
        self.group_fulladmin = self.console.storage.getGroup(Group(keyword="fulladmin"))
        self.group_senioradmin = self.console.storage.getGroup(Group(keyword="senioradmin"))
        self.group_superadmin = self.console.storage.getGroup(Group(keyword="superadmin"))

    def assertGroups(self, groups):
        keywords = map(operator.attrgetter('keyword'), groups)
        self.assertListEqual(keywords, map(operator.attrgetter('keyword'), self.client.groups))
        self.assertListEqual(keywords, map(operator.attrgetter('keyword'), self.client.getGroups()))

    def test_addGroup(self):
        # GIVEN
        self.client.addGroup(self.group_mod)
        self.assertGroups([self.group_mod])
        # WHEN
        self.client.addGroup(self.group_superadmin)
        # THEN
        self.assertGroups([self.group_mod, self.group_superadmin])

    def test_rmGroup(self):
        # GIVEN
        self.client.addGroup(self.group_mod)
        self.assertGroups([self.group_mod])
        self.client.addGroup(self.group_superadmin)
        # WHEN
        self.client.remGroup(self.group_mod)
        # THEN
        self.assertGroups([self.group_superadmin])

    def test_guest_group_is_the_default_group_when_none(self):
        self.assertGroups([self.group_guest])

        self.client.remGroup(self.group_guest)
        self.assertGroups([self.group_guest])

        self.client.addGroup(self.group_admin)
        self.assertGroups([self.group_admin])

    def test_inGroup(self):
        self.assertFalse(self.client.inGroup(self.group_guest))
        self.assertFalse(self.client.inGroup(self.group_user))
        self.assertFalse(self.client.inGroup(self.group_reg))
        self.assertFalse(self.client.inGroup(self.group_mod))
        self.assertFalse(self.client.inGroup(self.group_admin))
        self.assertFalse(self.client.inGroup(self.group_fulladmin))
        self.assertFalse(self.client.inGroup(self.group_senioradmin))
        self.assertFalse(self.client.inGroup(self.group_superadmin))

        self.client.addGroup(self.group_user)
        self.assertTrue(self.client.inGroup(self.group_user))
        self.client.addGroup(self.group_reg)
        self.assertTrue(self.client.inGroup(self.group_reg))
        self.client.addGroup(self.group_mod)
        self.assertTrue(self.client.inGroup(self.group_mod))
        self.client.addGroup(self.group_admin)
        self.assertTrue(self.client.inGroup(self.group_admin))
        self.client.addGroup(self.group_fulladmin)
        self.assertTrue(self.client.inGroup(self.group_fulladmin))
        self.client.addGroup(self.group_senioradmin)
        self.assertTrue(self.client.inGroup(self.group_senioradmin))
        self.client.addGroup(self.group_superadmin)
        self.assertTrue(self.client.inGroup(self.group_superadmin))
開發者ID:HaoDrang,項目名稱:big-brother-bot,代碼行數:73,代碼來源:test_Client.py


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