web/test/unittest_views_basecontrollers.py
changeset 7702 73cadb5d0097
parent 7584 e1881933f366
child 7791 31bb51ea5485
equal deleted inserted replaced
7696:1541d9e6b242 7702:73cadb5d0097
   362                     '__type:%s'%eid2: 'EmailAddress',
   362                     '__type:%s'%eid2: 'EmailAddress',
   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.assertEqual(path, 'view')
   365         self.assertEqual(path, 'view')
   366         self.assertIn('_cwmsgid', params)
   366         self.assertIn('_cwmsgid', params)
       
   367 
       
   368     def test_simple_copy(self):
       
   369         req = self.request()
       
   370         blog = req.create_entity('Blog', title=u'my-blog')
       
   371         blogentry = req.create_entity('BlogEntry', title=u'entry1',
       
   372                                       content=u'content1', entry_of=blog)
       
   373         req = self.request()
       
   374         req.form = {'__maineid' : 'X', 'eid': 'X',
       
   375                     '__cloned_eid:X': blogentry.eid, '__type:X': 'BlogEntry',
       
   376                     '_cw_entity_fields:X': 'title-subject,content-subject',
       
   377                     'title-subject:X': u'entry1-copy',
       
   378                     'content-subject:X': u'content1',
       
   379                     }
       
   380         self.expect_redirect_publish(req, 'edit')
       
   381         blogentry2 = req.find_one_entity('BlogEntry', title=u'entry1-copy')
       
   382         self.assertEqual(blogentry2.entry_of[0].eid, blog.eid)
       
   383 
       
   384     def test_skip_copy_for(self):
       
   385         req = self.request()
       
   386         blog = req.create_entity('Blog', title=u'my-blog')
       
   387         blogentry = req.create_entity('BlogEntry', title=u'entry1',
       
   388                                       content=u'content1', entry_of=blog)
       
   389         blogentry.__class__.cw_skip_copy_for = [('entry_of', 'subject')]
       
   390         try:
       
   391             req = self.request()
       
   392             req.form = {'__maineid' : 'X', 'eid': 'X',
       
   393                         '__cloned_eid:X': blogentry.eid, '__type:X': 'BlogEntry',
       
   394                         '_cw_entity_fields:X': 'title-subject,content-subject',
       
   395                         'title-subject:X': u'entry1-copy',
       
   396                         'content-subject:X': u'content1',
       
   397                         }
       
   398             self.expect_redirect_publish(req, 'edit')
       
   399             blogentry2 = req.find_one_entity('BlogEntry', title=u'entry1-copy')
       
   400             # entry_of should not be copied
       
   401             self.assertEqual(len(blogentry2.entry_of), 0)
       
   402         finally:
       
   403             blogentry.__class__.cw_skip_copy_for = []
   367 
   404 
   368     def test_nonregr_eetype_etype_editing(self):
   405     def test_nonregr_eetype_etype_editing(self):
   369         """non-regression test checking that a manager user can edit a CWEType entity
   406         """non-regression test checking that a manager user can edit a CWEType entity
   370         """
   407         """
   371         groupeids = sorted(eid for eid, in self.execute('CWGroup G WHERE G name in ("managers", "users")'))
   408         groupeids = sorted(eid for eid, in self.execute('CWGroup G WHERE G name in ("managers", "users")'))