author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Wed, 21 Oct 2009 14:31:15 +0200 | |
branch | stable |
changeset 3771 | 234b003f0fe0 |
parent 3587 | 5b3725f315fc |
child 3589 | a5432f99f2d9 |
child 3898 | 90926f3a8ada |
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 |
|
0 | 7 |
from cubicweb.devtools.apptest import EnvBasedTC |
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 |
|
0 | 22 |
USERACTIONS = [('myprefs', actions.UserPreferencesAction), |
23 |
('myinfos', actions.UserInfoAction), |
|
24 |
('logout', actions.LogoutAction)] |
|
25 |
SITEACTIONS = [('siteconfig', actions.SiteConfigurationAction), |
|
26 |
('manage', actions.ManageAction), |
|
2439
77d8dd77acb3
[cleanup] fix tests
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2058
diff
changeset
|
27 |
('schema', schema.ViewSchemaAction), |
77d8dd77acb3
[cleanup] fix tests
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2058
diff
changeset
|
28 |
('siteinfo', actions.SiteInfoAction), |
77d8dd77acb3
[cleanup] fix tests
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2058
diff
changeset
|
29 |
] |
3587 | 30 |
FOOTERACTIONS = [('changelog', wdoc.ChangeLogAction), |
31 |
('about', wdoc.AboutAction), |
|
32 |
('poweredby', actions.PoweredByAction)] |
|
0 | 33 |
|
34 |
class ViewSelectorTC(EnvBasedTC): |
|
35 |
||
36 |
def setup_database(self): |
|
37 |
self.add_entity('BlogEntry', title=u"une news !", content=u"cubicweb c'est beau") |
|
38 |
self.add_entity('Bookmark', title=u"un signet !", path=u"view?vid=index") |
|
39 |
self.add_entity('EmailAddress', address=u"devel@logilab.fr", alias=u'devel') |
|
40 |
self.add_entity('Tag', name=u'x') |
|
41 |
||
42 |
def pactions(self, req, rset): |
|
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
|
43 |
resdict = self.vreg['actions'].possible_actions(req, rset) |
0 | 44 |
for cat, actions in resdict.items(): |
45 |
resdict[cat] = [(a.id, a.__class__) for a in actions] |
|
46 |
return resdict |
|
47 |
||
48 |
||
49 |
class VRegistryTC(ViewSelectorTC): |
|
50 |
"""test the view selector""" |
|
51 |
||
52 |
def _test_registered(self, registry, content): |
|
53 |
try: |
|
54 |
expected = getattr(self, 'all_%s' % registry) |
|
55 |
except AttributeError: |
|
56 |
return |
|
57 |
if registry == 'hooks': |
|
58 |
self.assertEquals(len(content), expected, content) |
|
59 |
return |
|
60 |
try: |
|
61 |
self.assertSetEqual(content.keys(), expected) |
|
62 |
except: |
|
63 |
print registry, sorted(expected), sorted(content.keys()) |
|
64 |
print 'no more', [v for v in expected if not v in content.keys()] |
|
65 |
print 'missing', [v for v in content.keys() if not v in expected] |
|
66 |
raise |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
67 |
|
2403
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
68 |
def setUp(self): |
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
69 |
super(VRegistryTC, self).setUp() |
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
70 |
assert self.vreg['views']['propertiesform'] |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
71 |
|
793 | 72 |
def test_possible_views_none_rset(self): |
0 | 73 |
req = self.request() |
74 |
self.assertListEqual(self.pviews(req, None), |
|
75 |
[('changelog', wdoc.ChangeLogView), |
|
76 |
('debug', debug.DebugView), |
|
77 |
('index', startup.IndexView), |
|
78 |
('info', management.ProcessInformationView), |
|
79 |
('manage', startup.ManageView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
80 |
('owl', owl.OWLView), |
1900
8dd4bb69c73d
[tests] fix test after eproperties got renamed to cwproperties
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1797
diff
changeset
|
81 |
('propertiesform', cwproperties.CWPropertiesForm), |
2780
ad1dfc3855b0
B web/tests back to green
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2657
diff
changeset
|
82 |
('registry', startup.RegistryView), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
83 |
('schema', schema.SchemaView), |
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
84 |
('systempropertiesform', cwproperties.SystemCWPropertiesForm), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
85 |
('tree', folderviews.FolderTreeView), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
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_noresult(self): |
0 | 89 |
rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999') |
90 |
self.assertListEqual(self.pviews(req, rset), |
|
783 | 91 |
[]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
92 |
|
793 | 93 |
def test_possible_views_one_egroup(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
94 |
rset, req = self.env.get_rset_and_req('CWGroup X WHERE X name "managers"') |
0 | 95 |
self.assertListEqual(self.pviews(req, rset), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
96 |
[('adaptedlist', baseviews.AdaptedListView), |
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
97 |
('csvexport', csvexport.CSVRsetView), |
1654 | 98 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 99 |
('editable-table', tableview.EditableTableView), |
444 | 100 |
('filetree', treeview.FileTreeView), |
0 | 101 |
('list', baseviews.ListView), |
102 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
103 |
('owlabox', owl.OWLABOXView), |
1654 | 104 |
('primary', primary.PrimaryView), |
105 |
('rsetxml', xmlrss.XMLRsetView), |
|
106 |
('rss', xmlrss.RSSView), |
|
0 | 107 |
('secondary', baseviews.SecondaryView), |
108 |
('security', management.SecurityManagementView), |
|
109 |
('table', tableview.TableView), |
|
110 |
('text', baseviews.TextView), |
|
444 | 111 |
('treeview', treeview.TreeView), |
0 | 112 |
('xbel', xbel.XbelView), |
1654 | 113 |
('xml', xmlrss.XMLView), |
0 | 114 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
115 |
|
793 | 116 |
def test_possible_views_multiple_egroups(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
117 |
rset, req = self.env.get_rset_and_req('CWGroup X') |
0 | 118 |
self.assertListEqual(self.pviews(req, rset), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
119 |
[('adaptedlist', baseviews.AdaptedListView), |
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
120 |
('csvexport', csvexport.CSVRsetView), |
1654 | 121 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 122 |
('editable-table', tableview.EditableTableView), |
444 | 123 |
('filetree', treeview.FileTreeView), |
0 | 124 |
('list', baseviews.ListView), |
125 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
126 |
('owlabox', owl.OWLABOXView), |
1654 | 127 |
('primary', primary.PrimaryView), |
128 |
('rsetxml', xmlrss.XMLRsetView), |
|
129 |
('rss', xmlrss.RSSView), |
|
0 | 130 |
('secondary', baseviews.SecondaryView), |
131 |
('security', management.SecurityManagementView), |
|
132 |
('table', tableview.TableView), |
|
133 |
('text', baseviews.TextView), |
|
444 | 134 |
('treeview', treeview.TreeView), |
0 | 135 |
('xbel', xbel.XbelView), |
1654 | 136 |
('xml', xmlrss.XMLView), |
0 | 137 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
138 |
|
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
139 |
def test_propertiesform_admin(self): |
2403
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
140 |
assert self.vreg['views']['propertiesform'] |
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
141 |
rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"') |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
142 |
rset2, req2 = self.env.get_rset_and_req('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
|
143 |
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
|
144 |
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
|
145 |
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
|
146 |
|
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
147 |
def test_propertiesform_anon(self): |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
148 |
self.login('anon') |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
149 |
rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"') |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
150 |
rset2, req2 = self.env.get_rset_and_req('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') |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
158 |
rset1, req1 = self.env.get_rset_and_req('CWUser X WHERE X login "admin"') |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
159 |
rset2, req2 = self.env.get_rset_and_req('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
|
160 |
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
|
161 |
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
|
162 |
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
|
163 |
|
793 | 164 |
def test_possible_views_multiple_different_types(self): |
0 | 165 |
rset, req = self.env.get_rset_and_req('Any X') |
166 |
self.assertListEqual(self.pviews(req, rset), |
|
1654 | 167 |
[('csvexport', csvexport.CSVRsetView), |
168 |
('ecsvexport', csvexport.CSVEntityView), |
|
0 | 169 |
('editable-table', tableview.EditableTableView), |
444 | 170 |
('filetree', treeview.FileTreeView), |
0 | 171 |
('list', baseviews.ListView), |
172 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
173 |
('owlabox', owl.OWLABOXView), |
1654 | 174 |
('primary', primary.PrimaryView), |
175 |
('rsetxml', xmlrss.XMLRsetView), |
|
176 |
('rss', xmlrss.RSSView), |
|
0 | 177 |
('secondary', baseviews.SecondaryView), |
178 |
('security', management.SecurityManagementView), |
|
179 |
('table', tableview.TableView), |
|
180 |
('text', baseviews.TextView), |
|
444 | 181 |
('treeview', treeview.TreeView), |
0 | 182 |
('xbel', xbel.XbelView), |
1654 | 183 |
('xml', xmlrss.XMLView), |
0 | 184 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
185 |
|
793 | 186 |
def test_possible_views_any_rset(self): |
0 | 187 |
rset, req = self.env.get_rset_and_req('Any N, X WHERE X in_group Y, Y name N') |
188 |
self.assertListEqual(self.pviews(req, rset), |
|
1654 | 189 |
[('csvexport', csvexport.CSVRsetView), |
0 | 190 |
('editable-table', tableview.EditableTableView), |
1654 | 191 |
('rsetxml', xmlrss.XMLRsetView), |
0 | 192 |
('table', tableview.TableView), |
193 |
]) |
|
793 | 194 |
|
195 |
def test_possible_views_multiple_eusers(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
196 |
rset, req = self.env.get_rset_and_req('CWUser X') |
0 | 197 |
self.assertListEqual(self.pviews(req, rset), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
198 |
[('adaptedlist', baseviews.AdaptedListView), |
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
199 |
('csvexport', csvexport.CSVRsetView), |
1654 | 200 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 201 |
('editable-table', tableview.EditableTableView), |
444 | 202 |
('filetree', treeview.FileTreeView), |
1654 | 203 |
('foaf', cwuser.FoafView), |
0 | 204 |
('list', baseviews.ListView), |
205 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
206 |
('owlabox', owl.OWLABOXView), |
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1654
diff
changeset
|
207 |
('primary', primary.PrimaryView), |
1654 | 208 |
('rsetxml', xmlrss.XMLRsetView), |
209 |
('rss', xmlrss.RSSView), |
|
0 | 210 |
('secondary', baseviews.SecondaryView), |
211 |
('security', management.SecurityManagementView), |
|
212 |
('table', tableview.TableView), |
|
213 |
('text', baseviews.TextView), |
|
444 | 214 |
('treeview', treeview.TreeView), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
215 |
('vcard', vcard.VCardCWUserView), |
2440
8e6b83e3b6b5
#343227: display the workflow history of any entity
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2439
diff
changeset
|
216 |
('wfhistory', workflow.WFHistoryView), |
0 | 217 |
('xbel', xbel.XbelView), |
1654 | 218 |
('xml', xmlrss.XMLView), |
0 | 219 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
220 |
|
0 | 221 |
def test_possible_actions_none_rset(self): |
222 |
req = self.request() |
|
223 |
self.assertDictEqual(self.pactions(req, None), |
|
224 |
{'useractions': USERACTIONS, |
|
225 |
'siteactions': SITEACTIONS, |
|
3587 | 226 |
'footer': FOOTERACTIONS, |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
227 |
|
0 | 228 |
}) |
229 |
def test_possible_actions_no_entity(self): |
|
230 |
rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999') |
|
231 |
self.assertDictEqual(self.pactions(req, rset), |
|
232 |
{'useractions': USERACTIONS, |
|
233 |
'siteactions': SITEACTIONS, |
|
3587 | 234 |
'footer': FOOTERACTIONS, |
0 | 235 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
236 |
|
0 | 237 |
def test_possible_actions_same_type_entities(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
238 |
rset, req = self.env.get_rset_and_req('CWGroup X') |
0 | 239 |
self.assertDictEqual(self.pactions(req, rset), |
240 |
{'useractions': USERACTIONS, |
|
241 |
'siteactions': SITEACTIONS, |
|
3587 | 242 |
'footer': FOOTERACTIONS, |
0 | 243 |
'mainactions': [('muledit', actions.MultipleEditAction)], |
244 |
'moreactions': [('delete', actions.DeleteAction), |
|
245 |
('addentity', actions.AddNewAction)], |
|
246 |
}) |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
247 |
|
0 | 248 |
def test_possible_actions_different_types_entities(self): |
249 |
rset, req = self.env.get_rset_and_req('Any X') |
|
250 |
self.assertDictEqual(self.pactions(req, rset), |
|
251 |
{'useractions': USERACTIONS, |
|
252 |
'siteactions': SITEACTIONS, |
|
3587 | 253 |
'footer': FOOTERACTIONS, |
0 | 254 |
'moreactions': [('delete', actions.DeleteAction)], |
255 |
}) |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
256 |
|
0 | 257 |
def test_possible_actions_final_entities(self): |
258 |
rset, req = self.env.get_rset_and_req('Any N, X WHERE X in_group Y, Y name N') |
|
259 |
self.assertDictEqual(self.pactions(req, rset), |
|
260 |
{'useractions': USERACTIONS, |
|
3587 | 261 |
'siteactions': SITEACTIONS, |
262 |
'footer': FOOTERACTIONS, |
|
263 |
}) |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
264 |
|
1654 | 265 |
def test_possible_actions_eetype_cwuser_entity(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
266 |
rset, req = self.env.get_rset_and_req('CWEType X WHERE X name "CWUser"') |
0 | 267 |
self.assertDictEqual(self.pactions(req, rset), |
268 |
{'useractions': USERACTIONS, |
|
269 |
'siteactions': SITEACTIONS, |
|
3587 | 270 |
'footer': FOOTERACTIONS, |
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
271 |
'mainactions': [('edit', actions.ModifyAction)], |
1654 | 272 |
'moreactions': [('managepermission', actions.ManagePermissionsAction), |
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
273 |
('addrelated', actions.AddRelatedActions), |
1654 | 274 |
('delete', actions.DeleteAction), |
793 | 275 |
('copy', actions.CopyAction), |
1654 | 276 |
], |
0 | 277 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
278 |
|
0 | 279 |
|
280 |
def test_select_creation_form(self): |
|
281 |
rset = None |
|
282 |
req = self.request() |
|
283 |
# creation form |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
284 |
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
|
285 |
self.assertIsInstance(self.vreg['views'].select('creation', req, rset=rset), |
1654 | 286 |
editforms.CreationFormView) |
0 | 287 |
del req.form['etype'] |
288 |
# custom creation form |
|
1654 | 289 |
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
|
290 |
__select__ = specified_etype_implements('CWUser') |
1654 | 291 |
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
|
292 |
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
|
293 |
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
|
294 |
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
|
295 |
CWUserCreationForm) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
296 |
|
0 | 297 |
def test_select_view(self): |
298 |
# no entity |
|
299 |
rset = None |
|
300 |
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
|
301 |
self.assertIsInstance(self.vreg['views'].select('index', req, rset=rset), |
0 | 302 |
startup.IndexView) |
303 |
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
|
304 |
self.vreg['views'].select, 'primary', req, rset=rset) |
0 | 305 |
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
|
306 |
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
|
307 |
|
0 | 308 |
# no entity |
309 |
rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999') |
|
310 |
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
|
311 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 312 |
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
|
313 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 314 |
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
|
315 |
self.vreg['views'].select, 'primary', req, rset=rset) |
0 | 316 |
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
|
317 |
self.vreg['views'].select, 'table', req, rset=rset) |
0 | 318 |
# one entity |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
319 |
rset, req = self.env.get_rset_and_req('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
|
320 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
1654 | 321 |
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
|
322 |
self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset), |
0 | 323 |
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
|
324 |
self.assertIsInstance(self.vreg['views'].select('edition', req, rset=rset), |
1654 | 325 |
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
|
326 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 327 |
tableview.TableView) |
328 |
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
|
329 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 330 |
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
|
331 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 332 |
# list of entities of the same type |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
333 |
rset, req = self.env.get_rset_and_req('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
|
334 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
1654 | 335 |
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
|
336 |
self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset), |
0 | 337 |
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
|
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 |
# list of entities of different types |
343 |
rset, req = self.env.get_rset_and_req('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
|
344 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
1654 | 345 |
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
|
346 |
self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset), |
0 | 347 |
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
|
348 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 349 |
tableview.TableView) |
350 |
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
|
351 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 352 |
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
|
353 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 354 |
# whatever |
355 |
rset, req = self.env.get_rset_and_req('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
|
356 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 357 |
tableview.TableView) |
358 |
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
|
359 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 360 |
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
|
361 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 362 |
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
|
363 |
self.vreg['views'].select, 'primary', req, rset=rset) |
0 | 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, 'list', 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, 'edition', req, rset=rset) |
0 | 368 |
# mixed query |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
369 |
rset, req = self.env.get_rset_and_req('Any U,G WHERE U is CWUser, G is CWGroup') |
0 | 370 |
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
|
371 |
self.vreg['views'].select, 'edition', req, rset=rset) |
0 | 372 |
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
|
373 |
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
|
374 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 375 |
tableview.TableView) |
376 |
||
377 |
def test_interface_selector(self): |
|
3587 | 378 |
image = self.add_entity('Image', data_name=u'bim.png', data=Binary('bim')) |
0 | 379 |
# image primary view priority |
3587 | 380 |
rset, req = self.env.get_rset_and_req('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
|
381 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
0 | 382 |
idownloadable.IDownloadablePrimaryView) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
383 |
|
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
384 |
|
0 | 385 |
def test_score_entity_selector(self): |
3587 | 386 |
image = self.add_entity('Image', data_name=u'bim.png', data=Binary('bim')) |
0 | 387 |
# image primary view priority |
3587 | 388 |
rset, req = self.env.get_rset_and_req('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
|
389 |
self.assertIsInstance(self.vreg['views'].select('image', req, rset=rset), |
0 | 390 |
idownloadable.ImageView) |
3587 | 391 |
fileobj = self.add_entity('File', data_name=u'bim.txt', data=Binary('bim')) |
0 | 392 |
# image primary view priority |
3587 | 393 |
rset, req = self.env.get_rset_and_req('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
|
394 |
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
|
395 |
|
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
396 |
|
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
397 |
|
0 | 398 |
def _test_view(self, vid, rql, args): |
399 |
if rql is None: |
|
400 |
rset = None |
|
401 |
req = self.request() |
|
402 |
else: |
|
403 |
rset, req = self.env.get_rset_and_req(rql) |
|
404 |
try: |
|
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
|
405 |
self.vreg['views'].render(vid, req, rset=rset, **args) |
0 | 406 |
except: |
407 |
print vid, rset, args |
|
408 |
raise |
|
409 |
||
410 |
def test_form(self): |
|
411 |
for vid, rql, args in ( |
|
412 |
#('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
|
413 |
('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
|
414 |
('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
|
415 |
('muledit', 'CWGroup X', {}), |
0 | 416 |
#('muledit', 'Any X', {}), |
417 |
): |
|
418 |
self._test_view(vid, rql, args) |
|
419 |
||
420 |
||
421 |
def test_properties(self): |
|
422 |
self.assertEquals(sorted(k for k in self.vreg['propertydefs'].keys() |
|
423 |
if k.startswith('boxes.edit_box')), |
|
424 |
['boxes.edit_box.context', |
|
425 |
'boxes.edit_box.order', |
|
426 |
'boxes.edit_box.visible']) |
|
427 |
self.assertEquals([k for k in self.vreg['propertyvalues'].keys() |
|
428 |
if not k.startswith('system.version')], |
|
429 |
[]) |
|
430 |
self.assertEquals(self.vreg.property_value('boxes.edit_box.visible'), True) |
|
431 |
self.assertEquals(self.vreg.property_value('boxes.edit_box.order'), 2) |
|
432 |
self.assertEquals(self.vreg.property_value('boxes.possible_views_box.visible'), False) |
|
433 |
self.assertEquals(self.vreg.property_value('boxes.possible_views_box.order'), 10) |
|
434 |
self.assertRaises(KeyError, self.vreg.property_value, 'boxes.actions_box') |
|
435 |
||
436 |
||
437 |
||
438 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
439 |
class CWETypeRQLAction(Action): |
0 | 440 |
id = 'testaction' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
441 |
__select__ = implements('CWEType') & rql_condition('X name "CWEType"') |
0 | 442 |
title = 'bla' |
443 |
||
444 |
class RQLActionTC(ViewSelectorTC): |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
445 |
|
0 | 446 |
def setUp(self): |
447 |
super(RQLActionTC, self).setUp() |
|
1654 | 448 |
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
|
449 |
self.vreg.register_appobject_class(CWETypeRQLAction) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
450 |
|
0 | 451 |
def tearDown(self): |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
452 |
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
|
453 |
del self.vreg['actions']['testaction'] |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
454 |
|
0 | 455 |
def test(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
456 |
rset, req = self.env.get_rset_and_req('CWEType X WHERE X name "CWEType"') |
0 | 457 |
self.assertDictEqual(self.pactions(req, rset), |
458 |
{'useractions': USERACTIONS, |
|
459 |
'siteactions': SITEACTIONS, |
|
3587 | 460 |
'footer': FOOTERACTIONS, |
0 | 461 |
'mainactions': [('edit', actions.ModifyAction)], |
1654 | 462 |
'moreactions': [('managepermission', actions.ManagePermissionsAction), |
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
463 |
('addrelated', actions.AddRelatedActions), |
1654 | 464 |
('delete', actions.DeleteAction), |
0 | 465 |
('copy', actions.CopyAction), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
466 |
('testaction', CWETypeRQLAction), |
1654 | 467 |
], |
0 | 468 |
}) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
469 |
rset, req = self.env.get_rset_and_req('CWEType X WHERE X name "CWRType"') |
0 | 470 |
self.assertDictEqual(self.pactions(req, rset), |
471 |
{'useractions': USERACTIONS, |
|
472 |
'siteactions': SITEACTIONS, |
|
3587 | 473 |
'footer': FOOTERACTIONS, |
0 | 474 |
'mainactions': [('edit', actions.ModifyAction)], |
1654 | 475 |
'moreactions': [('managepermission', actions.ManagePermissionsAction), |
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
476 |
('addrelated', actions.AddRelatedActions), |
1654 | 477 |
('delete', actions.DeleteAction), |
783 | 478 |
('copy', actions.CopyAction), |
1654 | 479 |
], |
0 | 480 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
481 |
|
0 | 482 |
|
483 |
||
484 |
if __name__ == '__main__': |
|
485 |
unittest_main() |