예제 #1
0
 def test_getGroup_by_keyword(self):
     g = self.storage.getGroup(Group(keyword='superadmin'))
     self.assertIsInstance(g, Group)
     self.assertEquals('superadmin', g.keyword)
     self.assertEquals(100, g.level)
     self.assertRaises(KeyError, self.storage.getGroup,
                       Group(keyword='foo'))
예제 #2
0
    def _update_client_group(self, client):
        """Update the group for the given client"""
        platoon_member = self._get_platoon_member(client)
        if platoon_member:
            # check join date
            join_date = datetime.datetime.fromtimestamp(platoon_member['joined']).date()
            min_member_days = self.platoons[platoon_member['platoon_id']]['settings']['min_member_days']
            if join_date >= datetime.date.today()-datetime.timedelta(days=min_member_days):
                self.info('%s does not reach the required member time.' % client.name)
                return

            # get b3 group keyword for the platoon member
            group = Group(keyword=self.platoons[platoon_member['platoon_id']]['settings']['member_group'])
            if platoon_member['is_admin']:
                group = Group(keyword=self.platoons[platoon_member['platoon_id']]['settings']['admin_group'])
            elif platoon_member['is_leader']:
                group = Group(keyword=self.platoons[platoon_member['platoon_id']]['settings']['leader_group'])
            #elif platoon_member['is_founder']:
            #    group = Group(keyword=self.platoons[platoon_member['platoon_id']]['settings']['founder_group'])

            # get group from storage
            group = self.console.storage.getGroup(group)

            # put client in group
            if not client.inGroup(group) and not client.maxLevel >= group.level:
                self.debug('Put %s in group %s' % (client.name, group.name))
                client.setGroup(group)
                client.save()
 def setUp(self):
     Admin_functional_test.setUp(self)
     self.init()
     self.group_user = self.console.storage.getGroup(Group(keyword='user'))
     self.group_reg = self.console.storage.getGroup(Group(keyword='reg'))
     self.joe.message = Mock(wraps=lambda x: sys.stdout.write("\t\t" + x + "\n"))
     self.joe.connects(0)
     self.mike.connects(1)
예제 #4
0
 def test_getGroup_bad_group(self):
     try:
         self.storage.getGroup(Group(level=-1))
         self.fail("expecting KeyError")
     except KeyError:
         pass
     except Exception:
         self.fail("expecting KeyError")
예제 #5
0
 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"))
예제 #6
0
 def test_getGroup_by_level(self):
     g = self.storage.getGroup(Group(level='20'))
     self.assertIsInstance(g, Group)
     self.assertEquals('mod', g.keyword)
     self.assertEquals(20, g.level)
     self.assertRaises(KeyError, self.storage.getGroup, Group(level='500'))