Commit fd9219af authored by Arnaud Fontaine's avatar Arnaud Fontaine

ZODB Components: Test bootstrap is already done before even running the test.

Therefore, all Test Components are now ERP5TypeLiveTestCase. For backward
compatibility sake, just modify Test Component class bases to
ERP5TypeLiveTestCase, likewise runLiveTest.

This means that tests ran through runUnitTest and from Live Tests ERP5 UI would
behave exactly the same, contrary to the implementation before Test Components.

Also, move a method called in one of ERP5TypeTypeMixin method from
ERP5TypeTestCaseCommandLine.
parent c35d24e8
......@@ -476,6 +476,58 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
DeprecationWarning)
return self.createUserAssignment(user, assignment_kw)
@staticmethod
def _getBTPathAndIdList(template_list):
bootstrap_path = os.environ.get('erp5_tests_bootstrap_path') or \
ERP5Site.getBootstrapDirectory()
bt5_path = os.environ.get('erp5_tests_bt5_path')
if bt5_path:
bt5_path_list = bt5_path.split(',')
bt5_path_list += [os.path.join(path, "*") for path in bt5_path_list]
else:
bt5_path = os.path.join(instancehome, 'bt5')
bt5_path_list = bt5_path, os.path.join(bt5_path, '*')
def search(path, template):
urltype, url = urllib.splittype(path + '/' + template)
if urltype == 'http':
host, selector = urllib.splithost(url)
user_passwd, host = urllib.splituser(host)
host = urllib.unquote(host)
h = httplib.HTTP(host)
h.putrequest('HEAD', selector)
h.putheader('Host', host)
if user_passwd:
h.putheader('Authorization',
'Basic %s' % base64.b64encode(user_passwd).strip())
h.endheaders()
errcode, errmsg, headers = h.getreply()
if errcode == 200:
return urltype + ':' + url
else:
path_list = glob(os.path.join(path, template))
if path_list:
return path_list[0]
not_found_list = []
new_template_list = []
for template in template_list:
id = template.split('/')[-1]
for path in bt5_path_list:
path = search(path, template) or search(path, template + '.bt5')
if path:
break
else:
path = os.path.join(bootstrap_path, template)
if not os.path.exists(path):
not_found_list.append(template)
continue
new_template_list.append((path, id))
if not_found_list:
raise RuntimeError("Following BT can't be found on your system : %s"
% ', '.join(not_found_list))
return new_template_list
def setupAutomaticBusinessTemplateRepository(self, accept_public=True,
searchable_business_template_list=None):
# Try to setup some valid Repository List by reusing ERP5TypeTestCase API.
......@@ -738,58 +790,6 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
"""
return 0
@staticmethod
def _getBTPathAndIdList(template_list):
bootstrap_path = os.environ.get('erp5_tests_bootstrap_path') or \
ERP5Site.getBootstrapDirectory()
bt5_path = os.environ.get('erp5_tests_bt5_path')
if bt5_path:
bt5_path_list = bt5_path.split(',')
bt5_path_list += [os.path.join(path, "*") for path in bt5_path_list]
else:
bt5_path = os.path.join(instancehome, 'bt5')
bt5_path_list = bt5_path, os.path.join(bt5_path, '*')
def search(path, template):
urltype, url = urllib.splittype(path + '/' + template)
if urltype == 'http':
host, selector = urllib.splithost(url)
user_passwd, host = urllib.splituser(host)
host = urllib.unquote(host)
h = httplib.HTTP(host)
h.putrequest('HEAD', selector)
h.putheader('Host', host)
if user_passwd:
h.putheader('Authorization',
'Basic %s' % base64.b64encode(user_passwd).strip())
h.endheaders()
errcode, errmsg, headers = h.getreply()
if errcode == 200:
return urltype + ':' + url
else:
path_list = glob(os.path.join(path, template))
if path_list:
return path_list[0]
not_found_list = []
new_template_list = []
for template in template_list:
id = template.split('/')[-1]
for path in bt5_path_list:
path = search(path, template) or search(path, template + '.bt5')
if path:
break
else:
path = os.path.join(bootstrap_path, template)
if not os.path.exists(path):
not_found_list.append(template)
continue
new_template_list.append((path, id))
if not_found_list:
raise RuntimeError("Following BT can't be found on your system : %s"
% ', '.join(not_found_list))
return new_template_list
def manuallyInstallBusinessTemplate(self, *template_list):
new_template_list = self._getBTPathAndIdList(template_list)
light_install = self.enableLightInstall()
......
......@@ -303,6 +303,11 @@ class ERP5TypeTestLoader(unittest.TestLoader):
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.ERP5TypeLiveTestCase import ERP5TypeLiveTestCase
# Bootstrap has been done in loadTestsFromNames, so the test can now
# be loaded like any Live Test on a real instance
if ERP5TypeLiveTestCase not in ERP5TypeTestCase.__bases__:
ERP5TypeTestCase.__bases__ = ERP5TypeLiveTestCase,
# TestLoader() does not perform any import so import the Module manually
module = __import__('erp5.component.test',
fromlist=['erp5.component.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