web/test/unittest_views_basecontrollers.py
changeset 4389 14a993bc8d1e
parent 4292 3fc808b0490b
child 4390 0285c1fa1459
equal deleted inserted replaced
4388:15c6607c4bda 4389:14a993bc8d1e
   363                     '__action_delete': ''}
   363                     '__action_delete': ''}
   364         path, params = self.expect_redirect_publish(req, 'edit')
   364         path, params = self.expect_redirect_publish(req, 'edit')
   365         self.assertEquals(path, 'view')
   365         self.assertEquals(path, 'view')
   366         self.assertEquals(params, {u'__message': u'entities deleted'})
   366         self.assertEquals(params, {u'__message': u'entities deleted'})
   367 
   367 
   368     def test_nonregr_egroup_etype_editing(self):
       
   369         """non-regression test checking that a manager user can edit a CWEType entity (CWGroup)
       
   370         """
       
   371         groupeids = [eid for eid, in self.execute('CWGroup G WHERE G name "managers"')]
       
   372         groups = [u(eid) for eid in groupeids]
       
   373         cwetypeeid = u(self.execute('CWEType X WHERE X name "CWGroup"')[0][0])
       
   374         basegroups = [u(eid) for eid, in self.execute('CWGroup G WHERE X read_permission G, X eid %(x)s', {'x': cwetypeeid})]
       
   375         req = self.request()
       
   376         req.form = {
       
   377             'eid':      cwetypeeid,
       
   378             '__type:'+cwetypeeid:   'CWEType',
       
   379             '_cw_edited_fields:'+cwetypeeid: 'name-subject,final-subject,description-subject,read_permission-subject',
       
   380             'name-subject:'+cwetypeeid:     u'CWGroup',
       
   381             #'final-subject:'+cwetypeeid:    False,
       
   382             'description-subject:'+cwetypeeid:     u'users group',
       
   383             'read_permission-subject:'+cwetypeeid:  groups,
       
   384             }
       
   385         try:
       
   386             path, params = self.expect_redirect_publish(req, 'edit')
       
   387             e = self.execute('Any X WHERE X eid %(x)s', {'x': cwetypeeid}, 'x').get_entity(0, 0)
       
   388             self.assertEquals(e.name, 'CWGroup')
       
   389             self.assertEquals([g.eid for g in e.read_permission], groupeids)
       
   390         finally:
       
   391             # restore
       
   392             self.execute('SET X read_permission Y WHERE X name "CWGroup", Y eid IN (%s), NOT X read_permission Y' % (','.join(basegroups)))
       
   393             self.commit()
       
   394 
       
   395     def test_nonregr_eetype_etype_editing(self):
   368     def test_nonregr_eetype_etype_editing(self):
   396         """non-regression test checking that a manager user can edit a CWEType entity (CWEType)
   369         """non-regression test checking that a manager user can edit a CWEType entity
   397         """
   370         """
   398         groupeids = sorted(eid for eid, in self.execute('CWGroup G WHERE G name in ("managers", "users")'))
   371         groupeids = sorted(eid for eid, in self.execute('CWGroup G WHERE G name in ("managers", "users")'))
   399         groups = [u(eid) for eid in groupeids]
   372         groups = [u(eid) for eid in groupeids]
   400         cwetypeeid = self.execute('CWEType X WHERE X name "CWEType"')[0][0]
   373         cwetypeeid = self.execute('CWEType X WHERE X name "CWEType"')[0][0]
   401         basegroups = [u(eid) for eid, in self.execute('CWGroup G WHERE X read_permission G, X eid %(x)s', {'x': cwetypeeid})]
   374         basegroups = [u(eid) for eid, in self.execute('CWGroup G WHERE X read_permission G, X eid %(x)s', {'x': cwetypeeid})]