diff --git a/product/ERP5Type/tests/ERP5TypeTestCase.py b/product/ERP5Type/tests/ERP5TypeTestCase.py index 5b1f7d1f2e2f1fe2ae708c5b610cc73835ccc1fe..b98b54390bcdb5b2e6bd94a937bebb8cb89beed6 100644 --- a/product/ERP5Type/tests/ERP5TypeTestCase.py +++ b/product/ERP5Type/tests/ERP5TypeTestCase.py @@ -483,6 +483,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. @@ -745,57 +797,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(',') - 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() diff --git a/product/ERP5Type/tests/runUnitTest.py b/product/ERP5Type/tests/runUnitTest.py index 7dab8c2606d64c1a8c68be2eb65a945f48e3b81a..eea06bc7b7237422ee69612936af453563677a5c 100755 --- a/product/ERP5Type/tests/runUnitTest.py +++ b/product/ERP5Type/tests/runUnitTest.py @@ -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'],