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

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Feb 15 11:12:03 CET 2007


Author: jerome
Date: Thu Feb 15 11:12:01 2007
New Revision: 12715

URL: http://svn.erp5.org?rev=12715&view=rev
Log:
honor --erp5_sql_connection_string for --save / --load (adhoc)

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

Modified: erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py?rev=12715&r1=12714&r2=12715&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py (original)
+++ erp5/trunk/products/ERP5Type/tests/ERP5TypeTestCase.py Thu Feb 15 11:12:01 2007
@@ -25,6 +25,7 @@
 
 from Testing import ZopeTestCase
 from Testing.ZopeTestCase.PortalTestCase import PortalTestCase, user_name
+from Products.ERP5Type.tests.utils import getMySQLArguments
 from Products.CMFCore.utils import getToolByName
 from Products.ERP5Type.Utils import getLocalPropertySheetList, \
                                     removeLocalPropertySheet, \
@@ -137,20 +138,16 @@
 initializeProductDocumentRegistry()
 
 from AccessControl.SecurityManagement import newSecurityManager, noSecurityManager
-from AccessControl.User import User
 
 from Acquisition import aq_base
 import time
 import md5
 import traceback
-import sys
 import os
 from cStringIO import StringIO
 from urllib import urlretrieve
 from glob import glob
 import pysvn
-
-from Products.ERP5.ERP5Site import ERP5Site
 
 portal_name = 'erp5_portal'
 
@@ -188,7 +185,8 @@
 
     def getRevision(self):
       try:
-        return pysvn.Client().info('%s/Products/ERP5' % os.environ['INSTANCE_HOME']).revision.number
+        return pysvn.Client().info('%s/Products/ERP5'
+                    % os.environ['INSTANCE_HOME']).revision.number
       except:
         return None
 
@@ -602,7 +600,8 @@
             if not quiet:
               ZopeTestCase._print('Dumping MySQL database ... ')
             instance_home = os.environ['INSTANCE_HOME']
-            os.system('mysqldump -u test test > %s/dump.sql' % instance_home)
+            os.system('mysqldump %s > %s/dump.sql' % (
+                      getMySQLArguments(), instance_home))
             if not quiet:
               ZopeTestCase._print('Dumping static files ... ')
             for dir in ('Constraint', 'Document', 'PropertySheet'):

Modified: erp5/trunk/products/ERP5Type/tests/custom_zodb.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/custom_zodb.py?rev=12715&r1=12714&r2=12715&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/custom_zodb.py (original)
+++ erp5/trunk/products/ERP5Type/tests/custom_zodb.py Thu Feb 15 11:12:01 2007
@@ -2,6 +2,7 @@
 import os
 from ZODB.DemoStorage import DemoStorage
 from ZODB.FileStorage import FileStorage
+from Products.ERP5Type.tests.utils import getMySQLArguments
 
 instance_home = os.environ.get('INSTANCE_HOME')
 data_fs_path = os.environ.get('erp5_tests_data_fs_path')
@@ -17,7 +18,7 @@
   else:
     Storage = DemoStorage(base=FileStorage(new_data_fs_path), quota=(1<<20))
   print("Restoring MySQL database ... ")
-  os.system("mysql -u test test < %s/dump.sql" % instance_home)
+  os.system("mysql %s < %s/dump.sql" % (getMySQLArguments(), instance_home))
   print("Restoring static files ... ")
   for dir in ('Constraint', 'Document', 'PropertySheet'):
     if os.path.exists('%s/%s.bak' % (instance_home, dir)):

Modified: erp5/trunk/products/ERP5Type/tests/utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/utils.py?rev=12715&r1=12714&r2=12715&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/utils.py (original)
+++ erp5/trunk/products/ERP5Type/tests/utils.py Thu Feb 15 11:12:01 2007
@@ -28,6 +28,8 @@
 
 """Utility functions and classes for unit testing
 """
+
+import os
 
 import Products.ERP5Type
 from Products.MailHost.MailHost import MailHost
@@ -108,6 +110,18 @@
   portal.manage_delObjects(['portal_memcached'])
   portal._setObject('portal_memcached', MemcachedTool.MemcachedTool())
 
+# test runner shared functions
+def getMySQLArguments():
+  """Returns arguments to pass to mysql by heuristically converting the
+  connection string.
+  Only simple cases are coverred for now.
+  """
+  connection_string = os.environ.get('erp5_sql_connection_string')
+  if not connection_string:
+    return '-u test test'
+  db, user = connection_string.split()
+  return '-u %s %s' % (user, db)
+
 # decorators
 class reindex(object):
   """Decorator to commit transaction and flush activities after the method is




More information about the Erp5-report mailing list