1 # -*- coding: iso-8859-1 -*- |
1 # -*- coding: iso-8859-1 -*- |
2 """XXX rename, split, reorganize this |
2 """XXX rename, split, reorganize this |
3 """ |
3 """ |
4 |
4 from __future__ import with_statement |
5 import os.path as osp |
5 |
6 |
6 from logilab.common.testlib import unittest_main |
7 from logilab.common.testlib import TestCase, unittest_main |
|
8 from cubicweb.devtools.apptest import EnvBasedTC |
7 from cubicweb.devtools.apptest import EnvBasedTC |
9 |
8 |
10 |
9 |
11 from cubicweb import CW_SOFTWARE_ROOT as BASE, Binary |
10 from cubicweb import CW_SOFTWARE_ROOT as BASE, Binary |
12 from cubicweb.selectors import match_user_groups, implements, rql_condition |
11 from cubicweb.selectors import match_user_groups, implements, rql_condition, traced_selection |
13 |
12 |
14 from cubicweb.web._exceptions import NoSelectableObject |
13 from cubicweb.web._exceptions import NoSelectableObject |
15 from cubicweb.web.action import Action |
14 from cubicweb.web.action import Action |
16 from cubicweb.web.views import (baseviews, tableview, baseforms, calendar, |
15 from cubicweb.web.views import (baseviews, tableview, baseforms, calendar, |
17 management, embedding, actions, startup, |
16 management, embedding, actions, startup, |
18 euser, schemaentities, xbel, vcard, |
17 euser, schemaentities, xbel, vcard, owl, |
19 treeview, idownloadable, wdoc, debug) |
18 treeview, idownloadable, wdoc, debug, eproperties) |
20 from cubicweb.entities.lib import Card |
|
21 from cubicweb.interfaces import IMileStone |
|
22 from cubicweb.web.views import owl |
|
23 |
19 |
24 USERACTIONS = [('myprefs', actions.UserPreferencesAction), |
20 USERACTIONS = [('myprefs', actions.UserPreferencesAction), |
25 ('myinfos', actions.UserInfoAction), |
21 ('myinfos', actions.UserInfoAction), |
26 ('logout', actions.LogoutAction)] |
22 ('logout', actions.LogoutAction)] |
27 SITEACTIONS = [('siteconfig', actions.SiteConfigurationAction), |
23 SITEACTIONS = [('siteconfig', actions.SiteConfigurationAction), |
69 # no entity |
65 # no entity |
70 req = self.request() |
66 req = self.request() |
71 self.assertListEqual(self.pviews(req, None), |
67 self.assertListEqual(self.pviews(req, None), |
72 [('changelog', wdoc.ChangeLogView), |
68 [('changelog', wdoc.ChangeLogView), |
73 ('debug', debug.DebugView), |
69 ('debug', debug.DebugView), |
74 ('epropertiesform', management.EpropertiesForm), |
70 ('epropertiesform', eproperties.EPropertiesForm), |
75 ('index', startup.IndexView), |
71 ('index', startup.IndexView), |
76 ('info', management.ProcessInformationView), |
72 ('info', management.ProcessInformationView), |
77 ('manage', startup.ManageView), |
73 ('manage', startup.ManageView), |
78 ('owl', owl.OWLView), |
74 ('owl', owl.OWLView), |
79 ('schema', startup.SchemaView), |
75 ('schema', startup.SchemaView), |
80 ('systemepropertiesform', management.SystemEpropertiesForm)]) |
76 ('systemepropertiesform', eproperties.SystemEPropertiesForm)]) |
81 # no entity but etype |
77 # no entity but etype |
82 rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999') |
78 rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999') |
83 self.assertListEqual(self.pviews(req, rset), |
79 self.assertListEqual(self.pviews(req, rset), |
84 [#('changelog', wdoc.ChangeLogView), |
80 []) |
85 #('epropertiesform', management.EpropertiesForm), |
|
86 #('index', startup.IndexView), |
|
87 #('info', management.ProcessInformationView), |
|
88 #('manage', startup.ManageView), |
|
89 #('schema', startup.SchemaView), |
|
90 #('systemepropertiesform', management.SystemEpropertiesForm) |
|
91 ]) |
|
92 # one entity |
81 # one entity |
93 rset, req = self.env.get_rset_and_req('EGroup X WHERE X name "managers"') |
82 rset, req = self.env.get_rset_and_req('EGroup X WHERE X name "managers"') |
94 self.assertListEqual(self.pviews(req, rset), |
83 self.assertListEqual(self.pviews(req, rset), |
95 [('csvexport', baseviews.CSVRsetView), |
84 [('csvexport', baseviews.CSVRsetView), |
96 ('ecsvexport', baseviews.CSVEntityView), |
85 ('ecsvexport', baseviews.CSVEntityView), |
226 'mainactions': [('edit', actions.ModifyAction), |
215 'mainactions': [('edit', actions.ModifyAction), |
227 ('workflow', schemaentities.ViewWorkflowAction),], |
216 ('workflow', schemaentities.ViewWorkflowAction),], |
228 'moreactions': [('delete', actions.DeleteAction), |
217 'moreactions': [('delete', actions.DeleteAction), |
229 ('copy', actions.CopyAction)], |
218 ('copy', actions.CopyAction)], |
230 }) |
219 }) |
231 |
|
232 def test_load_subinterface_based_vojects(self): |
|
233 self.vreg._lastmodifs = {} # clear cache |
|
234 self.vreg.register_objects([osp.join(BASE, 'web', 'views', 'iprogress.py')]) |
|
235 # check progressbar was kicked |
|
236 self.failIf('progressbar' in self.vreg['views']) |
|
237 class MyCard(Card): |
|
238 __implements__ = (IMileStone,) |
|
239 self.vreg.register_vobject_class(MyCard) |
|
240 self.vreg._lastmodifs = {} # clear cache |
|
241 self.vreg.register_objects([osp.join(BASE, 'web', 'views', 'iprogress.py')]) |
|
242 # check progressbar isn't kicked |
|
243 self.assertEquals(len(self.vreg['views']['progressbar']), 1) |
|
244 |
220 |
245 |
221 |
246 def test_select_creation_form(self): |
222 def test_select_creation_form(self): |
247 rset = None |
223 rset = None |
248 req = self.request() |
224 req = self.request() |
457 {'useractions': USERACTIONS, |
431 {'useractions': USERACTIONS, |
458 'siteactions': SITEACTIONS, |
432 'siteactions': SITEACTIONS, |
459 'mainactions': [('edit', actions.ModifyAction)], |
433 'mainactions': [('edit', actions.ModifyAction)], |
460 'moreactions': [('delete', actions.DeleteAction), |
434 'moreactions': [('delete', actions.DeleteAction), |
461 ('copy', actions.CopyAction), |
435 ('copy', actions.CopyAction), |
462 ('testaction', EETypeRQLAction)], |
436 ('testaction', EETypeRQLAction), |
|
437 ('managepermission', actions.ManagePermissionsAction)], |
463 }) |
438 }) |
464 rset, req = self.env.get_rset_and_req('EEType X WHERE X name "ERType"') |
439 rset, req = self.env.get_rset_and_req('EEType X WHERE X name "ERType"') |
465 self.assertDictEqual(self.pactions(req, rset), |
440 self.assertDictEqual(self.pactions(req, rset), |
466 {'useractions': USERACTIONS, |
441 {'useractions': USERACTIONS, |
467 'siteactions': SITEACTIONS, |
442 'siteactions': SITEACTIONS, |
468 'mainactions': [('edit', actions.ModifyAction)], |
443 'mainactions': [('edit', actions.ModifyAction)], |
469 'moreactions': [('delete', actions.DeleteAction), |
444 'moreactions': [('delete', actions.DeleteAction), |
470 ('copy', actions.CopyAction)], |
445 ('copy', actions.CopyAction), |
|
446 ('managepermission', actions.ManagePermissionsAction)], |
471 }) |
447 }) |
472 |
448 |
473 |
449 |
474 |
450 |
475 if __name__ == '__main__': |
451 if __name__ == '__main__': |