Commit 28e0f0a2 authored by Gabriel Monnerat's avatar Gabriel Monnerat

Add test to simulate the issue with the method...

Add test to simulate the issue with the method TemplateTool.installBusinessTemplateListFromRepository

Using the method try to install Business Templates that are already
installed, the Business Templates is uploaded on ERP5 but not used. It
creates a lot of garbage because in the end you have many bt5s not
installed.
parent c615bc62
No related merge requests found
......@@ -1317,9 +1317,15 @@ class TemplateTool (BaseTool):
"Impossible to install, please install the following dependencies before: %s" \
% [x[1] for x in missing_dependency_list]
template_url_dict = self._getBusinessTemplateUrlDict()
activate_kw = dict(activity="SQLQueue", tag="start_%s" % (time.time()))
for repository, bt_id in resolved_template_list:
bt = template_url_dict.get(bt_id)
if bt is not None and bt_id in installed_bt5_set:
revision = int(bt['revision'])
installed_bt5 = self.getInstalledBusinessTemplate(bt_id)
if int(installed_bt5.getRevision()) <= revision and only_newer:
continue
bt_url = '%s/%s' % (repository, bt_id)
param_dict = dict(download_url=bt_url, only_newer=only_newer)
if update_catalog is not _MARKER:
......
......@@ -627,6 +627,21 @@ class TestTemplateTool(ERP5TypeTestCase):
self.assertNotEquals(bt, None)
transaction.abort()
def test_installBusinessTemplateListFromRepository_ignore_when_installed(self):
"""Check that install one business template, this method does not download
many business templates that are already installed
"""
template_tool = self.portal.portal_templates
# Delete not installed bt5 to check easily if more not installed was
# created
for bt5 in template_tool.getBuiltBusinessTemplateList():
bt5.delete()
bt5_name_list = ['erp5_calendar']
template_tool.installBusinessTemplateListFromRepository(bt5_name_list,
install_dependency=True)
self.tic()
self.assertEquals(template_tool.getBuiltBusinessTemplateList(), [])
def test_sortBusinessTemplateList(self):
"""Check sorting of a list of business template by their dependencies
"""
......
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