コード例 #1
0
 def test_synchronize_external_groups(self):
     """webgroup - synchronizing one user external groups"""
     from invenio.webgroup import synchronize_external_groups
     from invenio.webgroup_dblayer import get_external_groups
     synchronize_external_groups(self.uid, {
         'group1': 'descr1',
         'group2': 'descr2'
     }, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless('group1' in groups_names)
     self.failUnless('group2' in groups_names)
     synchronize_external_groups(self.uid, {
         'group1': 'descr1',
         'group2': 'descr2'
     }, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless('group1' in groups_names)
     self.failUnless('group2' in groups_names)
     self.failUnless(len(groups_names) == 2)
     synchronize_external_groups(self.uid, {
         'group1': 'descr1',
         'group3': 'descr2'
     }, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless('group1' in groups_names)
     self.failUnless('group3' in groups_names)
     self.failUnless(len(groups_names) == 2)
     synchronize_external_groups(self.uid, {}, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless(len(groups_names) == 0)
コード例 #2
0
 def test_synchronize_all_external_groups(self):
     """webgroup - synchronizing all external groups"""
     from invenio.webgroup import synchronize_all_external_groups
     from invenio.webgroup_dblayer import get_external_groups, \
         get_all_login_method_groups
     synchronize_all_external_groups(
         {'group1': ('descr1', [self.email, self.email2])},
         self.login_method)
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 1)
     synchronize_all_external_groups(
         {'group2': ('descr1', [self.email, self.email2])},
         self.login_method)
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 1)
     self.assertEqual(groups[0][1], 'group2')
     self.assertEqual(groups[0][2], 'descr1')
     synchronize_all_external_groups({'group2': ('descr2', [self.email])},
                                     self.login_method)
     groups = get_external_groups(self.uid)
     self.assertEqual(groups[0][2], 'descr2')
     groups = get_external_groups(self.uid)
     self.assertEqual(len(groups), 1)
     self.assertEqual(groups[0][1], 'group2')
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 0)
     synchronize_all_external_groups({}, self.login_method)
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 0)
     groups = get_all_login_method_groups(self.login_method)
     self.failIf(groups)
コード例 #3
0
 def test_synchronize_external_groups(self):
     """webgroup - synchronizing one user external groups"""
     synchronize_external_groups(self.uid, {'group1' : 'descr1', 'group2' : 'descr2'}, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless('group1' in groups_names)
     self.failUnless('group2' in groups_names)
     synchronize_external_groups(self.uid, {'group1' : 'descr1', 'group2' : 'descr2'}, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless('group1' in groups_names)
     self.failUnless('group2' in groups_names)
     self.failUnless(len(groups_names) == 2)
     synchronize_external_groups(self.uid, {'group1' : 'descr1', 'group3' : 'descr2'}, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless('group1' in groups_names)
     self.failUnless('group3' in groups_names)
     self.failUnless(len(groups_names) == 2)
     synchronize_external_groups(self.uid, {}, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless(len(groups_names) == 0)
コード例 #4
0
 def test_synchronize_external_groups(self):
     """webgroup - synchronizing one user external groups"""
     synchronize_external_groups(self.uid, {"group1": "descr1", "group2": "descr2"}, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless("group1" in groups_names)
     self.failUnless("group2" in groups_names)
     synchronize_external_groups(self.uid, {"group1": "descr1", "group2": "descr2"}, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless("group1" in groups_names)
     self.failUnless("group2" in groups_names)
     self.failUnless(len(groups_names) == 2)
     synchronize_external_groups(self.uid, {"group1": "descr1", "group3": "descr2"}, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless("group1" in groups_names)
     self.failUnless("group3" in groups_names)
     self.failUnless(len(groups_names) == 2)
     synchronize_external_groups(self.uid, {}, self.login_method)
     groups = get_external_groups(self.uid)
     groups_names = [name[1] for name in groups]
     self.failUnless(len(groups_names) == 0)
コード例 #5
0
ファイル: webgroup.py プロジェクト: Mbaroudi/invenio-master
def display_external_groups(uid, ln=CFG_SITE_LANG):
    """Display groups the user is admin of.
    @param uid: user id
    @param ln: language
    @return: body
    return html groups representation the user is admin of
    """
    body = ""
    record = db.get_external_groups(uid)
    if record:
        body = websession_templates.tmpl_display_external_groups(groups=record, ln=ln)
    else:
        body = None
    return body
コード例 #6
0
def display_external_groups(uid, ln=CFG_SITE_LANG):
    """Display groups the user is admin of.
    @param uid: user id
    @param ln: language
    @return: body
    return html groups representation the user is admin of
    """
    body = ""
    record = db.get_external_groups(uid)
    if record:
        body = websession_templates.tmpl_display_external_groups(groups=record,
                                                                 ln=ln)
    else:
        body = None
    return body
コード例 #7
0
 def test_synchronize_all_external_groups(self):
     """webgroup - synchronizing all external groups"""
     synchronize_all_external_groups({'group1' : ('descr1', [self.email, self.email2])}, self.login_method)
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 1)
     synchronize_all_external_groups({'group2' : ('descr1', [self.email, self.email2])}, self.login_method)
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 1)
     self.assertEqual(groups[0][1], 'group2')
     self.assertEqual(groups[0][2], 'descr1')
     synchronize_all_external_groups({'group2' : ('descr2', [self.email])}, self.login_method)
     groups = get_external_groups(self.uid)
     self.assertEqual(groups[0][2], 'descr2')
     groups = get_external_groups(self.uid)
     self.assertEqual(len(groups), 1)
     self.assertEqual(groups[0][1], 'group2')
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 0)
     synchronize_all_external_groups({}, self.login_method)
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 0)
     groups = get_all_login_method_groups(self.login_method)
     self.failIf(groups)
コード例 #8
0
 def test_synchronize_all_external_groups(self):
     """webgroup - synchronizing all external groups"""
     synchronize_all_external_groups({"group1": ("descr1", [self.email, self.email2])}, self.login_method)
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 1)
     synchronize_all_external_groups({"group2": ("descr1", [self.email, self.email2])}, self.login_method)
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 1)
     self.assertEqual(groups[0][1], "group2")
     self.assertEqual(groups[0][2], "descr1")
     synchronize_all_external_groups({"group2": ("descr2", [self.email])}, self.login_method)
     groups = get_external_groups(self.uid)
     self.assertEqual(groups[0][2], "descr2")
     groups = get_external_groups(self.uid)
     self.assertEqual(len(groups), 1)
     self.assertEqual(groups[0][1], "group2")
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 0)
     synchronize_all_external_groups({}, self.login_method)
     groups = get_external_groups(self.uid2)
     self.assertEqual(len(groups), 0)
     groups = get_all_login_method_groups(self.login_method)
     self.failIf(groups)