[Erp5-report] r19331 - /erp5/trunk/products/ERP5Type/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Feb 15 16:11:39 CET 2008


Author: vincent
Date: Fri Feb 15 16:11:39 2008
New Revision: 19331

URL: http://svn.erp5.org?rev=19331&view=rev
Log:
Add support for simultaneously providing --save and --load to runUnitTest.py.
Add --update_business_templates support. This, used in conjunction of --load will force all business templates to be updated with filesystem-available versions. Also invoking with --save will cause updated site to be saved for future use.
Do not use objectIds to get the list of installed business template, but getInstalledBusinessTemplateList.
This allows to not specify the business template id at installation.

Modified:
    erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
    erp5/trunk/products/ERP5Type/tests/custom_zodb.py
    erp5/trunk/products/ERP5Type/tests/runUnitTest.py

Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py?rev=19331&r1=19330&r2=19331&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py Fri Feb 15 16:11:39 2008
@@ -301,8 +301,16 @@
       INSTANCE_HOME = os.environ['INSTANCE_HOME']
       bt5_path = os.environ.get('erp5_tests_bt5_path',
                             os.path.join(INSTANCE_HOME, 'bt5'))
+      bootstrap_path = os.environ.get('erp5_tests_bootstrap_path',
+                                  os.path.join(INSTANCE_HOME, 'Products/ERP5/bootstrap'))
 
       template_list = self.getBusinessTemplateList()
+      erp5_catalog_storage = os.environ.get('erp5_catalog_storage',
+                                            'erp5_mysql_innodb_catalog')
+      update_business_templates = os.environ.get('update_business_templates') is not None
+      erp5_load_data_fs = os.environ.get('erp5_load_data_fs') is not None
+      if update_business_templates and erp5_load_data_fs:
+        template_list = ('erp5_core', 'erp5_xhtml_style', erp5_catalog_storage) + tuple(template_list)
       new_template_list = []
       for template in template_list:
         id = template.split('/')[-1]
@@ -311,8 +319,11 @@
         except IOError :
           # First, try the bt5 directory itself.
           path = os.path.join(bt5_path, template)
+          alternate_path = os.path.join(bootstrap_path, template)
           if os.path.exists(path):
             template = path
+          elif os.path.exists(alternate_path):
+            template = alternate_path
           else:
             path = '%s.bt5' % path
             if os.path.exists(path):
@@ -340,8 +351,6 @@
       light_install = self.enableLightInstall()
       create_activities = self.enableActivityTool()
       hot_reindexing = self.enableHotReindexing()
-      erp5_catalog_storage = os.environ.get('erp5_catalog_storage',
-                                            'erp5_mysql_innodb_catalog')
       setupERP5Site(business_template_list=new_template_list,
                     light_install=light_install,
                     portal_name=self.getPortalName(),
@@ -635,16 +644,23 @@
             for id_ in getLocalConstraintList():
               removeLocalConstraint(id_)
 
+          update_business_templates = os.environ.get('update_business_templates') is not None
+
           # Disable reindexing before adding templates
           # VERY IMPORTANT: Add some business templates
-          for url, id_ in business_template_list:
+          for url, title in business_template_list:
             start = time.time()
-            if id_ in portal.portal_templates.objectIds():
-              continue
-            if not quiet:
-              ZopeTestCase._print('Adding %s business template ... ' % id_)
-            portal.portal_templates.download(url, id=id_)
-            portal.portal_templates[id_].install(light_install=light_install)
+            if title in [x.getTitle() for x in portal.portal_templates.getInstalledBusinessTemplateList()]:
+              if update_business_templates:
+                if not quiet:
+                  ZopeTestCase._print('Updating %s business template ... ' % title)
+              else:
+                continue
+            else:
+              if not quiet:
+                ZopeTestCase._print('Adding %s business template ... ' % title)
+            bt = portal.portal_templates.download(url)
+            bt.install(light_install=light_install)
             # Release locks
             get_transaction().commit()
             if not quiet:

Modified: erp5/trunk/products/ERP5Type/tests/custom_zodb.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/custom_zodb.py?rev=19331&r1=19330&r2=19331&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/custom_zodb.py (original)
+++ erp5/trunk/products/ERP5Type/tests/custom_zodb.py Fri Feb 15 16:11:39 2008
@@ -8,11 +8,7 @@
 data_fs_path = os.environ.get('erp5_tests_data_fs_path')
 new_data_fs_path = os.path.join(instance_home, 'Data.fs')
 
-if os.environ.get('erp5_save_data_fs'):
-  if os.path.exists(new_data_fs_path):
-    os.remove(new_data_fs_path)
-  Storage = FileStorage(new_data_fs_path)
-elif os.environ.get('erp5_load_data_fs'):
+if os.environ.get('erp5_load_data_fs'):
   if os.environ.get('erp5_force_data_fs'):
     Storage = FileStorage(new_data_fs_path)
   else:
@@ -24,6 +20,10 @@
     if os.path.exists('%s/%s.bak' % (instance_home, dir)):
       os.system('rm -rf %s/%s' % (instance_home, dir))
       os.system('cp -ar %s/%s.bak %s/%s' % (instance_home, dir, instance_home, dir))
+elif os.environ.get('erp5_save_data_fs'):
+  if os.path.exists(new_data_fs_path):
+    os.remove(new_data_fs_path)
+  Storage = FileStorage(new_data_fs_path)
 elif data_fs_path:
   Storage = DemoStorage(base=FileStorage(data_fs_path), quota=(1<<20))
 else:

Modified: erp5/trunk/products/ERP5Type/tests/runUnitTest.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/runUnitTest.py?rev=19331&r1=19330&r2=19331&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/runUnitTest.py (original)
+++ erp5/trunk/products/ERP5Type/tests/runUnitTest.py Fri Feb 15 16:11:39 2008
@@ -60,6 +60,10 @@
                              expressions.
   -D                         
                              Invoke debugger on errors / failures.
+  --update_business_templates
+                             Update all business templates prior to runing
+                             tests. This only has a meaning when doing
+                             upgratability checks, in conjunction with --load.
 """
 
 def getUnitTestFile():
@@ -129,6 +133,8 @@
 else:
   software_home = '/usr/lib/zope/lib/python'
   zope_home = '/usr/lib/zope'
+zope_home = '/home/vincent/bin/zope2.8'
+software_home = '%s/lib/python' % (zope_home, )
 # handle 'system global' instance and windows
 if WIN:
   real_instance_home = os.path.join(erp5_home, 'ERP5Instance')
@@ -337,7 +343,8 @@
         "save",
         "load",
         "email_from_address=",
-        "run_only="] )
+        "run_only=",
+        "update_business_templates"] )
   except getopt.GetoptError, msg:
     usage(sys.stderr, msg)
     sys.exit(2)
@@ -348,6 +355,8 @@
   os.environ["erp5_tests_recreate_catalog"] = "0"
   verbosity = 1
   debug = 0
+  load = False
+  save = False
   
   for opt, arg in opts:
     if opt in ("-v", "--verbose"):
@@ -385,12 +394,19 @@
       os.environ["email_from_address"] = arg
     elif opt == "--save":
       os.environ["erp5_save_data_fs"] = "1"
+      save = True
     elif opt == "--load":
       os.environ["erp5_load_data_fs"] = "1"
+      load = True
     elif opt == "--erp5_catalog_storage":
       os.environ["erp5_catalog_storage"] = arg
     elif opt == "--run_only":
       os.environ["run_only"] = arg
+    elif opt == "--update_business_templates":
+      os.environ["update_business_templates"] = "1"
+
+  if load and save:
+    os.environ["erp5_force_data_fs"] = "1"
 
   test_list = args
   if not test_list:




More information about the Erp5-report mailing list