author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Tue, 22 Dec 2009 13:43:24 +0100 | |
branch | stable |
changeset 4179 | 3a0b2f14e17b |
parent 3952 | fbd77bda27c1 |
child 3998 | 94cc7cad3d2d |
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 |
] |
3898
90926f3a8ada
a new help action has been introduced, fix test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3587
diff
changeset
|
30 |
FOOTERACTIONS = [('help', wdoc.HelpAction), |
90926f3a8ada
a new help action has been introduced, fix test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3587
diff
changeset
|
31 |
('changelog', wdoc.ChangeLogAction), |
3587 | 32 |
('about', wdoc.AboutAction), |
33 |
('poweredby', actions.PoweredByAction)] |
|
0 | 34 |
|
35 |
class ViewSelectorTC(EnvBasedTC): |
|
36 |
||
37 |
def setup_database(self): |
|
38 |
self.add_entity('BlogEntry', title=u"une news !", content=u"cubicweb c'est beau") |
|
39 |
self.add_entity('Bookmark', title=u"un signet !", path=u"view?vid=index") |
|
40 |
self.add_entity('EmailAddress', address=u"devel@logilab.fr", alias=u'devel') |
|
41 |
self.add_entity('Tag', name=u'x') |
|
42 |
||
43 |
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
|
44 |
resdict = self.vreg['actions'].possible_actions(req, rset) |
0 | 45 |
for cat, actions in resdict.items(): |
46 |
resdict[cat] = [(a.id, a.__class__) for a in actions] |
|
47 |
return resdict |
|
48 |
||
49 |
||
50 |
class VRegistryTC(ViewSelectorTC): |
|
51 |
"""test the view selector""" |
|
52 |
||
53 |
def _test_registered(self, registry, content): |
|
54 |
try: |
|
55 |
expected = getattr(self, 'all_%s' % registry) |
|
56 |
except AttributeError: |
|
57 |
return |
|
58 |
if registry == 'hooks': |
|
59 |
self.assertEquals(len(content), expected, content) |
|
60 |
return |
|
61 |
try: |
|
62 |
self.assertSetEqual(content.keys(), expected) |
|
63 |
except: |
|
64 |
print registry, sorted(expected), sorted(content.keys()) |
|
65 |
print 'no more', [v for v in expected if not v in content.keys()] |
|
66 |
print 'missing', [v for v in content.keys() if not v in expected] |
|
67 |
raise |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
68 |
|
2403
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
69 |
def setUp(self): |
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
70 |
super(VRegistryTC, self).setUp() |
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
71 |
assert self.vreg['views']['propertiesform'] |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
72 |
|
793 | 73 |
def test_possible_views_none_rset(self): |
0 | 74 |
req = self.request() |
75 |
self.assertListEqual(self.pviews(req, None), |
|
76 |
[('changelog', wdoc.ChangeLogView), |
|
77 |
('debug', debug.DebugView), |
|
78 |
('index', startup.IndexView), |
|
79 |
('info', management.ProcessInformationView), |
|
80 |
('manage', startup.ManageView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
81 |
('owl', owl.OWLView), |
1900
8dd4bb69c73d
[tests] fix test after eproperties got renamed to cwproperties
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1797
diff
changeset
|
82 |
('propertiesform', cwproperties.CWPropertiesForm), |
2780
ad1dfc3855b0
B web/tests back to green
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2657
diff
changeset
|
83 |
('registry', startup.RegistryView), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
84 |
('schema', schema.SchemaView), |
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
85 |
('systempropertiesform', cwproperties.SystemCWPropertiesForm), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
86 |
('tree', folderviews.FolderTreeView), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
87 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
88 |
|
793 | 89 |
def test_possible_views_noresult(self): |
0 | 90 |
rset, req = self.env.get_rset_and_req('Any X WHERE X eid 999999') |
91 |
self.assertListEqual(self.pviews(req, rset), |
|
783 | 92 |
[]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
93 |
|
793 | 94 |
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
|
95 |
rset, req = self.env.get_rset_and_req('CWGroup X WHERE X name "managers"') |
0 | 96 |
self.assertListEqual(self.pviews(req, rset), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
97 |
[('adaptedlist', baseviews.AdaptedListView), |
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
98 |
('csvexport', csvexport.CSVRsetView), |
1654 | 99 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 100 |
('editable-table', tableview.EditableTableView), |
444 | 101 |
('filetree', treeview.FileTreeView), |
0 | 102 |
('list', baseviews.ListView), |
103 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
104 |
('owlabox', owl.OWLABOXView), |
1654 | 105 |
('primary', primary.PrimaryView), |
106 |
('rsetxml', xmlrss.XMLRsetView), |
|
107 |
('rss', xmlrss.RSSView), |
|
0 | 108 |
('secondary', baseviews.SecondaryView), |
109 |
('security', management.SecurityManagementView), |
|
110 |
('table', tableview.TableView), |
|
111 |
('text', baseviews.TextView), |
|
444 | 112 |
('treeview', treeview.TreeView), |
0 | 113 |
('xbel', xbel.XbelView), |
1654 | 114 |
('xml', xmlrss.XMLView), |
0 | 115 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
116 |
|
793 | 117 |
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
|
118 |
rset, req = self.env.get_rset_and_req('CWGroup X') |
0 | 119 |
self.assertListEqual(self.pviews(req, rset), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
120 |
[('adaptedlist', baseviews.AdaptedListView), |
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
121 |
('csvexport', csvexport.CSVRsetView), |
1654 | 122 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 123 |
('editable-table', tableview.EditableTableView), |
444 | 124 |
('filetree', treeview.FileTreeView), |
0 | 125 |
('list', baseviews.ListView), |
126 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
127 |
('owlabox', owl.OWLABOXView), |
1654 | 128 |
('primary', primary.PrimaryView), |
129 |
('rsetxml', xmlrss.XMLRsetView), |
|
130 |
('rss', xmlrss.RSSView), |
|
0 | 131 |
('secondary', baseviews.SecondaryView), |
132 |
('security', management.SecurityManagementView), |
|
133 |
('table', tableview.TableView), |
|
134 |
('text', baseviews.TextView), |
|
444 | 135 |
('treeview', treeview.TreeView), |
0 | 136 |
('xbel', xbel.XbelView), |
1654 | 137 |
('xml', xmlrss.XMLView), |
0 | 138 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
139 |
|
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
140 |
def test_propertiesform_admin(self): |
2403
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
141 |
assert self.vreg['views']['propertiesform'] |
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
142 |
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
|
143 |
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
|
144 |
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
|
145 |
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
|
146 |
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
|
147 |
|
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
148 |
def test_propertiesform_anon(self): |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
149 |
self.login('anon') |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
150 |
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
|
151 |
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
|
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') |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
159 |
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
|
160 |
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
|
161 |
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
|
162 |
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
|
163 |
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
|
164 |
|
793 | 165 |
def test_possible_views_multiple_different_types(self): |
0 | 166 |
rset, req = self.env.get_rset_and_req('Any X') |
167 |
self.assertListEqual(self.pviews(req, rset), |
|
1654 | 168 |
[('csvexport', csvexport.CSVRsetView), |
169 |
('ecsvexport', csvexport.CSVEntityView), |
|
0 | 170 |
('editable-table', tableview.EditableTableView), |
444 | 171 |
('filetree', treeview.FileTreeView), |
0 | 172 |
('list', baseviews.ListView), |
173 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
174 |
('owlabox', owl.OWLABOXView), |
1654 | 175 |
('primary', primary.PrimaryView), |
176 |
('rsetxml', xmlrss.XMLRsetView), |
|
177 |
('rss', xmlrss.RSSView), |
|
0 | 178 |
('secondary', baseviews.SecondaryView), |
179 |
('security', management.SecurityManagementView), |
|
180 |
('table', tableview.TableView), |
|
181 |
('text', baseviews.TextView), |
|
444 | 182 |
('treeview', treeview.TreeView), |
0 | 183 |
('xbel', xbel.XbelView), |
1654 | 184 |
('xml', xmlrss.XMLView), |
0 | 185 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
186 |
|
793 | 187 |
def test_possible_views_any_rset(self): |
0 | 188 |
rset, req = self.env.get_rset_and_req('Any N, X WHERE X in_group Y, Y name N') |
189 |
self.assertListEqual(self.pviews(req, rset), |
|
1654 | 190 |
[('csvexport', csvexport.CSVRsetView), |
0 | 191 |
('editable-table', tableview.EditableTableView), |
1654 | 192 |
('rsetxml', xmlrss.XMLRsetView), |
0 | 193 |
('table', tableview.TableView), |
194 |
]) |
|
793 | 195 |
|
196 |
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
|
197 |
rset, req = self.env.get_rset_and_req('CWUser X') |
0 | 198 |
self.assertListEqual(self.pviews(req, rset), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
199 |
[('adaptedlist', baseviews.AdaptedListView), |
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
200 |
('csvexport', csvexport.CSVRsetView), |
1654 | 201 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 202 |
('editable-table', tableview.EditableTableView), |
444 | 203 |
('filetree', treeview.FileTreeView), |
1654 | 204 |
('foaf', cwuser.FoafView), |
0 | 205 |
('list', baseviews.ListView), |
206 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
207 |
('owlabox', owl.OWLABOXView), |
1797
c2a80130b06d
fix some web tests, adjusts rtags
sylvain.thenault@logilab.fr
parents:
1654
diff
changeset
|
208 |
('primary', primary.PrimaryView), |
1654 | 209 |
('rsetxml', xmlrss.XMLRsetView), |
210 |
('rss', xmlrss.RSSView), |
|
0 | 211 |
('secondary', baseviews.SecondaryView), |
212 |
('security', management.SecurityManagementView), |
|
213 |
('table', tableview.TableView), |
|
214 |
('text', baseviews.TextView), |
|
444 | 215 |
('treeview', treeview.TreeView), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
216 |
('vcard', vcard.VCardCWUserView), |
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() |