Properly test 'Favorite' actions. Fails in Zope 2.12, for the time being

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@32430 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 14d53d34
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
import unittest import unittest
import md5 import md5
import pprint
import transaction import transaction
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -186,24 +187,52 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -186,24 +187,52 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
self.assertTrue('business_application' self.assertTrue('business_application'
in type_information.getTypeBaseCategoryList()) in type_information.getTypeBaseCategoryList())
def test_02_FavouritesMenu(self, quiet=quiet, run=run_all_test): def check_actions(self, target, expected):
""" actions = self.portal.portal_actions.listFilteredActionsFor(target)
Test that Manage members is not an entry in the My Favourites menu. got = {}
""" for category, actions in actions.items():
if not run: return got[category] = [dict(title=action['title'], id=action['id'])
portal_actions = getattr(self.getPortal(), 'portal_actions', None) for action in actions
global_action_list = portal_actions.listFilteredActionsFor( if action['visible']]
self.getPortal())['global'] msg = ("Actions do not match. Expected:\n%s\n\nGot:\n%s\n" %
action_name_list = [] (pprint.pformat(expected), pprint.pformat(got)))
for action in global_action_list: self.assertEquals(expected, got, msg)
if(action['visible']):
action_name_list.append(action['title']) def test_actions_on_portal(self):
# as manager:
self.assertTrue('Create Module' in action_name_list) expected = {'folder': [],
'global': [{'title': 'Manage Business Templates',
for action_name in action_name_list: 'id': 'bt_tool'},
self.assertNotEqual(action_name, "Manage Members") {'title': 'Configure Categories',
self.assertNotEqual(action_name, "Manage members") 'id': 'category_tool'},
{'title': 'Create Module',
'id': 'create_module'},
{'title': 'Configure Portal Types',
'id': 'types_tool'},
{'title': 'Undo', 'id': 'undo'}],
'object': [],
'object_search': [{'title': 'Search', 'id': 'search'}],
'object_sort': [{'title': 'Sort', 'id': 'sort_on'}],
'object_ui': [{'title': 'Modify UI', 'id': 'list_ui'}],
'object_view': [{'title': 'History', 'id': 'history'},
{'title': 'Metadata', 'id': 'metadata'}],
'user': [{'title': 'Preferences', 'id': 'preferences'},
{'title': 'Log out', 'id': 'logout'}],
'workflow': []}
self.check_actions(self.portal, expected)
# as anonymous:
self.logout()
expected = {'folder': [],
'global': [],
'object': [],
'object_search': [{'title': 'Search', 'id': 'search'}],
'object_sort': [{'title': 'Sort', 'id': 'sort_on'}],
'object_ui': [{'title': 'Modify UI', 'id': 'list_ui'}],
'object_view': [{'title': 'History', 'id': 'history'}],
'user': [{'id': 'login', 'title': 'Login'}],
'workflow': []}
self.check_actions(self.portal, expected)
def test_frontpage(self): def test_frontpage(self):
"""Test we can view the front page. """Test we can view the front page.
......
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