[Erp5-report] r30863 - in /erp5/trunk/products: ERP5Catalog/tests/ ERP5Type/tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Nov 25 18:08:00 CET 2009


Author: jm
Date: Wed Nov 25 18:07:59 2009
New Revision: 30863

URL: http://svn.erp5.org?rev=30863&view=rev
Log:
Unit test: provide a way to specify extra connection strings

This allows to not hardcode connection strings in testArchive and
testERP5Catalog, which need several databases.

A new environment variable (extra_sql_connection_string_list) is recognized:
it is a colon-separated string of connection strings.

Modified:
    erp5/trunk/products/ERP5Catalog/tests/testArchive.py
    erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py
    erp5/trunk/products/ERP5Type/tests/utils.py

Modified: erp5/trunk/products/ERP5Catalog/tests/testArchive.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Catalog/tests/testArchive.py?rev=30863&r1=30862&r2=30863&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Catalog/tests/testArchive.py [utf8] (original)
+++ erp5/trunk/products/ERP5Catalog/tests/testArchive.py [utf8] Wed Nov 25 18:07:59 2009
@@ -37,7 +37,8 @@
 from DateTime import DateTime
 from Products.CMFCore.tests.base.testcase import LogInterceptor
 from Testing.ZopeTestCase.PortalTestCase import PortalTestCase
-from Products.ERP5Type.tests.utils import createZODBPythonScript
+from Products.ERP5Type.tests.utils import createZODBPythonScript, \
+                                          getExtraSqlConnectionStringList
 from Products.ZSQLCatalog.ZSQLCatalog import HOT_REINDEXING_FINISHED_STATE,\
       HOT_REINDEXING_RECORDING_STATE, HOT_REINDEXING_DOUBLE_INDEXING_STATE
 from Products.CMFActivity.Errors import ActivityFlushError
@@ -168,27 +169,28 @@
     
     # Create new connectors for destination
     self.new_connection_id = 'erp5_sql_connection1'
+    db1, db2 = getExtraSqlConnectionStringList()[:2]
     portal.manage_addZMySQLConnection(self.new_connection_id,'',
-                                      'test2 test2')
+                                      db1)
     new_connection = portal[self.new_connection_id]
     new_connection.manage_open_connection()
     # the deferred one
     self.new_deferred_connection_id = 'erp5_sql_connection2'
     portal.manage_addZMySQLConnection(self.new_deferred_connection_id,'',
-                                      'test2 test2')
+                                      db1)
     new_deferred_connection = portal[self.new_deferred_connection_id]
     new_deferred_connection.manage_open_connection()
 
     # Create new connectors for archive
     self.archive_connection_id = 'erp5_sql_connection3'
     portal.manage_addZMySQLConnection(self.archive_connection_id,'',
-                                      'test3 test3')
+                                      db2)
     archive_connection = portal[self.archive_connection_id]
     archive_connection.manage_open_connection()
     # the deferred one
     self.archive_deferred_connection_id = 'erp5_sql_connection4'
     portal.manage_addZMySQLConnection(self.archive_deferred_connection_id,'',
-                                      'test3 test3')
+                                      db2)
     archive_deferred_connection = portal[self.archive_deferred_connection_id]
     archive_deferred_connection.manage_open_connection()
 

Modified: erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py?rev=30863&r1=30862&r2=30863&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py [utf8] (original)
+++ erp5/trunk/products/ERP5Catalog/tests/testERP5Catalog.py [utf8] Wed Nov 25 18:07:59 2009
@@ -36,7 +36,8 @@
 from zLOG import LOG
 from DateTime import DateTime
 from Products.CMFCore.tests.base.testcase import LogInterceptor
-from Products.ERP5Type.tests.utils import createZODBPythonScript, todo_erp5
+from Products.ERP5Type.tests.utils import createZODBPythonScript, todo_erp5, \
+                                          getExtraSqlConnectionStringList
 from Products.ZSQLCatalog.ZSQLCatalog import HOT_REINDEXING_FINISHED_STATE,\
       HOT_REINDEXING_RECORDING_STATE, HOT_REINDEXING_DOUBLE_INDEXING_STATE
 from Products.CMFActivity.Errors import ActivityFlushError
@@ -1467,7 +1468,7 @@
     portal = self.getPortal()
     self.original_connection_id = 'erp5_sql_connection'
     self.new_connection_id = 'erp5_sql_connection2'
-    new_connection_string = 'test2 test2'
+    new_connection_string = getExtraSqlConnectionStringList()[0]
 
     # Skip this test if default connection string is not "test test".
     original_connection = getattr(portal, self.original_connection_id)

Modified: erp5/trunk/products/ERP5Type/tests/utils.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/tests/utils.py?rev=30863&r1=30862&r2=30863&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/tests/utils.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/tests/utils.py [utf8] Wed Nov 25 18:07:59 2009
@@ -237,6 +237,12 @@
 
   return '-u %s %s %s %s' % (user, password, host, db)
 
+def getExtraSqlConnectionStringList():
+  """Return list of extra available SQL connection string
+  """
+  return os.environ.get('extra_sql_connection_string_list',
+                        'test2 test2:test3 test3').split(':')
+
 # decorators
 class reindex(object):
   """Decorator to commit transaction and flush activities after the method is




More information about the Erp5-report mailing list