Commit c9c5dbf4 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Temp commit of BT installation test

parent 3bdde386
......@@ -6862,6 +6862,76 @@ class TestBusinessTemplate(BusinessTemplateMixin):
{'test_document': ('Removed but should be kept', 'Path')},
new_bt.preinstall())
def test_update_business_template_with_category_having_subcategory_tree_modified(self):
"""Tries to reproduce the bug of having portal/portal_categories/test_category/foo with
two sub-categories '1' and '2'. If a sub-object in '1' is modified and
'2' is removed then upgrading the template failed because:
- CategoryTemplateItem creates a trash object for '2' first
- PathTemplateItem does not re-create '1' when it re-installs the
Parent Category ('foo')
"""
portal_categories = self.portal.portal_categories
base_category_id = 'test_category'
if base_category_id in portal_categories.objectIds():
portal_categories.manage_delObjects([base_category_id])
base_category = portal_categories.newContent(portal_type='Base Category', id=base_category_id)
parent_category = base_category.newContent(portal_type='Category', id='foo')
parent_category.newContent(portal_type='Category', id='1')
parent_category.newContent(portal_type='Category', id='2')
parent_category['1'].newContent(portal_type='Category', id='10')
business_template = self.portal.portal_templates.newContent(
portal_type='Business Template',
title=self.id(),
template_path_list=(
'portal_categories/' + base_category_id,
'portal_categories/' + base_category_id + '/**'
),
template_base_category_list=[base_category_id],
)
self.tic()
business_template.build()
self.tic()
export_dir = tempfile.mkdtemp()
try:
business_template.export(path=export_dir, local=True)
self.tic()
new_business_template_version_1 = self.portal.portal_templates.download(
url='file://%s' % export_dir)
finally:
shutil.rmtree(export_dir)
# Modify parent category
parent_category.setTitle('Title for FOO')
# Add a child to '1'
parent_category['1'].newContent(portal_type='Category', id='11')
# Delete '2'
parent_category.manage_delObjects(['2'])
business_template = self.portal.portal_templates.newContent(
portal_type='Business Template',
title=self.id(),
template_path_list=(
'portal_categories/' + base_category_id,
'portal_categories/' + base_category_id + '/**'
),
template_base_category_list=[base_category_id],
)
self.tic()
business_template.build()
self.tic()
export_dir = tempfile.mkdtemp()
try:
business_template.export(path=export_dir, local=True)
self.tic()
self.portal.portal_categories.manage_delObjects([base_category_id])
new_business_template_version_1.install()
self.tic()
self.portal.portal_templates.updateBusinessTemplateFromUrl(
download_url='file://%s' % export_dir
) # Fails with KeyError: '1'
finally:
shutil.rmtree(export_dir)
def test_update_business_template_with_template_keep_path_list_catalog_method(self):
"""Tests for `template_keep_path_list` feature for the special case of catalog methods
"""
......
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