[Erp5-report] r26332 - /erp5/trunk/products/ERP5/tests/testERP5Web.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Apr 7 15:17:38 CEST 2009


Author: vincentd
Date: Tue Apr  7 15:17:35 2009
New Revision: 26332

URL: http://svn.erp5.org?rev=26332&view=rev
Log:
Complete expire web section test and add a test for the creation of web section

Modified:
    erp5/trunk/products/ERP5/tests/testERP5Web.py

Modified: erp5/trunk/products/ERP5/tests/testERP5Web.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5/tests/testERP5Web.py?rev=26332&r1=26331&r2=26332&view=diff
==============================================================================
--- erp5/trunk/products/ERP5/tests/testERP5Web.py [utf8] (original)
+++ erp5/trunk/products/ERP5/tests/testERP5Web.py [utf8] Tue Apr  7 15:17:35 2009
@@ -779,6 +779,7 @@
     self.portal.Localizer = DummyLocalizer()
     self.createUser('admin', ['Manager'])
     self.createUser('erp5user', ['Auditor', 'Author'])
+    self.createUser('web_user', ['Assignor'])
     get_transaction().commit()
     self.tic()
 
@@ -1043,22 +1044,65 @@
     if not quiet:
       message = '\ntest_04_ExpireUserAction'
       ZopeTestCase._print(message)
+
     self.changeUser('admin')
     web_site_module = self.portal.web_site_module
-    site = web_site_module.newContent(portal_type='Web Site',
-                                      id='site')
-
-    section_1 = site.newContent(portal_type='Web Section', 
-                              id='section')
-
-    get_transaction().commit()
-    self.tic()
-
-    section_1.expire()
-
-    self.changeUser('erp5user')
-        
-
+    site = web_site_module.newContent(portal_type='Web Site', id='site')
+
+    # create websections in a site and in anothers web sections
+    section_1 = site.newContent(portal_type='Web Section', id='section_1')
+    section_2 = site.newContent(portal_type='Web Section', id='section_2')
+    section_3 = site.newContent(portal_type='Web Section', id='section_3')
+    section_4 = site.newContent(portal_type='Web Section', id='section_4')
+    section_5 = section_3.newContent(portal_type='Web Section', id='section_5')
+    section_6 = section_4.newContent(portal_type='Web Section', id='section_6')
+    get_transaction().commit()
+    self.tic()
+
+    # test if a manager can expire them
+    try:
+      section_1.expire()
+      section_5.expire()
+    except Unauthorized:
+      self.fail("Admin should be able to expire a Web Section.")
+      
+    # test if a user (ASSIGNOR) can expire them
+    self.changeUser('web_user')
+    try:
+      section_2.expire()
+      section_6.expire()
+    except Unauthorized:
+      self.fail("An user should be able to expire a Web Section.")
+      
+  def test_05_createWebSection(self, quiet=quiet, run=run_all_test):
+    """ Test to create web sections with many users """
+    if not run: return
+    if not quiet:
+      message = '\ntest_05_createWebSection'
+      ZopeTestCase._print(message)
+      
+    self.changeUser('admin')
+    web_site_module = self.portal.web_site_module
+    site = web_site_module.newContent(portal_type='Web Site', id='site')
+
+    # test for admin
+    try:
+      section_1 = site.newContent(portal_type='Web Section', id='section_1')
+      section_2 = section_1.newContent(portal_type='Web Section', id='section_2')
+    except Unauthorized:
+      self.fail("Admin should be able to create a Web Section.")
+
+    # test as a web user (assignor)
+    self.changeUser('web_user')
+    try:
+      section_2 = site.newContent(portal_type='Web Section', id='section_2')
+      section_3 = section_2.newContent(portal_type='Web Section', id='section_3')
+      self.fail("A web user should not be able to create a Web Section.")
+    except Unauthorized:
+      pass
+
+      
+    
 def test_suite():
   suite = unittest.TestSuite()
   suite.addTest(unittest.makeSuite(TestERP5Web))




More information about the Erp5-report mailing list