Commit 0fa3ffd5 authored by Ayush Tiwari's avatar Ayush Tiwari

BusinessTemplate: Maintain consisitency while adding values in modified_object_list

In al the TemplateItem objects, we consider the values being added to modified_object_list
in the format {<object_path>: [List of changed action]}. But, for ObjectTemplateItem we
used to add tuples instead of list. This was not getting tested as we always had cases
where we had old_xml and new_xml similar to each other.
This also explains why some tests were expecting tuples and not lists in this commit:
727477a3

But, fortunately this came to notice after migrating SQL Method objects to behave as
ERP5fied objects.
parent 24277038
......@@ -1073,7 +1073,7 @@ class ObjectTemplateItem(BaseTemplateItem):
if installed_item._objects.has_key(path):
upgrade_list.append((path, installed_item._objects[path]))
else: # new object
modified_object_list[path] = 'New', type_name
modified_object_list[path] = ['New', type_name]
# update _p_jar property of objects cleaned by removeProperties
transaction.savepoint(optimistic=True)
......@@ -1094,15 +1094,15 @@ class ObjectTemplateItem(BaseTemplateItem):
old_io.close()
if new_obj_xml != old_obj_xml:
if context.isKeepObject(path):
modified_object_list[path] = 'Modified but should be kept', type_name
modified_object_list[path] = ['Modified but should be kept', type_name]
else:
modified_object_list[path] = 'Modified', type_name
modified_object_list[path] = ['Modified', type_name]
# get removed object
for path in set(installed_item._objects) - set(self._objects):
if context.isKeepObject(path):
modified_object_list[path] = 'Removed but should be kept', type_name
modified_object_list[path] = ['Removed but should be kept', type_name]
else:
modified_object_list[path] = 'Removed', type_name
modified_object_list[path] = ['Removed', type_name]
return modified_object_list
def _backupObject(self, action, trashbin, container_path, object_id, **kw):
......
......@@ -6857,7 +6857,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
finally:
shutil.rmtree(export_dir)
self.assertEqual(
{'test_document': ('Removed but should be kept', 'Path')},
{'test_document': ['Removed but should be kept', 'Path']},
new_bt.preinstall())
def test_update_business_template_with_template_keep_path_list_catalog_method(self):
......@@ -6912,7 +6912,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
shutil.rmtree(export_dir)
self.assertEqual(
{'portal_catalog/erp5_mysql_innodb/z_fake_method':
('Removed but should be kept', 'CatalogMethod')},
['Removed but should be kept', 'CatalogMethod']},
new_bt.preinstall())
def test_BusinessTemplateWithTest(self):
......
......@@ -1155,4 +1155,4 @@ AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO
# the PythonScript is recognised as modified
result = second_import_template.preinstall()
self.assertEquals(result.get('portal_skins/%s/%s' % (skin_folder_id, python_script_id)),
('Modified', 'Skin'))
['Modified', 'Skin'])
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