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