Commit 88e56565 authored by Rafael Monnerat's avatar Rafael Monnerat

On updateBusinessTemplateFromUrl, do not install the business template or run...

On updateBusinessTemplateFromUrl, do not install the business template or run any script if the business template was already installed with the same revision or newer. The Exception is if reinstall parameter is True.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@42316 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 62f554bd
......@@ -1199,6 +1199,12 @@ class TemplateTool (BaseTool):
install_kw = dict.fromkeys(imported_bt5.getItemsList(), 'install')
else:
install_kw = {}
previous_bt5 = self.getInstalledBusinessTemplate(bt_title)
if previous_bt5 is not None and \
(imported_bt5.getRevision() <= previous_bt5.getRevision()):
log("%s is already installed with same or newer revision." % bt_title)
return imported_bt5
for listbox_line in listbox_object_list:
item = listbox_line.object_id
state = listbox_line.object_state
......
......@@ -5690,22 +5690,43 @@ class TestBusinessTemplate(ERP5TypeTestCase, LogInterceptor):
def test_updateBusinessTemplateFromUrl_simple(self):
"""
Test updateBusinessTemplateFromUrl method
By default if a new business template has revision >= previous one
the new bt5 is not installed, only imported.
"""
template_tool = self.portal.portal_templates
old_bt = template_tool.getInstalledBusinessTemplate('erp5_csv_style')
# change revision to an old revision
old_bt.setRevision(0.0001)
url = 'https://svn.erp5.org/repos/public/erp5/trunk/bt5/erp5_csv_style'
template_tool.updateBusinessTemplateFromUrl(url)
new_bt = template_tool.getInstalledBusinessTemplate('erp5_csv_style')
self.assertNotEquals(old_bt, new_bt)
self.assertEquals('erp5_csv_style', new_bt.getTitle())
# Test Another time with definning an ID
old_bt = new_bt
old_bt.setRevision(0.0002)
template_tool.updateBusinessTemplateFromUrl(url, id="new_erp5_csv_style")
new_bt = template_tool.getInstalledBusinessTemplate('erp5_csv_style')
self.assertNotEquals(old_bt, new_bt)
self.assertEquals('erp5_csv_style', new_bt.getTitle())
self.assertEquals('new_erp5_csv_style', new_bt.getId())
# Test if the new instance with same revision is not installed.
old_bt = new_bt
template_tool.updateBusinessTemplateFromUrl(url, id="not_installed_bt5")
new_bt = template_tool.getInstalledBusinessTemplate('erp5_csv_style')
self.assertEquals(old_bt, new_bt)
self.assertEquals('erp5_csv_style', new_bt.getTitle())
self.assertEquals('new_erp5_csv_style', new_bt.getId())
not_installed_bt5 = getattr(template_tool, "not_installed_bt5", None)
self.assertNotEquals(not_installed_bt5, None)
self.assertEquals('erp5_csv_style', not_installed_bt5.getTitle())
self.assertEquals(not_installed_bt5.getInstallationState(),
"not_installed")
self.assertEquals(not_installed_bt5.getRevision(), new_bt.getRevision())
def test_updateBusinessTemplateFromUrl_keep_list(self):
"""
Test updateBusinessTemplateFromUrl method
......
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