author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 27 Jan 2010 09:56:58 +0100 | |
changeset 4389 | 14a993bc8d1e |
parent 4182 | b7cf0ebdd8b6 |
child 4491 | a0f48c31b58a |
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 |
0 | 8 |
from cubicweb import CW_SOFTWARE_ROOT as BASE, Binary |
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 |
('debug', debug.DebugView), |
|
71 |
('index', startup.IndexView), |
|
72 |
('info', management.ProcessInformationView), |
|
73 |
('manage', startup.ManageView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
74 |
('owl', owl.OWLView), |
1900
8dd4bb69c73d
[tests] fix test after eproperties got renamed to cwproperties
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1797
diff
changeset
|
75 |
('propertiesform', cwproperties.CWPropertiesForm), |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
76 |
('registry', debug.RegistryView), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
77 |
('schema', schema.SchemaView), |
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
78 |
('systempropertiesform', cwproperties.SystemCWPropertiesForm), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
79 |
('tree', folderviews.FolderTreeView), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
80 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
81 |
|
793 | 82 |
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
|
83 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
84 |
rset = req.execute('Any X WHERE X eid 999999') |
0 | 85 |
self.assertListEqual(self.pviews(req, rset), |
783 | 86 |
[]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
87 |
|
793 | 88 |
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
|
89 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
90 |
rset = req.execute('CWGroup X WHERE X name "managers"') |
0 | 91 |
self.assertListEqual(self.pviews(req, rset), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
92 |
[('adaptedlist', baseviews.AdaptedListView), |
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
93 |
('csvexport', csvexport.CSVRsetView), |
1654 | 94 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 95 |
('editable-table', tableview.EditableTableView), |
444 | 96 |
('filetree', treeview.FileTreeView), |
0 | 97 |
('list', baseviews.ListView), |
98 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
99 |
('owlabox', owl.OWLABOXView), |
1654 | 100 |
('primary', primary.PrimaryView), |
101 |
('rsetxml', xmlrss.XMLRsetView), |
|
102 |
('rss', xmlrss.RSSView), |
|
0 | 103 |
('secondary', baseviews.SecondaryView), |
104 |
('security', management.SecurityManagementView), |
|
105 |
('table', tableview.TableView), |
|
106 |
('text', baseviews.TextView), |
|
444 | 107 |
('treeview', treeview.TreeView), |
0 | 108 |
('xbel', xbel.XbelView), |
1654 | 109 |
('xml', xmlrss.XMLView), |
0 | 110 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
111 |
|
793 | 112 |
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
|
113 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
114 |
rset = req.execute('CWGroup X') |
0 | 115 |
self.assertListEqual(self.pviews(req, rset), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
116 |
[('adaptedlist', baseviews.AdaptedListView), |
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
117 |
('csvexport', csvexport.CSVRsetView), |
1654 | 118 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 119 |
('editable-table', tableview.EditableTableView), |
444 | 120 |
('filetree', treeview.FileTreeView), |
0 | 121 |
('list', baseviews.ListView), |
122 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
123 |
('owlabox', owl.OWLABOXView), |
1654 | 124 |
('primary', primary.PrimaryView), |
125 |
('rsetxml', xmlrss.XMLRsetView), |
|
126 |
('rss', xmlrss.RSSView), |
|
0 | 127 |
('secondary', baseviews.SecondaryView), |
128 |
('security', management.SecurityManagementView), |
|
129 |
('table', tableview.TableView), |
|
130 |
('text', baseviews.TextView), |
|
444 | 131 |
('treeview', treeview.TreeView), |
0 | 132 |
('xbel', xbel.XbelView), |
1654 | 133 |
('xml', xmlrss.XMLView), |
0 | 134 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
135 |
|
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
136 |
def test_propertiesform_admin(self): |
2403
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
137 |
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
|
138 |
req1 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
139 |
req2 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
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
|
144 |
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
|
145 |
|
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
146 |
def test_propertiesform_anon(self): |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
147 |
self.login('anon') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
148 |
req1 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
149 |
req2 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
150 |
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
|
151 |
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
|
152 |
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
|
153 |
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
|
154 |
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
|
155 |
|
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
156 |
def test_propertiesform_jdoe(self): |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
157 |
self.create_user('jdoe') |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
158 |
self.login('jdoe') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
159 |
req1 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
160 |
req2 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
161 |
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
|
162 |
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
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
|
793 | 167 |
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
|
168 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
169 |
rset = req.execute('Any X') |
0 | 170 |
self.assertListEqual(self.pviews(req, rset), |
1654 | 171 |
[('csvexport', csvexport.CSVRsetView), |
172 |
('ecsvexport', csvexport.CSVEntityView), |
|
0 | 173 |
('editable-table', tableview.EditableTableView), |
444 | 174 |
('filetree', treeview.FileTreeView), |
0 | 175 |
('list', baseviews.ListView), |
176 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
177 |
('owlabox', owl.OWLABOXView), |
1654 | 178 |
('primary', primary.PrimaryView), |
179 |
('rsetxml', xmlrss.XMLRsetView), |
|
180 |
('rss', xmlrss.RSSView), |
|
0 | 181 |
('secondary', baseviews.SecondaryView), |
182 |
('security', management.SecurityManagementView), |
|
183 |
('table', tableview.TableView), |
|
184 |
('text', baseviews.TextView), |
|
444 | 185 |
('treeview', treeview.TreeView), |
0 | 186 |
('xbel', xbel.XbelView), |
1654 | 187 |
('xml', xmlrss.XMLView), |
0 | 188 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
189 |
|
793 | 190 |
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
|
191 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
192 |
rset = req.execute('Any N, X WHERE X in_group Y, Y name N') |
0 | 193 |
self.assertListEqual(self.pviews(req, rset), |
1654 | 194 |
[('csvexport', csvexport.CSVRsetView), |
0 | 195 |
('editable-table', tableview.EditableTableView), |
1654 | 196 |
('rsetxml', xmlrss.XMLRsetView), |
0 | 197 |
('table', tableview.TableView), |
198 |
]) |
|
793 | 199 |
|
200 |
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
|
201 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
202 |
rset = req.execute('CWUser X') |
0 | 203 |
self.assertListEqual(self.pviews(req, rset), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
204 |
[('adaptedlist', baseviews.AdaptedListView), |
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
205 |
('csvexport', csvexport.CSVRsetView), |
1654 | 206 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 207 |
('editable-table', tableview.EditableTableView), |
444 | 208 |
('filetree', treeview.FileTreeView), |
1654 | 209 |
('foaf', cwuser.FoafView), |
0 | 210 |
('list', baseviews.ListView), |
211 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
212 |
('owlabox', owl.OWLABOXView), |
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1654
diff
changeset
|
213 |
('primary', primary.PrimaryView), |
1654 | 214 |
('rsetxml', xmlrss.XMLRsetView), |
215 |
('rss', xmlrss.RSSView), |
|
0 | 216 |
('secondary', baseviews.SecondaryView), |
217 |
('security', management.SecurityManagementView), |
|
218 |
('table', tableview.TableView), |
|
219 |
('text', baseviews.TextView), |
|
444 | 220 |
('treeview', treeview.TreeView), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
221 |
('vcard', vcard.VCardCWUserView), |
0 | 222 |
('xbel', xbel.XbelView), |
1654 | 223 |
('xml', xmlrss.XMLView), |
0 | 224 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
225 |
|
0 | 226 |
def test_possible_actions_none_rset(self): |
227 |
req = self.request() |
|
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
228 |
self.assertDictEqual(self.pactionsdict(req, None, skipcategories=()), |
0 | 229 |
{'useractions': USERACTIONS, |
230 |
'siteactions': SITEACTIONS, |
|
3587 | 231 |
'footer': FOOTERACTIONS, |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
232 |
|
0 | 233 |
}) |
234 |
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
|
235 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
236 |
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
|
237 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 238 |
{'useractions': USERACTIONS, |
239 |
'siteactions': SITEACTIONS, |
|
3587 | 240 |
'footer': FOOTERACTIONS, |
0 | 241 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
242 |
|
0 | 243 |
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
|
244 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
245 |
rset = req.execute('CWGroup X') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
246 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 247 |
{'useractions': USERACTIONS, |
248 |
'siteactions': SITEACTIONS, |
|
3587 | 249 |
'footer': FOOTERACTIONS, |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
250 |
'mainactions': [actions.MultipleEditAction], |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
251 |
'moreactions': [actions.DeleteAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
252 |
actions.AddNewAction], |
0 | 253 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
254 |
|
0 | 255 |
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
|
256 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
257 |
rset = req.execute('Any X') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
258 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 259 |
{'useractions': USERACTIONS, |
260 |
'siteactions': SITEACTIONS, |
|
3587 | 261 |
'footer': FOOTERACTIONS, |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
262 |
'moreactions': [actions.DeleteAction], |
0 | 263 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
264 |
|
0 | 265 |
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
|
266 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
267 |
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
|
268 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 269 |
{'useractions': USERACTIONS, |
3587 | 270 |
'siteactions': SITEACTIONS, |
271 |
'footer': FOOTERACTIONS, |
|
272 |
}) |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
273 |
|
1654 | 274 |
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
|
275 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
276 |
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
|
277 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 278 |
{'useractions': USERACTIONS, |
279 |
'siteactions': SITEACTIONS, |
|
3587 | 280 |
'footer': FOOTERACTIONS, |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
281 |
'mainactions': [actions.ModifyAction], |
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__] = {} |
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
302 |
self.vreg.register_appobject_class(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) |
|
455 |
self.assertRaises(KeyError, self.vreg.property_value, 'boxes.actions_box') |
|
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__] = {} |
2657
de974465d381
[appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2650
diff
changeset
|
470 |
self.vreg.register_appobject_class(CWETypeRQLAction) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
471 |
|
0 | 472 |
def tearDown(self): |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
473 |
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
|
474 |
del self.vreg['actions']['testaction'] |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
475 |
|
0 | 476 |
def test(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
477 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
478 |
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
|
479 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 480 |
{'useractions': USERACTIONS, |
481 |
'siteactions': SITEACTIONS, |
|
3587 | 482 |
'footer': FOOTERACTIONS, |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
483 |
'mainactions': [actions.ModifyAction], |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
484 |
'moreactions': [actions.ManagePermissionsAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
485 |
actions.AddRelatedActions, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
486 |
actions.DeleteAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
487 |
actions.CopyAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
488 |
CWETypeRQLAction, |
1654 | 489 |
], |
0 | 490 |
}) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
491 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
492 |
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
|
493 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 494 |
{'useractions': USERACTIONS, |
495 |
'siteactions': SITEACTIONS, |
|
3587 | 496 |
'footer': FOOTERACTIONS, |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
497 |
'mainactions': [actions.ModifyAction], |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
498 |
'moreactions': [actions.ManagePermissionsAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
499 |
actions.AddRelatedActions, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
500 |
actions.DeleteAction, |
3735 | 501 |
actions.CopyAction,] |
0 | 502 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
503 |
|
0 | 504 |
|
505 |
||
506 |
if __name__ == '__main__': |
|
507 |
unittest_main() |