17 treeview, idownloadable, wdoc, debug, |
17 treeview, idownloadable, wdoc, debug, |
18 cwproperties, workflow, xmlrss, csvexport) |
18 cwproperties, workflow, xmlrss, csvexport) |
19 |
19 |
20 from cubes.folder import views as folderviews |
20 from cubes.folder import views as folderviews |
21 |
21 |
22 USERACTIONS = [('myprefs', actions.UserPreferencesAction), |
22 USERACTIONS = [actions.UserPreferencesAction, |
23 ('myinfos', actions.UserInfoAction), |
23 actions.UserInfoAction, |
24 ('logout', actions.LogoutAction)] |
24 actions.LogoutAction] |
25 SITEACTIONS = [('siteconfig', actions.SiteConfigurationAction), |
25 SITEACTIONS = [actions.SiteConfigurationAction, |
26 ('manage', actions.ManageAction), |
26 actions.ManageAction, |
27 ('schema', schema.ViewSchemaAction), |
27 schema.ViewSchemaAction, |
28 ('siteinfo', actions.SiteInfoAction), |
28 actions.SiteInfoAction, |
29 ] |
29 ] |
30 |
30 |
31 class ViewSelectorTC(CubicWebTC): |
31 class ViewSelectorTC(CubicWebTC): |
32 |
32 |
33 def setup_database(self): |
33 def setup_database(self): |
34 self.add_entity('BlogEntry', title=u"une news !", content=u"cubicweb c'est beau") |
34 self.add_entity('BlogEntry', title=u"une news !", content=u"cubicweb c'est beau") |
35 self.add_entity('Bookmark', title=u"un signet !", path=u"view?vid=index") |
35 self.add_entity('Bookmark', title=u"un signet !", path=u"view?vid=index") |
36 self.add_entity('EmailAddress', address=u"devel@logilab.fr", alias=u'devel') |
36 self.add_entity('EmailAddress', address=u"devel@logilab.fr", alias=u'devel') |
37 self.add_entity('Tag', name=u'x') |
37 self.add_entity('Tag', name=u'x') |
38 |
|
39 def pactions(self, req, rset): |
|
40 resdict = self.vreg['actions'].possible_actions(req, rset) |
|
41 for cat, actions in resdict.items(): |
|
42 resdict[cat] = [(a.id, a.__class__) for a in actions] |
|
43 return resdict |
|
44 |
|
45 |
38 |
46 class VRegistryTC(ViewSelectorTC): |
39 class VRegistryTC(ViewSelectorTC): |
47 """test the view selector""" |
40 """test the view selector""" |
48 |
41 |
49 def _test_registered(self, registry, content): |
42 def _test_registered(self, registry, content): |
74 ('index', startup.IndexView), |
67 ('index', startup.IndexView), |
75 ('info', management.ProcessInformationView), |
68 ('info', management.ProcessInformationView), |
76 ('manage', startup.ManageView), |
69 ('manage', startup.ManageView), |
77 ('owl', owl.OWLView), |
70 ('owl', owl.OWLView), |
78 ('propertiesform', cwproperties.CWPropertiesForm), |
71 ('propertiesform', cwproperties.CWPropertiesForm), |
79 ('registry', startup.RegistryView), |
72 ('registry', debug.RegistryView), |
80 ('schema', schema.SchemaView), |
73 ('schema', schema.SchemaView), |
81 ('systempropertiesform', cwproperties.SystemCWPropertiesForm), |
74 ('systempropertiesform', cwproperties.SystemCWPropertiesForm), |
82 ('tree', folderviews.FolderTreeView), |
75 ('tree', folderviews.FolderTreeView), |
83 ]) |
76 ]) |
84 |
77 |
227 ('xml', xmlrss.XMLView), |
220 ('xml', xmlrss.XMLView), |
228 ]) |
221 ]) |
229 |
222 |
230 def test_possible_actions_none_rset(self): |
223 def test_possible_actions_none_rset(self): |
231 req = self.request() |
224 req = self.request() |
232 self.assertDictEqual(self.pactions(req, None), |
225 self.assertDictEqual(self.pactionsdict(req, None, skipcategories=()), |
233 {'useractions': USERACTIONS, |
226 {'useractions': USERACTIONS, |
234 'siteactions': SITEACTIONS, |
227 'siteactions': SITEACTIONS, |
235 |
228 |
236 }) |
229 }) |
237 def test_possible_actions_no_entity(self): |
230 def test_possible_actions_no_entity(self): |
238 req = self.request() |
231 req = self.request() |
239 rset = req.execute('Any X WHERE X eid 999999') |
232 rset = req.execute('Any X WHERE X eid 999999') |
240 self.assertDictEqual(self.pactions(req, rset), |
233 self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
241 {'useractions': USERACTIONS, |
234 {'useractions': USERACTIONS, |
242 'siteactions': SITEACTIONS, |
235 'siteactions': SITEACTIONS, |
243 }) |
236 }) |
244 |
237 |
245 def test_possible_actions_same_type_entities(self): |
238 def test_possible_actions_same_type_entities(self): |
246 req = self.request() |
239 req = self.request() |
247 rset = req.execute('CWGroup X') |
240 rset = req.execute('CWGroup X') |
248 self.assertDictEqual(self.pactions(req, rset), |
241 self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
249 {'useractions': USERACTIONS, |
242 {'useractions': USERACTIONS, |
250 'siteactions': SITEACTIONS, |
243 'siteactions': SITEACTIONS, |
251 'mainactions': [('muledit', actions.MultipleEditAction)], |
244 'mainactions': [actions.MultipleEditAction], |
252 'moreactions': [('delete', actions.DeleteAction), |
245 'moreactions': [actions.DeleteAction, |
253 ('addentity', actions.AddNewAction)], |
246 actions.AddNewAction], |
254 }) |
247 }) |
255 |
248 |
256 def test_possible_actions_different_types_entities(self): |
249 def test_possible_actions_different_types_entities(self): |
257 req = self.request() |
250 req = self.request() |
258 rset = req.execute('Any X') |
251 rset = req.execute('Any X') |
259 self.assertDictEqual(self.pactions(req, rset), |
252 self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
260 {'useractions': USERACTIONS, |
253 {'useractions': USERACTIONS, |
261 'siteactions': SITEACTIONS, |
254 'siteactions': SITEACTIONS, |
262 'moreactions': [('delete', actions.DeleteAction)], |
255 'moreactions': [actions.DeleteAction], |
263 }) |
256 }) |
264 |
257 |
265 def test_possible_actions_final_entities(self): |
258 def test_possible_actions_final_entities(self): |
266 req = self.request() |
259 req = self.request() |
267 rset = req.execute('Any N, X WHERE X in_group Y, Y name N') |
260 rset = req.execute('Any N, X WHERE X in_group Y, Y name N') |
268 self.assertDictEqual(self.pactions(req, rset), |
261 self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
269 {'useractions': USERACTIONS, |
262 {'useractions': USERACTIONS, |
270 'siteactions': SITEACTIONS}) |
263 'siteactions': SITEACTIONS}) |
271 |
264 |
272 def test_possible_actions_eetype_cwuser_entity(self): |
265 def test_possible_actions_eetype_cwuser_entity(self): |
273 req = self.request() |
266 req = self.request() |
274 rset = req.execute('CWEType X WHERE X name "CWUser"') |
267 rset = req.execute('CWEType X WHERE X name "CWUser"') |
275 self.assertDictEqual(self.pactions(req, rset), |
268 self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
276 {'useractions': USERACTIONS, |
269 {'useractions': USERACTIONS, |
277 'siteactions': SITEACTIONS, |
270 'siteactions': SITEACTIONS, |
278 'mainactions': [('edit', actions.ModifyAction)], |
271 'mainactions': [actions.ModifyAction], |
279 'moreactions': [('managepermission', actions.ManagePermissionsAction), |
272 'moreactions': [actions.ManagePermissionsAction, |
280 ('addrelated', actions.AddRelatedActions), |
273 actions.AddRelatedActions, |
281 ('delete', actions.DeleteAction), |
274 actions.DeleteAction, |
282 ('copy', actions.CopyAction), |
275 actions.CopyAction, |
283 ], |
276 ], |
284 }) |
277 }) |
285 |
278 |
286 |
279 |
287 def test_select_creation_form(self): |
280 def test_select_creation_form(self): |
470 del self.vreg['actions']['testaction'] |
463 del self.vreg['actions']['testaction'] |
471 |
464 |
472 def test(self): |
465 def test(self): |
473 req = self.request() |
466 req = self.request() |
474 rset = req.execute('CWEType X WHERE X name "CWEType"') |
467 rset = req.execute('CWEType X WHERE X name "CWEType"') |
475 self.assertDictEqual(self.pactions(req, rset), |
468 self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
476 {'useractions': USERACTIONS, |
469 {'useractions': USERACTIONS, |
477 'siteactions': SITEACTIONS, |
470 'siteactions': SITEACTIONS, |
478 'mainactions': [('edit', actions.ModifyAction)], |
471 'mainactions': [actions.ModifyAction], |
479 'moreactions': [('managepermission', actions.ManagePermissionsAction), |
472 'moreactions': [actions.ManagePermissionsAction, |
480 ('addrelated', actions.AddRelatedActions), |
473 actions.AddRelatedActions, |
481 ('delete', actions.DeleteAction), |
474 actions.DeleteAction, |
482 ('copy', actions.CopyAction), |
475 actions.CopyAction, |
483 ('testaction', CWETypeRQLAction), |
476 CWETypeRQLAction, |
484 ], |
477 ], |
485 }) |
478 }) |
486 req = self.request() |
479 req = self.request() |
487 rset = req.execute('CWEType X WHERE X name "CWRType"') |
480 rset = req.execute('CWEType X WHERE X name "CWRType"') |
488 self.assertDictEqual(self.pactions(req, rset), |
481 self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
489 {'useractions': USERACTIONS, |
482 {'useractions': USERACTIONS, |
490 'siteactions': SITEACTIONS, |
483 'siteactions': SITEACTIONS, |
491 'mainactions': [('edit', actions.ModifyAction)], |
484 'mainactions': [actions.ModifyAction], |
492 'moreactions': [('managepermission', actions.ManagePermissionsAction), |
485 'moreactions': [actions.ManagePermissionsAction, |
493 ('addrelated', actions.AddRelatedActions), |
486 actions.AddRelatedActions, |
494 ('delete', actions.DeleteAction), |
487 actions.DeleteAction, |
495 ('copy', actions.CopyAction), |
488 actions.CopyAction, |
496 ], |
489 ], |
497 }) |
490 }) |
498 |
491 |
499 |
492 |
500 |
493 |