Commit 35d8bbce authored by Rafael Monnerat's avatar Rafael Monnerat

Drop duplicated code at tests used to update Repository List

Now as default, the tests prefer local bt5 folder if it is a repository.

With the usage of git branches, this changes helps the developer test
his own local changes before merge with master (branch used to generate
snapshots)
parent b373caa4
......@@ -57,8 +57,7 @@ class TestTemplateTool(ERP5TypeTestCase):
def afterSetUp(self):
self.templates_tool = self.portal.portal_templates
self.templates_tool.updateRepositoryBusinessTemplateList(\
["http://www.erp5.org/dists/snapshot/bt5/", ])
self.setupAutomaticBusinessTemplateRepository()
if getattr(self.portal, self.test_tool_id, None) is not None:
self.portal.manage_delObjects(ids=[self.test_tool_id])
self.portal.newContent(portal_type='Template Tool',
......@@ -584,7 +583,7 @@ class TestTemplateTool(ERP5TypeTestCase):
bt = template_tool.getInstalledBusinessTemplate(bt5_name)
self.assertEquals(bt, None)
dependency_list = template_tool.getDependencyList(
(repository, bt5_name + '.bt5'))
(repository, bt5_name))
self.assertNotEquals(dependency_list, [])
self.tic()
......@@ -604,10 +603,14 @@ class TestTemplateTool(ERP5TypeTestCase):
repository = "http://www.erp5.org/dists/snapshot/bt5/"
template_tool = self.portal.portal_templates
# XXX This test requires the usage of the public repository due ".bt5" usage
if repository not in template_tool.getRepositoryList():
self.portal.portal_templates.updateRepositoryBusinessTemplateList([repository])
bt5list = template_tool.resolveBusinessTemplateListDependency(('erp5_credential',))
# because erp5_base is already installed, it is not returned
# by resolveBusinessTemplateListDependency, so append it manualy
bt5list.append((repository, 'erp5_base.bt5'))
bt5list.append((repository, "erp5_base.bt5"))
# add some entropy by disorder bt5list returned by
# resolveBusinessTemplateListDependency
......
......@@ -113,22 +113,7 @@ class TestLiveConfiguratorWorkflowMixin(SecurityTestCase):
self.stepCleanUpRequest()
self.restricted_security = 0
# information to know if a business template is a standard business
# template or a custom one
public_bt5_repository_list = ['http://www.erp5.org/dists/snapshot/bt5/']
template_list = self._getBTPathAndIdList(["erp5_base"])
if len(template_list) > 0:
bt5_repository_path = "/".join(template_list[0][0].split("/")[:-1])
try:
self.portal.portal_templates.updateRepositoryBusinessTemplateList(
[bt5_repository_path], None)
except (RuntimeError, IOError):
# 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(
public_bt5_repository_list)
self.setupAutomaticBusinessTemplateRepository()
# it is required by SecurityTestCase
self.workflow_tool = self.portal.portal_workflow
......
......@@ -41,22 +41,7 @@ class TestZeleniumConfiguratorStandard(ERP5TypeFunctionalTestCase):
] + BASE_REMOTE_SELENIUM_TEST_URL_LIST
def afterSetUp(self):
# information to know if a business template is a standard business
# template or a custom one
public_bt5_repository_list = ['http://www.erp5.org/dists/snapshot/bt5/']
template_list = self._getBTPathAndIdList(["erp5_base"])
if len(template_list) > 0:
bt5_repository_path = "/".join(template_list[0][0].split("/")[:-1])
try:
self.portal.portal_templates.updateRepositoryBusinessTemplateList(
[bt5_repository_path], None)
except (RuntimeError, IOError):
# 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(
public_bt5_repository_list)
self.setupAutomaticBusinessTemplateRepository()
print self.portal.portal_templates.getRepositoryList()
ERP5TypeFunctionalTestCase.afterSetUp(self)
......
......@@ -520,6 +520,36 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase):
DeprecationWarning)
return self.createUserAssignment(user, assignment_kw)
def setupAutomaticBusinessTemplateRepository(self, accept_public=True):
# 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/']
template_list = self._getBTPathAndIdList(["erp5_base"])
if len(template_list) > 0:
bt5_repository_path = "/".join(template_list[0][0].split("/")[:-1])
if accept_public:
try:
self.portal.portal_templates.updateRepositoryBusinessTemplateList(
[bt5_repository_path], 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], 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:
msg='%r != %r' % (a, b)
......
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