author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 12 Mar 2010 11:34:35 +0100 | |
branch | stable |
changeset 4885 | 7929865dedf1 |
parent 4724 | fe1f3c560381 |
child 4916 | 4b8cdda342ae |
permissions | -rw-r--r-- |
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
0 | 2 |
"""XXX rename, split, reorganize this |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1914
diff
changeset
|
3 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 4 |
""" |
783 | 5 |
from logilab.common.testlib import unittest_main |
793 | 6 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
7 |
from cubicweb.devtools.testlib import CubicWebTC |
4493
c0a43c6ba777
now raise UnknownProperty, not KeyError
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4492
diff
changeset
|
8 |
from cubicweb import CW_SOFTWARE_ROOT as BASE, Binary, UnknownProperty |
793 | 9 |
from cubicweb.selectors import (match_user_groups, implements, |
10 |
specified_etype_implements, rql_condition, |
|
11 |
traced_selection) |
|
12 |
from cubicweb.web import NoSelectableObject |
|
0 | 13 |
from cubicweb.web.action import Action |
1654 | 14 |
from cubicweb.web.views import (primary, baseviews, tableview, editforms, |
15 |
calendar, management, embedding, actions, |
|
16 |
startup, cwuser, schema, xbel, vcard, owl, |
|
17 |
treeview, idownloadable, wdoc, debug, |
|
18 |
cwproperties, workflow, xmlrss, csvexport) |
|
0 | 19 |
|
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
20 |
from cubes.folder import views as folderviews |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
21 |
|
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
22 |
USERACTIONS = [actions.UserPreferencesAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
23 |
actions.UserInfoAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
24 |
actions.LogoutAction] |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
25 |
SITEACTIONS = [actions.SiteConfigurationAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
26 |
actions.ManageAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
27 |
schema.ViewSchemaAction, |
3998
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
28 |
actions.SiteInfoAction] |
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
29 |
FOOTERACTIONS = [wdoc.HelpAction, |
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
30 |
wdoc.ChangeLogAction, |
3589 | 31 |
wdoc.AboutAction, |
32 |
actions.PoweredByAction] |
|
0 | 33 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
34 |
class ViewSelectorTC(CubicWebTC): |
0 | 35 |
|
36 |
def setup_database(self): |
|
4078 | 37 |
req = self.request() |
38 |
req.create_entity('BlogEntry', title=u"une news !", content=u"cubicweb c'est beau") |
|
39 |
req.create_entity('Bookmark', title=u"un signet !", path=u"view?vid=index") |
|
40 |
req.create_entity('EmailAddress', address=u"devel@logilab.fr", alias=u'devel') |
|
41 |
req.create_entity('Tag', name=u'x') |
|
0 | 42 |
|
43 |
class VRegistryTC(ViewSelectorTC): |
|
44 |
"""test the view selector""" |
|
45 |
||
46 |
def _test_registered(self, registry, content): |
|
47 |
try: |
|
48 |
expected = getattr(self, 'all_%s' % registry) |
|
49 |
except AttributeError: |
|
50 |
return |
|
51 |
if registry == 'hooks': |
|
52 |
self.assertEquals(len(content), expected, content) |
|
53 |
return |
|
54 |
try: |
|
55 |
self.assertSetEqual(content.keys(), expected) |
|
56 |
except: |
|
57 |
print registry, sorted(expected), sorted(content.keys()) |
|
58 |
print 'no more', [v for v in expected if not v in content.keys()] |
|
59 |
print 'missing', [v for v in content.keys() if not v in expected] |
|
60 |
raise |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
61 |
|
2403
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
62 |
def setUp(self): |
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
63 |
super(VRegistryTC, self).setUp() |
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
64 |
assert self.vreg['views']['propertiesform'] |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
65 |
|
793 | 66 |
def test_possible_views_none_rset(self): |
0 | 67 |
req = self.request() |
68 |
self.assertListEqual(self.pviews(req, None), |
|
69 |
[('changelog', wdoc.ChangeLogView), |
|
70 |
('index', startup.IndexView), |
|
4724
fe1f3c560381
fix test, broken by the merge of debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4534
diff
changeset
|
71 |
('info', debug.ProcessInformationView), |
0 | 72 |
('manage', startup.ManageView), |
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
73 |
('owl', owl.OWLView), |
1900
8dd4bb69c73d
[tests] fix test after eproperties got renamed to cwproperties
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1797
diff
changeset
|
74 |
('propertiesform', cwproperties.CWPropertiesForm), |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
75 |
('registry', debug.RegistryView), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
76 |
('schema', schema.SchemaView), |
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
77 |
('systempropertiesform', cwproperties.SystemCWPropertiesForm), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
78 |
('tree', folderviews.FolderTreeView), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
79 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
80 |
|
793 | 81 |
def test_possible_views_noresult(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
82 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
83 |
rset = req.execute('Any X WHERE X eid 999999') |
0 | 84 |
self.assertListEqual(self.pviews(req, rset), |
783 | 85 |
[]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
86 |
|
793 | 87 |
def test_possible_views_one_egroup(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
88 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
89 |
rset = req.execute('CWGroup X WHERE X name "managers"') |
0 | 90 |
self.assertListEqual(self.pviews(req, rset), |
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
91 |
[('csvexport', csvexport.CSVRsetView), |
1654 | 92 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 93 |
('editable-table', tableview.EditableTableView), |
444 | 94 |
('filetree', treeview.FileTreeView), |
0 | 95 |
('list', baseviews.ListView), |
96 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
97 |
('owlabox', owl.OWLABOXView), |
1654 | 98 |
('primary', primary.PrimaryView), |
99 |
('rsetxml', xmlrss.XMLRsetView), |
|
100 |
('rss', xmlrss.RSSView), |
|
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
101 |
('sameetypelist', baseviews.SameETypeListView), |
0 | 102 |
('secondary', baseviews.SecondaryView), |
103 |
('security', management.SecurityManagementView), |
|
104 |
('table', tableview.TableView), |
|
105 |
('text', baseviews.TextView), |
|
444 | 106 |
('treeview', treeview.TreeView), |
0 | 107 |
('xbel', xbel.XbelView), |
1654 | 108 |
('xml', xmlrss.XMLView), |
0 | 109 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
110 |
|
793 | 111 |
def test_possible_views_multiple_egroups(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
112 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
113 |
rset = req.execute('CWGroup X') |
0 | 114 |
self.assertListEqual(self.pviews(req, rset), |
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
115 |
[('csvexport', csvexport.CSVRsetView), |
1654 | 116 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 117 |
('editable-table', tableview.EditableTableView), |
444 | 118 |
('filetree', treeview.FileTreeView), |
0 | 119 |
('list', baseviews.ListView), |
120 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
121 |
('owlabox', owl.OWLABOXView), |
1654 | 122 |
('primary', primary.PrimaryView), |
123 |
('rsetxml', xmlrss.XMLRsetView), |
|
124 |
('rss', xmlrss.RSSView), |
|
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
125 |
('sameetypelist', baseviews.SameETypeListView), |
0 | 126 |
('secondary', baseviews.SecondaryView), |
127 |
('security', management.SecurityManagementView), |
|
128 |
('table', tableview.TableView), |
|
129 |
('text', baseviews.TextView), |
|
444 | 130 |
('treeview', treeview.TreeView), |
0 | 131 |
('xbel', xbel.XbelView), |
1654 | 132 |
('xml', xmlrss.XMLView), |
0 | 133 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
134 |
|
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
135 |
def test_propertiesform_admin(self): |
2403
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
136 |
assert self.vreg['views']['propertiesform'] |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
137 |
req1 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
138 |
req2 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
139 |
rset1 = req1.execute('CWUser X WHERE X login "admin"') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
140 |
rset2 = req2.execute('CWUser X WHERE X login "anon"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
141 |
self.failUnless(self.vreg['views'].select('propertiesform', req1, rset=None)) |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
142 |
self.failUnless(self.vreg['views'].select('propertiesform', req1, rset=rset1)) |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
143 |
self.failUnless(self.vreg['views'].select('propertiesform', req2, rset=rset2)) |
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
144 |
|
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
145 |
def test_propertiesform_anon(self): |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
146 |
self.login('anon') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
147 |
req1 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
148 |
req2 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
149 |
rset1 = req1.execute('CWUser X WHERE X login "admin"') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
150 |
rset2 = req2.execute('CWUser X WHERE X login "anon"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
151 |
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req1, rset=None) |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
152 |
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req1, rset=rset1) |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
153 |
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req1, rset=rset2) |
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
154 |
|
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
155 |
def test_propertiesform_jdoe(self): |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
156 |
self.create_user('jdoe') |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
157 |
self.login('jdoe') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
158 |
req1 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
159 |
req2 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
160 |
rset1 = req1.execute('CWUser X WHERE X login "admin"') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
161 |
rset2 = req2.execute('CWUser X WHERE X login "jdoe"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
162 |
self.failUnless(self.vreg['views'].select('propertiesform', req1, rset=None)) |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
163 |
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req1, rset=rset1) |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
164 |
self.failUnless(self.vreg['views'].select('propertiesform', req2, rset=rset2)) |
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
165 |
|
793 | 166 |
def test_possible_views_multiple_different_types(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
167 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
168 |
rset = req.execute('Any X') |
0 | 169 |
self.assertListEqual(self.pviews(req, rset), |
1654 | 170 |
[('csvexport', csvexport.CSVRsetView), |
171 |
('ecsvexport', csvexport.CSVEntityView), |
|
0 | 172 |
('editable-table', tableview.EditableTableView), |
444 | 173 |
('filetree', treeview.FileTreeView), |
0 | 174 |
('list', baseviews.ListView), |
175 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
176 |
('owlabox', owl.OWLABOXView), |
1654 | 177 |
('primary', primary.PrimaryView), |
178 |
('rsetxml', xmlrss.XMLRsetView), |
|
179 |
('rss', xmlrss.RSSView), |
|
0 | 180 |
('secondary', baseviews.SecondaryView), |
181 |
('security', management.SecurityManagementView), |
|
182 |
('table', tableview.TableView), |
|
183 |
('text', baseviews.TextView), |
|
444 | 184 |
('treeview', treeview.TreeView), |
0 | 185 |
('xbel', xbel.XbelView), |
1654 | 186 |
('xml', xmlrss.XMLView), |
0 | 187 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
188 |
|
793 | 189 |
def test_possible_views_any_rset(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
190 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
191 |
rset = req.execute('Any N, X WHERE X in_group Y, Y name N') |
0 | 192 |
self.assertListEqual(self.pviews(req, rset), |
1654 | 193 |
[('csvexport', csvexport.CSVRsetView), |
0 | 194 |
('editable-table', tableview.EditableTableView), |
1654 | 195 |
('rsetxml', xmlrss.XMLRsetView), |
0 | 196 |
('table', tableview.TableView), |
197 |
]) |
|
793 | 198 |
|
199 |
def test_possible_views_multiple_eusers(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
200 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
201 |
rset = req.execute('CWUser X') |
0 | 202 |
self.assertListEqual(self.pviews(req, rset), |
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
203 |
[('csvexport', csvexport.CSVRsetView), |
1654 | 204 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 205 |
('editable-table', tableview.EditableTableView), |
444 | 206 |
('filetree', treeview.FileTreeView), |
1654 | 207 |
('foaf', cwuser.FoafView), |
0 | 208 |
('list', baseviews.ListView), |
209 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
210 |
('owlabox', owl.OWLABOXView), |
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1654
diff
changeset
|
211 |
('primary', primary.PrimaryView), |
1654 | 212 |
('rsetxml', xmlrss.XMLRsetView), |
213 |
('rss', xmlrss.RSSView), |
|
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
214 |
('sameetypelist', baseviews.SameETypeListView), |
0 | 215 |
('secondary', baseviews.SecondaryView), |
216 |
('security', management.SecurityManagementView), |
|
217 |
('table', tableview.TableView), |
|
218 |
('text', baseviews.TextView), |
|
444 | 219 |
('treeview', treeview.TreeView), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
220 |
('vcard', vcard.VCardCWUserView), |
0 | 221 |
('xbel', xbel.XbelView), |
1654 | 222 |
('xml', xmlrss.XMLView), |
0 | 223 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
224 |
|
0 | 225 |
def test_possible_actions_none_rset(self): |
226 |
req = self.request() |
|
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
227 |
self.assertDictEqual(self.pactionsdict(req, None, skipcategories=()), |
0 | 228 |
{'useractions': USERACTIONS, |
229 |
'siteactions': SITEACTIONS, |
|
3587 | 230 |
'footer': FOOTERACTIONS, |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
231 |
|
0 | 232 |
}) |
233 |
def test_possible_actions_no_entity(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
234 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
235 |
rset = req.execute('Any X WHERE X eid 999999') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
236 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 237 |
{'useractions': USERACTIONS, |
238 |
'siteactions': SITEACTIONS, |
|
3587 | 239 |
'footer': FOOTERACTIONS, |
0 | 240 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
241 |
|
0 | 242 |
def test_possible_actions_same_type_entities(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
243 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
244 |
rset = req.execute('CWGroup X') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
245 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 246 |
{'useractions': USERACTIONS, |
247 |
'siteactions': SITEACTIONS, |
|
3587 | 248 |
'footer': FOOTERACTIONS, |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
249 |
'mainactions': [actions.MultipleEditAction], |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
250 |
'moreactions': [actions.DeleteAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
251 |
actions.AddNewAction], |
0 | 252 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
253 |
|
0 | 254 |
def test_possible_actions_different_types_entities(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
255 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
256 |
rset = req.execute('Any X') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
257 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 258 |
{'useractions': USERACTIONS, |
259 |
'siteactions': SITEACTIONS, |
|
3587 | 260 |
'footer': FOOTERACTIONS, |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
261 |
'moreactions': [actions.DeleteAction], |
0 | 262 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
263 |
|
0 | 264 |
def test_possible_actions_final_entities(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
265 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
266 |
rset = req.execute('Any N, X WHERE X in_group Y, Y name N') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
267 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 268 |
{'useractions': USERACTIONS, |
3587 | 269 |
'siteactions': SITEACTIONS, |
270 |
'footer': FOOTERACTIONS, |
|
271 |
}) |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
272 |
|
1654 | 273 |
def test_possible_actions_eetype_cwuser_entity(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
274 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
275 |
rset = req.execute('CWEType X WHERE X name "CWUser"') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
276 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 277 |
{'useractions': USERACTIONS, |
278 |
'siteactions': SITEACTIONS, |
|
3587 | 279 |
'footer': FOOTERACTIONS, |
4492
150f1d57ecfd
fix test broken by introduction of ViewSameEType action
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4491
diff
changeset
|
280 |
'mainactions': [actions.ModifyAction, |
150f1d57ecfd
fix test broken by introduction of ViewSameEType action
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4491
diff
changeset
|
281 |
actions.ViewSameCWEType], |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
282 |
'moreactions': [actions.ManagePermissionsAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
283 |
actions.AddRelatedActions, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
284 |
actions.DeleteAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
285 |
actions.CopyAction, |
1654 | 286 |
], |
0 | 287 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
288 |
|
0 | 289 |
|
290 |
def test_select_creation_form(self): |
|
291 |
rset = None |
|
292 |
req = self.request() |
|
293 |
# creation form |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
294 |
req.form['etype'] = 'CWGroup' |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
295 |
self.assertIsInstance(self.vreg['views'].select('creation', req, rset=rset), |
1654 | 296 |
editforms.CreationFormView) |
0 | 297 |
del req.form['etype'] |
298 |
# custom creation form |
|
1654 | 299 |
class CWUserCreationForm(editforms.CreationFormView): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
300 |
__select__ = specified_etype_implements('CWUser') |
1654 | 301 |
self.vreg._loadedmods[__name__] = {} |
4491
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4182
diff
changeset
|
302 |
self.vreg.register(CWUserCreationForm) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
303 |
req.form['etype'] = 'CWUser' |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
304 |
self.assertIsInstance(self.vreg['views'].select('creation', req, rset=rset), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
305 |
CWUserCreationForm) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
306 |
|
0 | 307 |
def test_select_view(self): |
308 |
# no entity |
|
309 |
rset = None |
|
310 |
req = self.request() |
|
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
311 |
self.assertIsInstance(self.vreg['views'].select('index', req, rset=rset), |
0 | 312 |
startup.IndexView) |
313 |
self.failUnlessRaises(NoSelectableObject, |
|
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
314 |
self.vreg['views'].select, 'primary', req, rset=rset) |
0 | 315 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
316 |
self.vreg['views'].select, 'table', req, rset=rset) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
317 |
|
0 | 318 |
# no entity |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
319 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
320 |
rset = req.execute('Any X WHERE X eid 999999') |
0 | 321 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
322 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 323 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
324 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 325 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
326 |
self.vreg['views'].select, 'primary', req, rset=rset) |
0 | 327 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
328 |
self.vreg['views'].select, 'table', req, rset=rset) |
0 | 329 |
# one entity |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
330 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
331 |
rset = req.execute('CWGroup X WHERE X name "managers"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
332 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
1654 | 333 |
primary.PrimaryView) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
334 |
self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset), |
0 | 335 |
baseviews.ListView) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
336 |
self.assertIsInstance(self.vreg['views'].select('edition', req, rset=rset), |
1654 | 337 |
editforms.EditionFormView) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
338 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 339 |
tableview.TableView) |
340 |
self.failUnlessRaises(NoSelectableObject, |
|
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
341 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 342 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
343 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 344 |
# list of entities of the same type |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
345 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
346 |
rset = req.execute('CWGroup X') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
347 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
1654 | 348 |
primary.PrimaryView) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
349 |
self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset), |
0 | 350 |
baseviews.ListView) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
351 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 352 |
tableview.TableView) |
353 |
self.failUnlessRaises(NoSelectableObject, |
|
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
354 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 355 |
# list of entities of different types |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
356 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
357 |
rset = req.execute('Any X') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
358 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
1654 | 359 |
primary.PrimaryView) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
360 |
self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset), |
0 | 361 |
baseviews.ListView) |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
362 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 363 |
tableview.TableView) |
364 |
self.failUnlessRaises(NoSelectableObject, |
|
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
365 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 366 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
367 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 368 |
# whatever |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
369 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
370 |
rset = req.execute('Any N, X WHERE X in_group Y, Y name N') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
371 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 372 |
tableview.TableView) |
373 |
self.failUnlessRaises(NoSelectableObject, |
|
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
374 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 375 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
376 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 377 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
378 |
self.vreg['views'].select, 'primary', req, rset=rset) |
0 | 379 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
380 |
self.vreg['views'].select, 'list', req, rset=rset) |
0 | 381 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
382 |
self.vreg['views'].select, 'edition', req, rset=rset) |
0 | 383 |
# mixed query |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
384 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
385 |
rset = req.execute('Any U,G WHERE U is CWUser, G is CWGroup') |
0 | 386 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
387 |
self.vreg['views'].select, 'edition', req, rset=rset) |
0 | 388 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
389 |
self.vreg['views'].select, 'creation', req, rset=rset) |
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
390 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 391 |
tableview.TableView) |
392 |
||
393 |
def test_interface_selector(self): |
|
4078 | 394 |
image = self.request().create_entity('Image', data_name=u'bim.png', data=Binary('bim')) |
0 | 395 |
# image primary view priority |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
396 |
req = self.request() |
3589 | 397 |
rset = req.execute('Image X WHERE X data_name "bim.png"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
398 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
0 | 399 |
idownloadable.IDownloadablePrimaryView) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
400 |
|
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
401 |
|
0 | 402 |
def test_score_entity_selector(self): |
4078 | 403 |
image = self.request().create_entity('Image', data_name=u'bim.png', data=Binary('bim')) |
0 | 404 |
# image primary view priority |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
405 |
req = self.request() |
3589 | 406 |
rset = req.execute('Image X WHERE X data_name "bim.png"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
407 |
self.assertIsInstance(self.vreg['views'].select('image', req, rset=rset), |
0 | 408 |
idownloadable.ImageView) |
4078 | 409 |
fileobj = self.request().create_entity('File', data_name=u'bim.txt', data=Binary('bim')) |
0 | 410 |
# image primary view priority |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
411 |
req = self.request() |
3589 | 412 |
rset = req.execute('File X WHERE X data_name "bim.txt"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
413 |
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'image', req, rset=rset) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
414 |
|
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
415 |
|
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
416 |
|
0 | 417 |
def _test_view(self, vid, rql, args): |
418 |
if rql is None: |
|
419 |
rset = None |
|
420 |
req = self.request() |
|
421 |
else: |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
422 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
423 |
rset = req.execute(rql) |
0 | 424 |
try: |
4182 | 425 |
obj = self.vreg['views'].select(vid, req, rset=rset, **args) |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4078
diff
changeset
|
426 |
return obj.render(**args) |
0 | 427 |
except: |
428 |
print vid, rset, args |
|
429 |
raise |
|
430 |
||
431 |
def test_form(self): |
|
432 |
for vid, rql, args in ( |
|
433 |
#('creation', 'Any X WHERE X eid 999999', {}), |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
434 |
('edition', 'CWGroup X WHERE X name "managers"', {}), |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
435 |
('copy', 'CWGroup X WHERE X name "managers"', {}), |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
436 |
('muledit', 'CWGroup X', {}), |
0 | 437 |
#('muledit', 'Any X', {}), |
438 |
): |
|
439 |
self._test_view(vid, rql, args) |
|
440 |
||
441 |
||
442 |
def test_properties(self): |
|
443 |
self.assertEquals(sorted(k for k in self.vreg['propertydefs'].keys() |
|
444 |
if k.startswith('boxes.edit_box')), |
|
445 |
['boxes.edit_box.context', |
|
446 |
'boxes.edit_box.order', |
|
447 |
'boxes.edit_box.visible']) |
|
448 |
self.assertEquals([k for k in self.vreg['propertyvalues'].keys() |
|
449 |
if not k.startswith('system.version')], |
|
450 |
[]) |
|
451 |
self.assertEquals(self.vreg.property_value('boxes.edit_box.visible'), True) |
|
452 |
self.assertEquals(self.vreg.property_value('boxes.edit_box.order'), 2) |
|
453 |
self.assertEquals(self.vreg.property_value('boxes.possible_views_box.visible'), False) |
|
454 |
self.assertEquals(self.vreg.property_value('boxes.possible_views_box.order'), 10) |
|
4493
c0a43c6ba777
now raise UnknownProperty, not KeyError
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4492
diff
changeset
|
455 |
self.assertRaises(UnknownProperty, self.vreg.property_value, 'boxes.actions_box') |
0 | 456 |
|
457 |
||
458 |
||
459 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
460 |
class CWETypeRQLAction(Action): |
3408
c92170fca813
[api] use __regid__ instead of deprecated id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
461 |
__regid__ = 'testaction' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
462 |
__select__ = implements('CWEType') & rql_condition('X name "CWEType"') |
0 | 463 |
title = 'bla' |
464 |
||
465 |
class RQLActionTC(ViewSelectorTC): |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
466 |
|
0 | 467 |
def setUp(self): |
468 |
super(RQLActionTC, self).setUp() |
|
1654 | 469 |
self.vreg._loadedmods[__name__] = {} |
4491
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4182
diff
changeset
|
470 |
self.vreg.register(CWETypeRQLAction) |
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4182
diff
changeset
|
471 |
actionsreg = self.vreg['actions'] |
4534 | 472 |
actionsreg['testaction'][0].__registered__(actionsreg) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
473 |
|
0 | 474 |
def tearDown(self): |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
475 |
super(RQLActionTC, self).tearDown() |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
476 |
del self.vreg['actions']['testaction'] |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
477 |
|
0 | 478 |
def test(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
479 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
480 |
rset = req.execute('CWEType X WHERE X name "CWEType"') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
481 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 482 |
{'useractions': USERACTIONS, |
483 |
'siteactions': SITEACTIONS, |
|
3587 | 484 |
'footer': FOOTERACTIONS, |
4492
150f1d57ecfd
fix test broken by introduction of ViewSameEType action
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4491
diff
changeset
|
485 |
'mainactions': [actions.ModifyAction, actions.ViewSameCWEType], |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
486 |
'moreactions': [actions.ManagePermissionsAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
487 |
actions.AddRelatedActions, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
488 |
actions.DeleteAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
489 |
actions.CopyAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
490 |
CWETypeRQLAction, |
1654 | 491 |
], |
0 | 492 |
}) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
493 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
494 |
rset = req.execute('CWEType X WHERE X name "CWRType"') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
495 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 496 |
{'useractions': USERACTIONS, |
497 |
'siteactions': SITEACTIONS, |
|
3587 | 498 |
'footer': FOOTERACTIONS, |
4492
150f1d57ecfd
fix test broken by introduction of ViewSameEType action
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4491
diff
changeset
|
499 |
'mainactions': [actions.ModifyAction, actions.ViewSameCWEType], |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
500 |
'moreactions': [actions.ManagePermissionsAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
501 |
actions.AddRelatedActions, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
502 |
actions.DeleteAction, |
3735 | 503 |
actions.CopyAction,] |
0 | 504 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
505 |
|
0 | 506 |
|
507 |
||
508 |
if __name__ == '__main__': |
|
509 |
unittest_main() |