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