Commit 7011ce47 authored by Boris Kocherov's avatar Boris Kocherov

BusinessTemplate: fix problem of not installment bt's actions whose

containers are not IActionProvider.
This problem arisen as result of my convert portal_action to erp5's action tool.
parent eaf90364
...@@ -535,6 +535,13 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor): ...@@ -535,6 +535,13 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
if x.getReference() == action_id] if x.getReference() == action_id]
object_type._delObject(action_id) object_type._delObject(action_id)
def stepRemoveFirstActionFromPath(self, sequence=None, **kw):
bt = sequence.get('current_bt', None)
self.assertTrue(bt is not None)
path_list = list(bt.getTemplatePathList())
path_list.remove('portal_types/Geek Object/action_become_geek')
bt.setTemplatePathList(path_list)
def stepCheckPortalTypeExists(self, sequence=None, **kw): def stepCheckPortalTypeExists(self, sequence=None, **kw):
""" """
Check presence of portal type Check presence of portal type
...@@ -1286,7 +1293,9 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor): ...@@ -1286,7 +1293,9 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
bc_id = sequence.get('bc_id') bc_id = sequence.get('bc_id')
bt = sequence.get('current_bt') bt = sequence.get('current_bt')
path = 'portal_categories/'+bc_id+'/**' path = 'portal_categories/'+bc_id+'/**'
bt.edit(template_path_list=[path]) path_list = list(bt.getTemplatePathList())
path_list.append(path)
bt.edit(template_path_list=path_list)
def stepCheckSubCategoriesExists(self, sequence=None, **kw): def stepCheckSubCategoriesExists(self, sequence=None, **kw):
bc_id = sequence.get('bc_id') bc_id = sequence.get('bc_id')
...@@ -2578,7 +2587,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor): ...@@ -2578,7 +2587,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
def stepCheckBeforeReinstall(self, sequence=None, **kw): def stepCheckBeforeReinstall(self, sequence=None, **kw):
import_bt = sequence.get('current_bt') import_bt = sequence.get('current_bt')
diff_list = import_bt.BusinessTemplate_getModifiedObject() diff_list = import_bt.BusinessTemplate_getModifiedObject()
self.assertTrue('portal_types/Geek Object/become_geek' self.assertTrue('portal_types/Geek Object/action_become_geek'
in [line.object_id for line in diff_list]) in [line.object_id for line in diff_list])
def stepInstallCurrentBusinessTemplate(self, sequence=None, **kw): def stepInstallCurrentBusinessTemplate(self, sequence=None, **kw):
...@@ -5922,6 +5931,7 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -5922,6 +5931,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
InstallCurrentBusinessTemplate Tic \ InstallCurrentBusinessTemplate Tic \
Tic \ Tic \
RemoveFirstAction \ RemoveFirstAction \
RemoveFirstActionFromPath \
CheckBeforeReinstall \ CheckBeforeReinstall \
ReinstallBusinessTemplate Tic \ ReinstallBusinessTemplate Tic \
\ \
...@@ -6525,20 +6535,19 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -6525,20 +6535,19 @@ class TestBusinessTemplate(BusinessTemplateMixin):
def test_global_action(self): def test_global_action(self):
# Tests that global actions are properly exported and reimported # Tests that global actions are properly exported and reimported
self.portal.portal_actions.addAction( portal_actions = self.portal.portal_actions
id='test_global_action', portal_actions.newContent(
name='Test Global Action', portal_type='Action Information',
action='', reference='test_global_action',
condition='', title='Test Global Action',
permission='', action_type='object_view')
category='object_view') action_id = 'action_test_global_action'
action_idx = len(self.portal.portal_actions._actions)
bt = self.portal.portal_templates.newContent( bt = self.portal.portal_templates.newContent(
portal_type='Business Template', portal_type='Business Template',
title='test_bt', title='test_bt',
template_action_path_list=( template_path_list=(
'portal_actions | test_global_action',),) 'portal_actions/action_test_global_action',),)
self.tic() self.tic()
bt.build() bt.build()
self.tic() self.tic()
...@@ -6550,14 +6559,14 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -6550,14 +6559,14 @@ class TestBusinessTemplate(BusinessTemplateMixin):
# tool # tool
self.assertEqual(['portal_actions'], self.assertEqual(['portal_actions'],
[os.path.basename(f) for f in [os.path.basename(f) for f in
glob.glob('%s/ActionTemplateItem/portal_types/*' % (export_dir, ))]) glob.glob('%s/PathTemplateItem/*' % (export_dir, ))])
new_bt = self.portal.portal_templates.download( new_bt = self.portal.portal_templates.download(
url='file:/%s' % export_dir) url='file:/%s' % export_dir)
finally: finally:
shutil.rmtree(export_dir) shutil.rmtree(export_dir)
# manually uninstall the action # manually uninstall the action
self.portal.portal_actions.deleteActions(selections=[action_idx]) portal_actions._delObject(action_id)
self.tic() self.tic()
# install the business template and make sure the action is properly # install the business template and make sure the action is properly
...@@ -6565,7 +6574,7 @@ class TestBusinessTemplate(BusinessTemplateMixin): ...@@ -6565,7 +6574,7 @@ class TestBusinessTemplate(BusinessTemplateMixin):
new_bt.install() new_bt.install()
self.tic() self.tic()
self.assertNotEquals(None, self.assertNotEquals(None,
self.portal.portal_actions.getActionInfo('object_view/test_global_action')) portal_actions._getOb(action_id, None))
def test_indexation_of_updated_path_item(self): def test_indexation_of_updated_path_item(self):
"""Tests indexation on updated paths item. """Tests indexation on updated paths item.
......
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