Esempio n. 1
0
 def test_createGroups(self):        
     conn = self.rootconn
     uuid = conn._sessionUuid
     
     # private group
     params = {
         "name":"webadmin_test_group_private %s" % uuid,
         "description":"test group",
         "permissions":0
     }
     request = fakeRequest(method="post", params=params)
     gid = _createGroup(request, conn)
        
     # check if group created
     group = conn.getObject("ExperimenterGroup", gid)
     permissions = getActualPermissions(group)
     self.assertEquals(params['name'], group.name)
     self.assertEquals(params['description'], group.description)
     self.assertEquals(params['permissions'], permissions)
     
     # collaborative read-only group
     params = {
         "name":"webadmin_test_group_read-only %s" % uuid,
         "description":"test group",
         "permissions":1
     }
     request = fakeRequest(method="post", params=params)
     gid = _createGroup(request, conn)
        
     # check if group created
     group = conn.getObject("ExperimenterGroup", gid)
     permissions = getActualPermissions(group)
     self.assertEquals(params['name'], group.name)
     self.assertEquals(params['description'], group.description)
     self.assertEquals(params['permissions'], permissions)
     
     # collaborative read-annotate group
     params = {
         "name":"webadmin_test_group_read-ann %s" % uuid,
         "description":"test group",
         "permissions":2
     }
     request = fakeRequest(method="post", params=params)
     gid = _createGroup(request, conn)
        
     # check if group created
     group = conn.getObject("ExperimenterGroup", gid)
     permissions = getActualPermissions(group)
     self.assertEquals(params['name'], group.name)
     self.assertEquals(params['description'], group.description)
     self.assertEquals(params['permissions'], permissions)
Esempio n. 2
0
 def test_createGroupsWithNonASCII(self):        
     conn = self.rootconn
     uuid = conn._sessionUuid
     
     # private group
     params = {
         "name":u"русский_алфавит %s" % uuid,
         "description":u"Frühstück-Śniadanie. Tschüß-Cześć",
         "owners": [0L],
         "members": [0L],
         "permissions":0
     }
     request = fakeRequest(method="post", params=params)
     gid = _createGroup(request, conn)
     
     # check if group created
     group = conn.getObject("ExperimenterGroup", gid)
     ownerIds = [e.id for e in group.getOwners()]
     membersIds = [e.id for e in group.getMembers()]
     permissions = getActualPermissions(group)
     self.assertEquals(params['name'], group.name)
     self.assertEquals(params['description'], group.description)
     self.assertEquals(sorted(params['owners']), sorted(ownerIds))
     self.assertEquals(sorted(params['members']), sorted(membersIds))
     self.assertEquals(params['permissions'], permissions)
Esempio n. 3
0
 def test_updateGroups(self):
     conn = self.rootconn
     uuid = conn._sessionUuid
     
     # default group - helper
     params = {
         "name":"webadmin_test_default %s" % uuid,
         "description":"test group default",
         "owners": [0L],
         "permissions":0
     }
     request = fakeRequest(method="post", params=params)
     default_gid = _createGroup(request, conn)
     
     # create new user
     params = {
         "omename":"webadmin_test_owner %s" % uuid,
         "first_name":uuid,
         "middle_name": uuid,
         "last_name":uuid,
         "email":"*****@*****.**" % uuid,
         "institution":"Laboratory",
         "active":True,
         "default_group":default_gid,
         "other_groups":[default_gid],
         "password":"******",
         "confirmation":"123" 
     }
     request = fakeRequest(method="post", params=params)
     eid = _createExperimenter(request, conn)
     
     # create new user2
     params = {
         "omename":"webadmin_test_member %s" % uuid,
         "first_name":uuid,
         "middle_name": uuid,
         "last_name":uuid,
         "email":"*****@*****.**" % uuid,
         "institution":"Laboratory",
         "active":True,
         "default_group":default_gid,
         "other_groups":[default_gid],
         "password":"******",
         "confirmation":"123" 
     }
     request = fakeRequest(method="post", params=params)
     eid2 = _createExperimenter(request, conn)
     
     # create private group
     params = {
         "name":"webadmin_test_group_private %s" % uuid,
         "description":"test group",
         "permissions":0
     }
     request = fakeRequest(method="post", params=params)
     gid = _createGroup(request, conn)
     
     # check if group created
     group = conn.getObject("ExperimenterGroup", gid)
     permissions = getActualPermissions(group)
     self.assertEquals(params['name'], group.name)
     self.assertEquals(params['description'], group.description)
     self.assertEquals(params['permissions'], permissions)
     
     # upgrade group to collaborative
     # read-only group and add new owner and members
     params = {
         "name":"webadmin_test_group_read-only %s" % uuid,
         "description":"test group changed",
         "owners": [eid],
         "members": [eid2],
         "permissions":1
     }
     request = fakeRequest(method="post", params=params)
     _updateGroup(request, conn, gid)
     
     # check if group updated
     group = conn.getObject("ExperimenterGroup", gid)
     ownerIds = [e.id for e in group.getOwners()]
     memberIds = [e.id for e in group.getMembers()]
     permissions = getActualPermissions(group)
     self.assertEquals(params['name'], group.name)
     self.assertEquals(params['description'], group.description)
     self.assertEquals(params['owners'], sorted(ownerIds))
     self.assertEquals(sorted(mergeLists(params['owners'], params['members'])), sorted(memberIds))
     self.assertEquals(params['permissions'], permissions)
     
     # upgrade group to collaborative
     # read-ann group and change owners and members
     params = {
         "name":"webadmin_test_group_read-only %s" % uuid,
         "description":"test group changed",
         "owners": [eid2],
         "members": [0,eid],
         "permissions":1
     }
     request = fakeRequest(method="post", params=params)
     _updateGroup(request, conn, gid)
     
     # check if group updated
     group = conn.getObject("ExperimenterGroup", gid)
     ownerIds = [e.id for e in group.getOwners()]
     memberIds = [e.id for e in group.getMembers()]
     permissions = getActualPermissions(group)
     self.assertEquals(params['name'], group.name)
     self.assertEquals(params['description'], group.description)
     self.assertEquals(params['owners'], sorted(ownerIds))
     self.assertEquals(sorted(mergeLists(params['owners'], params['members'])), sorted(memberIds))
     self.assertEquals(params['permissions'], permissions)