facilities to test new submenu actions 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 15 Sep 2009 14:47:39 +0200
branch3.5
changeset 3225 464c5b9c6fa0
parent 3224 56d4104b4261
child 3226 10f4f525044c
facilities to test new submenu actions
devtools/apptest.py
--- a/devtools/apptest.py	Tue Sep 15 14:47:15 2009 +0200
+++ b/devtools/apptest.py	Tue Sep 15 14:47:39 2009 +0200
@@ -230,6 +230,23 @@
         return [(a.id, a.__class__) for a in self.vreg['actions'].possible_vobjects(req, rset=rset)
                 if a.category not in skipcategories]
 
+    def action_submenu(self, req, rset, id):
+        return self._test_action(self.vreg['actions'].select(id, req, rset=rset))
+
+    def _test_action(self, action):
+        class fake_menu(list):
+            @property
+            def items(self):
+                return self
+        class fake_box(object):
+            def mk_action(self, label, url, **kwargs):
+                return (label, url)
+            def box_action(self, action, **kwargs):
+                return (action.title, action.url())
+        submenu = fake_menu()
+        action.fill_menu(fake_box(), submenu)
+        return submenu
+
     def pactions_by_cats(self, req, rset, categories=('addrelated',)):
         return [(a.id, a.__class__) for a in self.vreg['actions'].possible_vobjects(req, rset=rset)
                 if a.category in categories]