Commit 31f65011 authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Allow to execute runUnitTest for bt5 Test Components.

Usage: runUnitTest test.VERSION.REFERENCE as exported on the filesystem. Also,
add bt5 Test Components to tests being run through erp5testnode.
parent 71a4e4b3
......@@ -297,6 +297,33 @@ class ERP5TypeTestLoader(unittest.TestLoader):
if name.endswith('.py'):
name = name[:-3]
name = name.replace(':', '.')
# TODO-arnau: Dirty hack to allow './runUnitTest test.erp5.testFoo'. This
# must be implemented properly by specifiying the bt5 *and* test name
if name.startswith('test.'):
for path in sys.path:
if not path.endswith('/portal_components'):
continue
component_module_name = name.split('.')[2]
component_filename = '.'.join(name.split('.', 3)[:3]) + '.py'
component_path = os.path.join(path, component_filename)
if not os.path.isfile(component_path):
continue
with open(component_path) as component_file:
import imp
module = imp.new_module(component_module_name)
setattr(module,
component_module_name,
imp.load_module(component_module_name,
component_file,
component_filename,
('.py', 'rb', imp.PY_SOURCE)))
name = '.'.join(name.split('.', 3)[2:])
break
return super(ERP5TypeTestLoader, self).loadTestsFromName(name, module)
def loadTestsFromModule(self, module):
......@@ -429,9 +456,16 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
project_bt5_test_list = []
for bt5_path in bt5_path_list:
bt5_test_list.extend(glob(os.path.join(bt5_path,'*','TestTemplateItem')))
bt5_test_list.extend(glob(os.path.join(bt5_path,'*','TestTemplateItem',
'portal_components')))
# also suport instance_home/bt5/project_bt5/*
project_bt5_test_list.extend(glob(os.path.join(bt5_path, '*', '*',
'TestTemplateItem')))
'TestTemplateItem')))
project_bt5_test_list.extend(glob(os.path.join(bt5_path, '*', '*',
'TestTemplateItem',
'portal_components')))
sys.path.extend(bt5_test_list)
sys.path.extend(project_bt5_test_list)
......
......@@ -28,8 +28,10 @@ class _ERP5(ERP5TypeTestSuite):
def _getAllTestList(self):
test_list = []
for test_path in glob.glob('%s/product/*/tests/test*.py' % sys.path[0]) + \
glob.glob('%s/bt5/*/TestTemplateItem/test*.py' % sys.path[0]):
for test_path in (
glob.glob('%s/product/*/tests/test*.py' % sys.path[0]) +
glob.glob('%s/bt5/*/TestTemplateItem/test*.py' % sys.path[0]) +
glob.glob('%s/bt5/*/TestTemplateItem/portal_components/test.*.test*.py' % sys.path[0])):
test_case = test_path.split(os.sep)[-1][:-3] # remove .py
product = test_path.split(os.sep)[-3]
# don't test 3rd party products
......@@ -64,23 +66,26 @@ class ERP5(_ERP5):
test_list = []
for test_case in self._getAllTestList():
# skip some tests
if test_case.startswith('testLive') or test_case.startswith('testVifib') \
or test_case.find('Performance') > 0 \
or test_case in ('testERP5LdapCatalog', # XXX (Ivan), until LDAP server is available this test will alway fail
# tests reading selenium tables from erp5.com
'testFunctionalStandaloneUserTutorial',
'testFunctionalRunMyDocSample',
'testFunctionalConfigurator',
'testFunctionalConfiguratorConsulting',
# not maintained
'testERP5eGov',
'testAccounting_l10n_fr_m9'):
if ('testLive' in test_case or
'testVifib' in test_case or
test_case.find('Performance') > 0 or
# XXX (Ivan), until LDAP server is available this test will alway fail
test_case.endswith('testERP5LdapCatalog') or
# tests reading selenium tables from erp5.com
test_case.endswith('testFunctionalStandaloneUserTutorial') or
test_case.endswith('testFunctionalRunMyDocSample') or
test_case.endswith('testFunctionalConfigurator') or
test_case.endswith('testFunctionalConfiguratorConsulting') or
# not maintained
test_case.endswith('testERP5eGov') or
test_case.endswith('testAccounting_l10n_fr_m9')):
continue
test_list.append(test_case)
return test_list
def run(self, test):
if test in ('testConflictResolution', 'testInvalidationBug'):
if (test.endswith('testConflictResolution') or
test.endswith('testInvalidationBug')):
status_dict = self.runUnitTest('--save', test)
if not status_dict['status_code']:
status_dict = self.runUnitTest('--load', '--activity_node=2', test)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment