Commit 8ef8e6cb authored by Jérome Perrin's avatar Jérome Perrin

BusinessTemplate: backup existing objects overwritten during business template update

parent 1399c8f8
...@@ -1088,7 +1088,8 @@ class ObjectTemplateItem(BaseTemplateItem): ...@@ -1088,7 +1088,8 @@ class ObjectTemplateItem(BaseTemplateItem):
# old widget, thus we can readd them in # old widget, thus we can readd them in
# the right order group # the right order group
old_groups[path] = deepcopy(old_obj.groups) old_groups[path] = deepcopy(old_obj.groups)
subobjects_dict = self._backupObject(action, trashbin, # we force backup since it was an existing object
subobjects_dict = self._backupObject('backup', trashbin,
container_path, object_id) container_path, object_id)
# in case of portal types, we want to keep some properties # in case of portal types, we want to keep some properties
if interfaces.ITypeProvider.providedBy(container): if interfaces.ITypeProvider.providedBy(container):
......
...@@ -3142,9 +3142,29 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor): ...@@ -3142,9 +3142,29 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
skin_folder = self.portal.portal_skins[skin_folder_id] skin_folder = self.portal.portal_skins[skin_folder_id]
skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript( skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript(
id=python_script_id) id=python_script_id)
skin_folder[python_script_id].ZPythonScript_edit('param=""', 'return "body"')
sequence.set('python_script_id', python_script_id) sequence.set('python_script_id', python_script_id)
sequence.set('skin_folder_id', skin_folder_id) sequence.set('skin_folder_id', skin_folder_id)
def stepModifyFakeZODBScript(self, sequence=None, **kw):
script = self.portal.portal_skins[sequence['skin_folder_id']]\
[sequence['python_script_id']]
script.ZPythonScript_edit('new_param=""', 'return "new body"')
def stepCheckFakeZODBScriptIsUpdated(self, sequence=None, **kw):
script = self.portal.portal_skins[sequence['skin_folder_id']]\
[sequence['python_script_id']]
self.assertEquals('return "body"\n',
script._body)
def stepCheckFakeZODBScriptIsBackedUp(self, sequence=None, **kw):
trash = self.getTrashTool()
trash_bin, = trash.objectValues()
backup_script = trash_bin.portal_skins_items[sequence['skin_folder_id']]\
[sequence['python_script_id']]
self.assertEquals('return "new body"\n',
backup_script._body)
def stepAddCustomSkinFolderToBusinessTemplate(self, sequence=None, **kw): def stepAddCustomSkinFolderToBusinessTemplate(self, sequence=None, **kw):
""" """
Add types to business template Add types to business template
...@@ -5545,6 +5565,7 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -5545,6 +5565,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
UseImportBusinessTemplate \ UseImportBusinessTemplate \
InstallWithoutForceBusinessTemplate \ InstallWithoutForceBusinessTemplate \
Tic \ Tic \
RemoveAllTrashBins \
\ \
CheckFormGroups \ CheckFormGroups \
\ \
...@@ -5919,6 +5940,59 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -5919,6 +5940,59 @@ class TestBusinessTemplate(BusinessTemplateMixin):
sequence_list.addSequenceString(sequence_string) sequence_list.addSequenceString(sequence_string)
sequence_list.play(self) sequence_list.play(self)
def test_CheckInstallErasingExistingDocument(self):
""" Installing a business template containing a path that already exist
in the site should overwrite this path after storing it in portal_trash
"""
sequence_list = SequenceList()
sequence_string = '\
RemoveAllTrashBins \
CreateFakeZODBScript \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
AddCustomSkinFolderToBusinessTemplate \
BuildBusinessTemplate \
ModifyFakeZODBScript \
SaveBusinessTemplate \
ImportBusinessTemplate \
InstallCurrentBusinessTemplate Tic \
CheckFakeZODBScriptIsUpdated \
CheckFakeZODBScriptIsBackedUp \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_CheckUpdateErasingExistingDocument(self):
""" Updating a business template containing a path that already exist
in the site should overwrite this path after storing it in portal_trash
"""
sequence_list = SequenceList()
sequence_string = '\
RemoveAllTrashBins \
CreateFakeZODBScript \
CreateNewBusinessTemplate \
UseExportBusinessTemplate \
BuildBusinessTemplate \
SaveBusinessTemplate \
ImportBusinessTemplate \
InstallCurrentBusinessTemplate Tic \
ImportBusinessTemplate \
UseImportBusinessTemplate \
AddCustomSkinFolderToBusinessTemplate \
BuildBusinessTemplate \
ModifyFakeZODBScript \
SaveBusinessTemplate \
ImportBusinessTemplate \
UseImportBusinessTemplate \
InstallWithoutForceBusinessTemplate Tic \
CheckFakeZODBScriptIsUpdated \
CheckFakeZODBScriptIsBackedUp \
'
sequence_list.addSequenceString(sequence_string)
sequence_list.play(self)
def test_39_CheckSiteProperties(self): def test_39_CheckSiteProperties(self):
"""Test Site Properties""" """Test Site Properties"""
sequence_list = SequenceList() sequence_list = SequenceList()
......
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