Commit a771dca4 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 c164192e
...@@ -297,6 +297,33 @@ class ERP5TypeTestLoader(unittest.TestLoader): ...@@ -297,6 +297,33 @@ class ERP5TypeTestLoader(unittest.TestLoader):
if name.endswith('.py'): if name.endswith('.py'):
name = name[:-3] name = name[:-3]
name = name.replace(':', '.') 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) return super(ERP5TypeTestLoader, self).loadTestsFromName(name, module)
def loadTestsFromModule(self, module): def loadTestsFromModule(self, module):
...@@ -429,9 +456,16 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None): ...@@ -429,9 +456,16 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
project_bt5_test_list = [] project_bt5_test_list = []
for bt5_path in bt5_path_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')))
bt5_test_list.extend(glob(os.path.join(bt5_path,'*','TestTemplateItem',
'portal_components')))
# also suport instance_home/bt5/project_bt5/* # also suport instance_home/bt5/project_bt5/*
project_bt5_test_list.extend(glob(os.path.join(bt5_path, '*', '*', 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(bt5_test_list)
sys.path.extend(project_bt5_test_list) sys.path.extend(project_bt5_test_list)
......
...@@ -28,8 +28,10 @@ class _ERP5(ERP5TypeTestSuite): ...@@ -28,8 +28,10 @@ class _ERP5(ERP5TypeTestSuite):
def _getAllTestList(self): def _getAllTestList(self):
test_list = [] test_list = []
for test_path in glob.glob('%s/product/*/tests/test*.py' % sys.path[0]) + \ for test_path in (
glob.glob('%s/bt5/*/TestTemplateItem/test*.py' % sys.path[0]): 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 test_case = test_path.split(os.sep)[-1][:-3] # remove .py
product = test_path.split(os.sep)[-3] product = test_path.split(os.sep)[-3]
# don't test 3rd party products # don't test 3rd party products
...@@ -64,23 +66,26 @@ class ERP5(_ERP5): ...@@ -64,23 +66,26 @@ class ERP5(_ERP5):
test_list = [] test_list = []
for test_case in self._getAllTestList(): for test_case in self._getAllTestList():
# skip some tests # skip some tests
if test_case.startswith('testLive') or test_case.startswith('testVifib') \ if ('testLive' in test_case or
or test_case.find('Performance') > 0 \ 'testVifib' in test_case or
or test_case in ('testERP5LdapCatalog', # XXX (Ivan), until LDAP server is available this test will alway fail test_case.find('Performance') > 0 or
# tests reading selenium tables from erp5.com # XXX (Ivan), until LDAP server is available this test will alway fail
'testFunctionalStandaloneUserTutorial', test_case.endswith('testERP5LdapCatalog') or
'testFunctionalRunMyDocSample', # tests reading selenium tables from erp5.com
'testFunctionalConfigurator', test_case.endswith('testFunctionalStandaloneUserTutorial') or
'testFunctionalConfiguratorConsulting', test_case.endswith('testFunctionalRunMyDocSample') or
# not maintained test_case.endswith('testFunctionalConfigurator') or
'testERP5eGov', test_case.endswith('testFunctionalConfiguratorConsulting') or
'testAccounting_l10n_fr_m9'): # not maintained
test_case.endswith('testERP5eGov') or
test_case.endswith('testAccounting_l10n_fr_m9')):
continue continue
test_list.append(test_case) test_list.append(test_case)
return test_list return test_list
def run(self, test): def run(self, test):
if test in ('testConflictResolution', 'testInvalidationBug'): if (test.endswith('testConflictResolution') or
test.endswith('testInvalidationBug')):
status_dict = self.runUnitTest('--save', test) status_dict = self.runUnitTest('--save', test)
if not status_dict['status_code']: if not status_dict['status_code']:
status_dict = self.runUnitTest('--load', '--activity_node=2', test) 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