diff --git a/product/ERP5Type/tests/ERP5TypeTestCase.py b/product/ERP5Type/tests/ERP5TypeTestCase.py index 7398ce73149104b5f078ac1a74b8af55c053064c..32b929e457adc5a409c5debc72187c7cc46184fd 100644 --- a/product/ERP5Type/tests/ERP5TypeTestCase.py +++ b/product/ERP5Type/tests/ERP5TypeTestCase.py @@ -401,36 +401,64 @@ def setupERP5Site( business_template_list=(), # Add ERP5 Site reindex = 1 if hot_reindexing: - setattr(app,'isIndexable',0) + setattr(app, 'isIndexable', 0) reindex = 0 if not quiet: ZopeTestCase._print('Adding %s ERP5 Site ... ' % portal_name) - factory = app.manage_addProduct['ERP5'] # Not needed by ERP5Type - factory.manage_addERP5Site(portal_name,light_install=light_install, - reindex=reindex,create_activities=create_activities) + + sql_connections_dict = {} + erp5_sql_connection_string = os.environ.get( + 'erp5_sql_connection_string') + if erp5_sql_connection_string: + sql_connections_dict['erp5_sql_connection_string'] = \ + erp5_sql_connection_string + cmf_activity_sql_connection_string = os.environ.get( + 'cmf_activity_sql_connection_string', + os.environ.get('erp5_sql_connection_string')) + if cmf_activity_sql_connection_string: + sql_connections_dict['cmf_activity_sql_connection_string'] = \ + cmf_activity_sql_connection_string + erp5_sql_deferred_connection_string = os.environ.get( + 'erp5_sql_deferred_connection_string', + os.environ.get('erp5_sql_connection_string')) + if erp5_sql_deferred_connection_string: + sql_connections_dict['erp5_sql_deferred_connection_string'] = \ + erp5_sql_deferred_connection_string + factory = app.manage_addProduct['ERP5'] + factory.manage_addERP5Site(portal_name, + light_install=light_install, + reindex=reindex, + create_activities=create_activities, + **sql_connections_dict ) + if not quiet: ZopeTestCase._print('done (%.3fs)\n' % (time.time() - _start)) # Release locks get_transaction().commit() - portal=app[portal_name] + portal = app[portal_name] + # Remove all local PropertySheets, Documents - for id in getLocalPropertySheetList(): - removeLocalPropertySheet(id) - for id in getLocalDocumentList(): - removeLocalDocument(id) - for id in getLocalConstraintList(): - removeLocalConstraint(id) + for id_ in getLocalPropertySheetList(): + removeLocalPropertySheet(id_) + for id_ in getLocalDocumentList(): + removeLocalDocument(id_) + for id_ in getLocalConstraintList(): + removeLocalConstraint(id_) + # Disable reindexing before adding templates # VERY IMPORTANT: Add some business templates - for url, id in business_template_list: + for url, id_ in business_template_list: start = time.time() - ZopeTestCase._print('Adding %s business template ... ' % id) - portal.portal_templates.download(url, id=id) - portal.portal_templates[id].install(light_install=light_install) + 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) # Release locks get_transaction().commit() - ZopeTestCase._print('done (%.3fs)\n' % (time.time() - start)) - # Enbable reindexing + if not quiet: + ZopeTestCase._print('done (%.3fs)\n' % (time.time() - start)) + + # Enable reindexing # Do hot reindexing # Does not work if hot_reindexing: setattr(app,'isIndexable', 1) @@ -451,28 +479,27 @@ def setupERP5Site( business_template_list=(), [('/'.join(m.object_path), m.method_id, m.processing_node, m.priority) for m in portal_activities.getMessageList()],) + # Reset aq dynamic, so all unit tests will start again from Products.ERP5Type.Base import _aq_reset _aq_reset() + # Log out if not quiet: ZopeTestCase._print('Logout ... \n') noSecurityManager() if not quiet: ZopeTestCase._print('done (%.3fs)\n' % (time.time()-_start,)) - if not quiet: ZopeTestCase._print('Ran Unit test of %s\n' % title) finally: get_transaction().commit() ZopeTestCase.close(app) - pass except: f = StringIO() traceback.print_exc(file=f) ZopeTestCase._print(f.getvalue()) f.close() - def optimize(): '''Significantly reduces portal creation time.''' def __init__(self, text): diff --git a/product/ERP5Type/tests/runUnitTest.py b/product/ERP5Type/tests/runUnitTest.py index 79aed3a96a7972367c01c72ea35d67508f458bbe..30f2118101a66c3e054b57b4d656064e1fa60ef7 100755 --- a/product/ERP5Type/tests/runUnitTest.py +++ b/product/ERP5Type/tests/runUnitTest.py @@ -1,7 +1,4 @@ #!/usr/bin/python -# -# Runs the tests passed on the command line -# import os import sys import getopt @@ -11,14 +8,23 @@ __doc__ = """%(program)s: unit test runner for the ERP5 Project usage: %(program)s [options] [UnitTest1[:TestClass1[:TestClass2]] [UnitTest2]] Options: --v/--verbose -- produce verbose output - + -v, --verbose produce verbose output + -h, --help this help screen + --erp5_sql_connection_string=STRING + ZSQL Connection string for erp5_sql_connection, by + default, it will use "test test" + --cmf_activity_sql_connection_string=STRING + ZSQL Connection string for + cmf_activity_sql_connection (if unset, defaults to + erp5_sql_connection_string) + --erp5_sql_deferred_connection_string=STRING + ZSQL Connection string for + erp5_sql_deferred_connection (if unset, defaults + to erp5_sql_connection_string) + """ -def getUnitTestFile() : - return os.path.abspath(__file__) - def initializeInstanceHome(tests_framework_home, real_instance_home, instance_home): @@ -159,7 +165,8 @@ def usage(stream, msg=None): def main(): try: opts, args = getopt.getopt(sys.argv[1:], - "hv", ["help", "verbose", ] ) + "hv", ["help", "verbose", "erp5_sql_connection_string=", + "cmf_activity_sql_connection_string=", "erp5_deferred_sql_connection_string="] ) except getopt.GetoptError, msg: usage(sys.stderr, msg) sys.exit(2) @@ -167,9 +174,16 @@ def main(): for opt, arg in opts: if opt in ("-v", "--verbose"): os.environ['VERBOSE'] = "1" - if opt in ("-h", "--help"): + elif opt in ("-h", "--help"): usage(sys.stdout) sys.exit() + elif opt == "--erp5_sql_connection_string": + os.environ["erp5_sql_connection_string"] = arg + print "set to ", arg + elif opt == "--cmf_activity_sql_connection_string": + os.environ["cmf_activity_sql_connection_string"] = arg + elif opt == "--erp5_sql_deferred_connection_string": + os.environ["erp5_sql_deferred_connection_string"] = arg test_list = args if not test_list: