Commit 33dbd558 authored by Rafael Monnerat's avatar Rafael Monnerat

Include Repository configuration on promise for test

  Permit user update promise file searching by bt5s name, and including its
 repository.

Conflicts:
	product/ERP5Type/tests/ERP5TypeTestCase.py
parent 23accc1d
......@@ -151,7 +151,9 @@ def _getPersistentMemcachedServerDict():
port = os.environ.get('persistent_memcached_server_port', '12121')
return dict(hostname=hostname, port=port)
def _createTestPromiseConfigurationFile(promise_path):
def _createTestPromiseConfigurationFile(promise_path, bt5_repository_path_list=None):
memcached_url = "memcached://%(hostname)s:%(port)s/" % \
_getVolatileMemcachedServerDict()
kumofs_url = "memcached://%(hostname)s:%(port)s/" % \
_getVolatileMemcachedServerDict()
memcached_url = "memcached://%(hostname)s:%(port)s/" % \
......@@ -165,6 +167,11 @@ def _createTestPromiseConfigurationFile(promise_path):
promise_config.set('external_service', 'memcached_url',memcached_url)
promise_config.set('external_service', 'kumofs_url', kumofs_url)
if bt5_repository_path_list is not None:
promise_config.add_section('portal_templates')
promise_config.set('portal_templates', 'repository',
' '.join(bt5_repository_path_list))
if os.environ.get('TEST_CA_PATH') is not None:
promise_config.add_section('portal_certificate_authority')
promise_config.set('portal_certificate_authority', 'certificate_authority_path',
......@@ -492,15 +499,51 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
% ', '.join(not_found_list))
return new_template_list
def setupAutomaticBusinessTemplateRepository(self,
def _getBusinessRepositoryPathList(self, searchable_business_template_list=None):
if searchable_business_template_list is None:
searchable_business_template_list = ["erp5_base"]
template_list = []
for bt_id in searchable_business_template_list:
bt_template_list = self._getBTPathAndIdList([bt_id])
if len(bt_template_list):
template_list.append(bt_template_list[0])
if len(template_list) > 0:
return ["/".join(x[0].split("/")[:-1]) for x in template_list]
return []
def setupAutomaticBusinessTemplateRepository(self, accept_public=True,
searchable_business_template_list=("erp5_base",)):
template_tool = self.portal.portal_templates
bt_set = set(searchable_business_template_list).difference(x['title']
for x in template_tool.repository_dict.itervalues() for x in x)
if bt_set:
template_tool.updateRepositoryBusinessTemplateList(set(
os.path.dirname(x[0]) for x in self._getBTPathAndIdList(bt_set)),
genbt5list=1)
# Try to setup some valid Repository List by reusing ERP5TypeTestCase API.
# if accept_public we can accept public repository can be set, otherwise
# we let failure happens.
# Assume that the public official repository is a valid repository
public_bt5_repository_list = ['http://www.erp5.org/dists/snapshot/bt5/']
bt5_repository_path_list = self._getBusinessRepositoryPathList(
searchable_business_template_list)
if len(bt5_repository_path_list) > 0:
if accept_public:
try:
self.portal.portal_templates.updateRepositoryBusinessTemplateList(
bt5_repository_path_list, None)
except (RuntimeError, IOError), e:
# If bt5 repository is not a repository use public one.
self.portal.portal_templates.updateRepositoryBusinessTemplateList(
public_bt5_repository_list)
else:
self.portal.portal_templates.updateRepositoryBusinessTemplateList(
bt5_repository_path_list, None)
elif accept_public:
self.portal.portal_templates.updateRepositoryBusinessTemplateList(
public_bt5_repository_list)
else:
raise ValueError("ERP5 was unable to determinate a valid local " + \
"repository, please check your environment or " + \
"use accept_public as True")
def failIfDifferentSet(self, a, b, msg=""):
if not msg:
......@@ -821,12 +864,16 @@ class ERP5TypeCommandLineTestCase(ERP5TypeTestCaseMixin):
"""
return ()
def loadPromise(self):
def loadPromise(self, searchable_business_template_list=None):
""" Create promise configuration file and load it into configuration
"""
bt5_repository_path_list = self._getBusinessRepositoryPathList(
searchable_business_template_list)
promise_path = os.path.join(instancehome, "promise.cfg")
ZopeTestCase._print('Adding Promise at %s...\n' % promise_path)
_createTestPromiseConfigurationFile(promise_path)
_createTestPromiseConfigurationFile(promise_path, bt5_repository_path_list)
config.product_config["/%s" % self.getPortalName()] = \
{"promise_path": promise_path}
......
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