Commit 4f2b43b8 authored by Jérome Perrin's avatar Jérome Perrin

core,knowledge_pad: fix actions with same priority

In that case, the order of actions rendering is undefined, we want to
have unique priorities to have deterministic order of actions.
parent 30ba4c77
......@@ -27,6 +27,7 @@
#
##############################################################################
import collections
import pprint
import httplib
import urlparse
......@@ -206,9 +207,15 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
actions = self.portal.portal_actions.listFilteredActionsFor(target)
got = {}
for category, actions in actions.items():
actions_by_priority = collections.defaultdict(list)
got[category] = [dict(title=action['title'], id=action['id'])
for action in actions
if action['visible']]
for action in actions:
actions_by_priority[action['priority']].append(actions)
for actions in actions_by_priority.values():
if len(actions) > 1:
self.assertFalse(actions) # no actions with same priority
msg = ("Actions do not match. Expected:\n%s\n\nGot:\n%s\n" %
(pprint.pformat(expected), pprint.pformat(got)))
self.assertEqual(expected, got, msg)
......@@ -222,8 +229,6 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
'id': 'category_tool'},
{'title': 'Manage Callables',
'id': 'callable_tool'},
{'title': 'Create Module',
'id': 'create_module'},
{'title': 'Configure Portal Types',
'id': 'types_tool'},
{'id': 'property_sheet_tool',
......@@ -232,7 +237,9 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
'title': 'Configure Portal Catalog'},
{'id': 'portal_alarms_action',
'title': 'Configure Alarms'},
{'title': 'Undo', 'id': 'undo'}],
{'title': 'Undo', 'id': 'undo'},
{'title': 'Create Module',
'id': 'create_module'},],
'object': [],
'object_action': [{'id': 'diff_object_action', 'title': 'Diff Object'}],
'object_exchange': [{'id': 'csv_export', 'title': 'Export Csv File'}, # erp5_csv_style
......
......@@ -42,7 +42,7 @@
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>6.0</float> </value>
<value> <float>20.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -52,7 +52,7 @@
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>8.0</float> </value>
<value> <float>9.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -42,7 +42,7 @@
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>3.0</float> </value>
<value> <float>30.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
......
......@@ -44,7 +44,7 @@
</item>
<item>
<key> <string>priority</string> </key>
<value> <float>100.0</float> </value>
<value> <float>98.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
......
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