def testGroupHolder(self): gh = GroupHolder() ah = AvatarHolder() self.assert_(gh.getById("fake-group-1").containsUser(ah.getById("fake-1"))) self.assertEqual(gh.match({"groupname": "fake-group-1"}, searchInAuthenticators=False)[0].getEmail(), "*****@*****.**") self.assertEqual(len(gh.matchFirstLetter("f", searchInAuthenticators=False)), 2)
def _checkParams(self): AdminService._checkParams(self) self._pm = ParameterManager(self._params) gh = GroupHolder() groupId = self._pm.extract("groupId", pType=str, allowEmpty=False) self._group = gh.getById(groupId) if self._group == None: raise ServiceError("ER-G0", _("Cannot find group with id %s") % groupId)
def testGroupHolder(self): gh = GroupHolder() ah = AvatarHolder() self.assert_( gh.getById("fake-group-1").containsUser(ah.getById("fake-1"))) self.assertEqual( gh.match({"groupname": "fake-group-1"}, searchInAuthenticators=False)[0].getEmail(), "*****@*****.**") self.assertEqual( len(gh.matchFirstLetter("f", searchInAuthenticators=False)), 2)
def retrieve_principal(principal): """ Retrieves principal object from a `(type, id)` tuple. Valid principal types are 'Avatar' and 'Group' """ from MaKaC.user import AvatarHolder, GroupHolder ah = AvatarHolder() gh = GroupHolder() type_, id_ = principal try: return ah.getById(id_) if type_ == 'Avatar' else gh.getById(id_) except KeyError: return None
def retrieve_principals(iterable): """Retrieves principal objects from `(type, id)` tuples. Valid principal types are 'Avatar' and 'Group' """ from MaKaC.user import AvatarHolder, GroupHolder ah = AvatarHolder() gh = GroupHolder() principals = [] for type_, id_ in iterable: if type_ == 'Avatar': principal = ah.getById(id_) else: principal = gh.getById(id_) if principal: principals.append(principal) return principals