author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 27 Sep 2011 14:57:41 +0200 | |
branch | stable |
changeset 7873 | 975d6f51cfab |
parent 7840 | d6733436b0dd |
child 7845 | 2172978be237 |
permissions | -rw-r--r-- |
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
1 |
# -*- coding: utf-8 -*- |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
2 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
3 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
4 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
5 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
7 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
8 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
9 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
10 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
11 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
12 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
14 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
15 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
16 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
17 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4916
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5886 | 19 |
"""XXX rename, split, reorganize this""" |
20 |
||
783 | 21 |
from logilab.common.testlib import unittest_main |
793 | 22 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
23 |
from cubicweb.devtools.testlib import CubicWebTC |
4493
c0a43c6ba777
now raise UnknownProperty, not KeyError
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4492
diff
changeset
|
24 |
from cubicweb import CW_SOFTWARE_ROOT as BASE, Binary, UnknownProperty |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5570
diff
changeset
|
25 |
from cubicweb.selectors import (match_user_groups, is_instance, |
793 | 26 |
specified_etype_implements, rql_condition, |
27 |
traced_selection) |
|
28 |
from cubicweb.web import NoSelectableObject |
|
0 | 29 |
from cubicweb.web.action import Action |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
30 |
from cubicweb.web.views import ( |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
31 |
primary, baseviews, tableview, editforms, calendar, management, embedding, |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
32 |
actions, startup, cwuser, schema, xbel, vcard, owl, treeview, idownloadable, |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
33 |
wdoc, debug, cwuser, cwproperties, cwsources, workflow, xmlrss, rdf, |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
34 |
csvexport) |
0 | 35 |
|
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
36 |
from cubes.folder import views as folderviews |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
37 |
|
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
38 |
USERACTIONS = [actions.UserPreferencesAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
39 |
actions.UserInfoAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
40 |
actions.LogoutAction] |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
41 |
SITEACTIONS = [actions.ManageAction] |
3998
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
42 |
FOOTERACTIONS = [wdoc.HelpAction, |
94cc7cad3d2d
backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
43 |
wdoc.ChangeLogAction, |
3589 | 44 |
wdoc.AboutAction, |
45 |
actions.PoweredByAction] |
|
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
46 |
MANAGEACTIONS = [actions.SiteConfigurationAction, |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
47 |
schema.ViewSchemaAction, |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
48 |
cwuser.ManageUsersAction, |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
49 |
cwsources.ManageSourcesAction, |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
50 |
debug.SiteInfoAction] |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
51 |
|
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
52 |
if hasattr(rdf, 'RDFView') is not None: # not available if rdf lib not installed |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
53 |
RDFVIEWS = [('rdf', rdf.RDFView)] |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
54 |
|
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
55 |
assert RDFVIEWS |
0 | 56 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
57 |
class ViewSelectorTC(CubicWebTC): |
0 | 58 |
|
59 |
def setup_database(self): |
|
4078 | 60 |
req = self.request() |
61 |
req.create_entity('BlogEntry', title=u"une news !", content=u"cubicweb c'est beau") |
|
62 |
req.create_entity('Bookmark', title=u"un signet !", path=u"view?vid=index") |
|
63 |
req.create_entity('EmailAddress', address=u"devel@logilab.fr", alias=u'devel') |
|
64 |
req.create_entity('Tag', name=u'x') |
|
0 | 65 |
|
66 |
class VRegistryTC(ViewSelectorTC): |
|
67 |
"""test the view selector""" |
|
68 |
||
69 |
def _test_registered(self, registry, content): |
|
70 |
try: |
|
71 |
expected = getattr(self, 'all_%s' % registry) |
|
72 |
except AttributeError: |
|
73 |
return |
|
74 |
if registry == 'hooks': |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6048
diff
changeset
|
75 |
self.assertEqual(len(content), expected, content) |
0 | 76 |
return |
77 |
try: |
|
78 |
self.assertSetEqual(content.keys(), expected) |
|
7815
2a164a9cf81c
[exceptions] stop catching any exception in various places (closes #1942716)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7244
diff
changeset
|
79 |
except Exception: |
0 | 80 |
print registry, sorted(expected), sorted(content.keys()) |
81 |
print 'no more', [v for v in expected if not v in content.keys()] |
|
82 |
print 'missing', [v for v in content.keys() if not v in expected] |
|
83 |
raise |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
84 |
|
2403
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
85 |
def setUp(self): |
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
86 |
super(VRegistryTC, self).setUp() |
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
87 |
assert self.vreg['views']['propertiesform'] |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
88 |
|
793 | 89 |
def test_possible_views_none_rset(self): |
0 | 90 |
req = self.request() |
91 |
self.assertListEqual(self.pviews(req, None), |
|
92 |
[('changelog', wdoc.ChangeLogView), |
|
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
93 |
('cw.source-management', cwsources.CWSourceManagementView), |
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
94 |
('cw.user-management', cwuser.CWUserManagementView), |
4916 | 95 |
('gc', debug.GCView), |
0 | 96 |
('index', startup.IndexView), |
4724
fe1f3c560381
fix test, broken by the merge of debug and info views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4534
diff
changeset
|
97 |
('info', debug.ProcessInformationView), |
0 | 98 |
('manage', startup.ManageView), |
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
99 |
('owl', owl.OWLView), |
1900
8dd4bb69c73d
[tests] fix test after eproperties got renamed to cwproperties
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1797
diff
changeset
|
100 |
('propertiesform', cwproperties.CWPropertiesForm), |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
101 |
('registry', debug.RegistryView), |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2458
diff
changeset
|
102 |
('schema', schema.SchemaView), |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
103 |
('siteinfo', debug.SiteInfoView), |
3229
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
104 |
('systempropertiesform', cwproperties.SystemCWPropertiesForm), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
105 |
('tree', folderviews.FolderTreeView), |
948e0cb59b1a
test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
106 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
107 |
|
793 | 108 |
def test_possible_views_noresult(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
109 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
110 |
rset = req.execute('Any X WHERE X eid 999999') |
0 | 111 |
self.assertListEqual(self.pviews(req, rset), |
783 | 112 |
[]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
113 |
|
793 | 114 |
def test_possible_views_one_egroup(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
115 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
116 |
rset = req.execute('CWGroup X WHERE X name "managers"') |
0 | 117 |
self.assertListEqual(self.pviews(req, rset), |
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
118 |
[('csvexport', csvexport.CSVRsetView), |
1654 | 119 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 120 |
('editable-table', tableview.EditableTableView), |
444 | 121 |
('filetree', treeview.FileTreeView), |
0 | 122 |
('list', baseviews.ListView), |
123 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
124 |
('owlabox', owl.OWLABOXView), |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
125 |
('primary', cwuser.CWGroupPrimaryView)] + RDFVIEWS + [ |
1654 | 126 |
('rsetxml', xmlrss.XMLRsetView), |
127 |
('rss', xmlrss.RSSView), |
|
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
128 |
('sameetypelist', baseviews.SameETypeListView), |
0 | 129 |
('security', management.SecurityManagementView), |
130 |
('table', tableview.TableView), |
|
131 |
('text', baseviews.TextView), |
|
444 | 132 |
('treeview', treeview.TreeView), |
0 | 133 |
('xbel', xbel.XbelView), |
1654 | 134 |
('xml', xmlrss.XMLView), |
0 | 135 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
136 |
|
793 | 137 |
def test_possible_views_multiple_egroups(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
138 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
139 |
rset = req.execute('CWGroup X') |
0 | 140 |
self.assertListEqual(self.pviews(req, rset), |
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
141 |
[('csvexport', csvexport.CSVRsetView), |
1654 | 142 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 143 |
('editable-table', tableview.EditableTableView), |
444 | 144 |
('filetree', treeview.FileTreeView), |
0 | 145 |
('list', baseviews.ListView), |
146 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
147 |
('owlabox', owl.OWLABOXView), |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
148 |
('primary', cwuser.CWGroupPrimaryView)] + RDFVIEWS + [ |
1654 | 149 |
('rsetxml', xmlrss.XMLRsetView), |
150 |
('rss', xmlrss.RSSView), |
|
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
151 |
('sameetypelist', baseviews.SameETypeListView), |
0 | 152 |
('security', management.SecurityManagementView), |
153 |
('table', tableview.TableView), |
|
154 |
('text', baseviews.TextView), |
|
444 | 155 |
('treeview', treeview.TreeView), |
0 | 156 |
('xbel', xbel.XbelView), |
1654 | 157 |
('xml', xmlrss.XMLView), |
0 | 158 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
159 |
|
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
160 |
def test_propertiesform_admin(self): |
2403
74f7fa676a52
fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2401
diff
changeset
|
161 |
assert self.vreg['views']['propertiesform'] |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
162 |
req1 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
163 |
req2 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
164 |
rset1 = req1.execute('CWUser X WHERE X login "admin"') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
165 |
rset2 = req2.execute('CWUser X WHERE X login "anon"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
166 |
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
|
167 |
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
|
168 |
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
|
169 |
|
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
170 |
def test_propertiesform_anon(self): |
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
171 |
self.login('anon') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
172 |
req1 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
173 |
req2 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
174 |
rset1 = req1.execute('CWUser X WHERE X login "admin"') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
175 |
rset2 = req2.execute('CWUser X WHERE X login "anon"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
176 |
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
|
177 |
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
|
178 |
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
|
179 |
|
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
180 |
def test_propertiesform_jdoe(self): |
7244
a918f76441ce
fix tests broken by fcb8932082a5 (continued)
Alexandre Fayolle <alexandre.fayolle@logilab.fr>
parents:
7017
diff
changeset
|
181 |
self.create_user(self.request(), 'jdoe') |
2401
890f6b990dd7
[views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
182 |
self.login('jdoe') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
183 |
req1 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
184 |
req2 = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
185 |
rset1 = req1.execute('CWUser X WHERE X login "admin"') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
186 |
rset2 = req2.execute('CWUser X WHERE X login "jdoe"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
187 |
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
|
188 |
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
|
189 |
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
|
190 |
|
793 | 191 |
def test_possible_views_multiple_different_types(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
192 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
193 |
rset = req.execute('Any X') |
0 | 194 |
self.assertListEqual(self.pviews(req, rset), |
1654 | 195 |
[('csvexport', csvexport.CSVRsetView), |
196 |
('ecsvexport', csvexport.CSVEntityView), |
|
0 | 197 |
('editable-table', tableview.EditableTableView), |
444 | 198 |
('filetree', treeview.FileTreeView), |
0 | 199 |
('list', baseviews.ListView), |
200 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
201 |
('owlabox', owl.OWLABOXView), |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
202 |
('primary', primary.PrimaryView),] + RDFVIEWS + [ |
1654 | 203 |
('rsetxml', xmlrss.XMLRsetView), |
204 |
('rss', xmlrss.RSSView), |
|
0 | 205 |
('security', management.SecurityManagementView), |
206 |
('table', tableview.TableView), |
|
207 |
('text', baseviews.TextView), |
|
444 | 208 |
('treeview', treeview.TreeView), |
0 | 209 |
('xbel', xbel.XbelView), |
1654 | 210 |
('xml', xmlrss.XMLView), |
0 | 211 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
212 |
|
793 | 213 |
def test_possible_views_any_rset(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
214 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
215 |
rset = req.execute('Any N, X WHERE X in_group Y, Y name N') |
0 | 216 |
self.assertListEqual(self.pviews(req, rset), |
1654 | 217 |
[('csvexport', csvexport.CSVRsetView), |
0 | 218 |
('editable-table', tableview.EditableTableView), |
1654 | 219 |
('rsetxml', xmlrss.XMLRsetView), |
0 | 220 |
('table', tableview.TableView), |
221 |
]) |
|
793 | 222 |
|
223 |
def test_possible_views_multiple_eusers(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
224 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
225 |
rset = req.execute('CWUser X') |
0 | 226 |
self.assertListEqual(self.pviews(req, rset), |
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
227 |
[('csvexport', csvexport.CSVRsetView), |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
228 |
('cw.user-table', cwuser.CWUserTable), |
1654 | 229 |
('ecsvexport', csvexport.CSVEntityView), |
0 | 230 |
('editable-table', tableview.EditableTableView), |
444 | 231 |
('filetree', treeview.FileTreeView), |
1654 | 232 |
('foaf', cwuser.FoafView), |
0 | 233 |
('list', baseviews.ListView), |
234 |
('oneline', baseviews.OneLineView), |
|
587
c8ff5d88f164
adding views to test
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
479
diff
changeset
|
235 |
('owlabox', owl.OWLABOXView), |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
236 |
('primary', primary.PrimaryView)] + RDFVIEWS + [ |
1654 | 237 |
('rsetxml', xmlrss.XMLRsetView), |
238 |
('rss', xmlrss.RSSView), |
|
4494
ccb7fce7297b
AdaptedList -> SameETypeList
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4493
diff
changeset
|
239 |
('sameetypelist', baseviews.SameETypeListView), |
0 | 240 |
('security', management.SecurityManagementView), |
241 |
('table', tableview.TableView), |
|
242 |
('text', baseviews.TextView), |
|
444 | 243 |
('treeview', treeview.TreeView), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
244 |
('vcard', vcard.VCardCWUserView), |
0 | 245 |
('xbel', xbel.XbelView), |
1654 | 246 |
('xml', xmlrss.XMLView), |
0 | 247 |
]) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
248 |
|
0 | 249 |
def test_possible_actions_none_rset(self): |
250 |
req = self.request() |
|
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
251 |
self.assertDictEqual(self.pactionsdict(req, None, skipcategories=()), |
0 | 252 |
{'useractions': USERACTIONS, |
253 |
'siteactions': SITEACTIONS, |
|
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
254 |
'manage': MANAGEACTIONS, |
3587 | 255 |
'footer': FOOTERACTIONS, |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
256 |
|
0 | 257 |
}) |
258 |
def test_possible_actions_no_entity(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
259 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
260 |
rset = req.execute('Any X WHERE X eid 999999') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
261 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 262 |
{'useractions': USERACTIONS, |
263 |
'siteactions': SITEACTIONS, |
|
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
264 |
'manage': MANAGEACTIONS, |
3587 | 265 |
'footer': FOOTERACTIONS, |
0 | 266 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
267 |
|
0 | 268 |
def test_possible_actions_same_type_entities(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
269 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
270 |
rset = req.execute('CWGroup X') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
271 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 272 |
{'useractions': USERACTIONS, |
273 |
'siteactions': SITEACTIONS, |
|
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
274 |
'manage': MANAGEACTIONS, |
3587 | 275 |
'footer': FOOTERACTIONS, |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
276 |
'mainactions': [actions.MultipleEditAction], |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
277 |
'moreactions': [actions.DeleteAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
278 |
actions.AddNewAction], |
0 | 279 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
280 |
|
0 | 281 |
def test_possible_actions_different_types_entities(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
282 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
283 |
rset = req.execute('Any X') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
284 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 285 |
{'useractions': USERACTIONS, |
286 |
'siteactions': SITEACTIONS, |
|
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
287 |
'manage': MANAGEACTIONS, |
3587 | 288 |
'footer': FOOTERACTIONS, |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
289 |
'moreactions': [actions.DeleteAction], |
0 | 290 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
291 |
|
0 | 292 |
def test_possible_actions_final_entities(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
293 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
294 |
rset = req.execute('Any N, X WHERE X in_group Y, Y name N') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
295 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 296 |
{'useractions': USERACTIONS, |
3587 | 297 |
'siteactions': SITEACTIONS, |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
298 |
'manage': MANAGEACTIONS, |
3587 | 299 |
'footer': FOOTERACTIONS, |
300 |
}) |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
301 |
|
1654 | 302 |
def test_possible_actions_eetype_cwuser_entity(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
303 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
304 |
rset = req.execute('CWEType X WHERE X name "CWUser"') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
305 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 306 |
{'useractions': USERACTIONS, |
307 |
'siteactions': SITEACTIONS, |
|
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
308 |
'manage': MANAGEACTIONS, |
3587 | 309 |
'footer': FOOTERACTIONS, |
4492
150f1d57ecfd
fix test broken by introduction of ViewSameEType action
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4491
diff
changeset
|
310 |
'mainactions': [actions.ModifyAction, |
150f1d57ecfd
fix test broken by introduction of ViewSameEType action
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4491
diff
changeset
|
311 |
actions.ViewSameCWEType], |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
312 |
'moreactions': [actions.ManagePermissionsAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
313 |
actions.AddRelatedActions, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
314 |
actions.DeleteAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
315 |
actions.CopyAction, |
1654 | 316 |
], |
0 | 317 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
318 |
|
0 | 319 |
|
320 |
def test_select_creation_form(self): |
|
321 |
rset = None |
|
322 |
req = self.request() |
|
323 |
# creation form |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
324 |
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
|
325 |
self.assertIsInstance(self.vreg['views'].select('creation', req, rset=rset), |
1654 | 326 |
editforms.CreationFormView) |
0 | 327 |
del req.form['etype'] |
328 |
# custom creation form |
|
1654 | 329 |
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
|
330 |
__select__ = specified_etype_implements('CWUser') |
1654 | 331 |
self.vreg._loadedmods[__name__] = {} |
4491
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4182
diff
changeset
|
332 |
self.vreg.register(CWUserCreationForm) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
333 |
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
|
334 |
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
|
335 |
CWUserCreationForm) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
336 |
|
0 | 337 |
def test_select_view(self): |
338 |
# no entity |
|
339 |
rset = None |
|
340 |
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
|
341 |
self.assertIsInstance(self.vreg['views'].select('index', req, rset=rset), |
0 | 342 |
startup.IndexView) |
343 |
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
|
344 |
self.vreg['views'].select, 'primary', req, rset=rset) |
0 | 345 |
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
|
346 |
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
|
347 |
|
0 | 348 |
# no entity |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
349 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
350 |
rset = req.execute('Any X WHERE X eid 999999') |
0 | 351 |
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
|
352 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 353 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
354 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 355 |
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
|
356 |
self.vreg['views'].select, 'primary', req, rset=rset) |
0 | 357 |
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
|
358 |
self.vreg['views'].select, 'table', req, rset=rset) |
0 | 359 |
# one entity |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
360 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
361 |
rset = req.execute('CWGroup X WHERE X name "managers"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
362 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
1654 | 363 |
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
|
364 |
self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset), |
0 | 365 |
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
|
366 |
self.assertIsInstance(self.vreg['views'].select('edition', req, rset=rset), |
1654 | 367 |
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
|
368 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 369 |
tableview.TableView) |
370 |
self.failUnlessRaises(NoSelectableObject, |
|
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
371 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 372 |
self.failUnlessRaises(NoSelectableObject, |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
373 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 374 |
# list of entities of the same type |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
375 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
376 |
rset = req.execute('CWGroup X') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
377 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
1654 | 378 |
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
|
379 |
self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset), |
0 | 380 |
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
|
381 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 382 |
tableview.TableView) |
383 |
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
|
384 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 385 |
# list of entities of different types |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
386 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
387 |
rset = req.execute('Any X') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
388 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
1654 | 389 |
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
|
390 |
self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset), |
0 | 391 |
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
|
392 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 393 |
tableview.TableView) |
394 |
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
|
395 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 396 |
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
|
397 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 398 |
# whatever |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
399 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
400 |
rset = req.execute('Any N, X WHERE X in_group Y, Y name N') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
401 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 402 |
tableview.TableView) |
403 |
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
|
404 |
self.vreg['views'].select, 'index', req, rset=rset) |
0 | 405 |
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
|
406 |
self.vreg['views'].select, 'creation', req, rset=rset) |
0 | 407 |
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
|
408 |
self.vreg['views'].select, 'primary', req, rset=rset) |
0 | 409 |
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
|
410 |
self.vreg['views'].select, 'list', req, rset=rset) |
0 | 411 |
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
|
412 |
self.vreg['views'].select, 'edition', req, rset=rset) |
0 | 413 |
# mixed query |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
414 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
415 |
rset = req.execute('Any U,G WHERE U is CWUser, G is CWGroup') |
0 | 416 |
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
|
417 |
self.vreg['views'].select, 'edition', req, rset=rset) |
0 | 418 |
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
|
419 |
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
|
420 |
self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset), |
0 | 421 |
tableview.TableView) |
422 |
||
423 |
def test_interface_selector(self): |
|
5570
50b887d25233
[test] no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
424 |
image = self.request().create_entity('File', data_name=u'bim.png', data=Binary('bim')) |
0 | 425 |
# image primary view priority |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
426 |
req = self.request() |
5570
50b887d25233
[test] no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
427 |
rset = req.execute('File X WHERE X data_name "bim.png"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
428 |
self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset), |
0 | 429 |
idownloadable.IDownloadablePrimaryView) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
430 |
|
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
431 |
|
0 | 432 |
def test_score_entity_selector(self): |
5570
50b887d25233
[test] no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
433 |
image = self.request().create_entity('File', data_name=u'bim.png', data=Binary('bim')) |
6048
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
434 |
# image/ehtml primary view priority |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
435 |
req = self.request() |
5570
50b887d25233
[test] no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
436 |
rset = req.execute('File X WHERE X data_name "bim.png"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
437 |
self.assertIsInstance(self.vreg['views'].select('image', req, rset=rset), |
0 | 438 |
idownloadable.ImageView) |
6048
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
439 |
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'ehtml', req, rset=rset) |
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
440 |
|
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
441 |
fileobj = self.request().create_entity('File', data_name=u'bim.html', data=Binary('<html>bam</html')) |
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
442 |
# image/ehtml primary view priority |
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
443 |
req = self.request() |
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
444 |
rset = req.execute('File X WHERE X data_name "bim.html"') |
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
445 |
self.assertIsInstance(self.vreg['views'].select('ehtml', req, rset=rset), |
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
446 |
idownloadable.EHTMLView) |
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
447 |
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'image', req, rset=rset) |
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
448 |
|
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
449 |
fileobj = self.request().create_entity('File', data_name=u'bim.txt', data=Binary('boum')) |
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
450 |
# image/ehtml primary view priority |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
451 |
req = self.request() |
3589 | 452 |
rset = req.execute('File X WHERE X data_name "bim.txt"') |
2650
18aec79ec3a3
R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
453 |
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'image', req, rset=rset) |
6048
4695b1ee58a0
fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
6031
diff
changeset
|
454 |
self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'ehtml', req, rset=rset) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
455 |
|
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
456 |
|
0 | 457 |
def _test_view(self, vid, rql, args): |
458 |
if rql is None: |
|
459 |
rset = None |
|
460 |
req = self.request() |
|
461 |
else: |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
462 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
463 |
rset = req.execute(rql) |
0 | 464 |
try: |
4182 | 465 |
obj = self.vreg['views'].select(vid, req, rset=rset, **args) |
4172
4d4cef034eec
all web tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4078
diff
changeset
|
466 |
return obj.render(**args) |
7815
2a164a9cf81c
[exceptions] stop catching any exception in various places (closes #1942716)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7244
diff
changeset
|
467 |
except Exception: |
0 | 468 |
print vid, rset, args |
469 |
raise |
|
470 |
||
471 |
def test_form(self): |
|
472 |
for vid, rql, args in ( |
|
473 |
#('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
|
474 |
('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
|
475 |
('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
|
476 |
('muledit', 'CWGroup X', {}), |
0 | 477 |
#('muledit', 'Any X', {}), |
478 |
): |
|
479 |
self._test_view(vid, rql, args) |
|
480 |
||
481 |
||
482 |
def test_properties(self): |
|
6367
d4c485ec1ca1
fix merge, some buffers weren't saved...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
483 |
self.assertEqual(sorted(k for k in self.vreg['propertydefs'].keys() |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6048
diff
changeset
|
484 |
if k.startswith('ctxcomponents.edit_box')), |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6048
diff
changeset
|
485 |
['ctxcomponents.edit_box.context', |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6048
diff
changeset
|
486 |
'ctxcomponents.edit_box.order', |
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6048
diff
changeset
|
487 |
'ctxcomponents.edit_box.visible']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6048
diff
changeset
|
488 |
self.assertEqual([k for k in self.vreg['propertyvalues'].keys() |
0 | 489 |
if not k.startswith('system.version')], |
490 |
[]) |
|
6367
d4c485ec1ca1
fix merge, some buffers weren't saved...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
491 |
self.assertEqual(self.vreg.property_value('ctxcomponents.edit_box.visible'), True) |
d4c485ec1ca1
fix merge, some buffers weren't saved...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
492 |
self.assertEqual(self.vreg.property_value('ctxcomponents.edit_box.order'), 2) |
d4c485ec1ca1
fix merge, some buffers weren't saved...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
493 |
self.assertEqual(self.vreg.property_value('ctxcomponents.possible_views_box.visible'), False) |
d4c485ec1ca1
fix merge, some buffers weren't saved...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
494 |
self.assertEqual(self.vreg.property_value('ctxcomponents.possible_views_box.order'), 10) |
6141
b8287e54b528
[web api] unify 'contentnav' (VComponent) and 'boxes' registries as 'ctxcomponents' (CtxComponent)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6048
diff
changeset
|
495 |
self.assertRaises(UnknownProperty, self.vreg.property_value, 'ctxcomponents.actions_box') |
0 | 496 |
|
497 |
||
498 |
||
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
793
diff
changeset
|
499 |
class CWETypeRQLAction(Action): |
3408
c92170fca813
[api] use __regid__ instead of deprecated id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
500 |
__regid__ = 'testaction' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5570
diff
changeset
|
501 |
__select__ = is_instance('CWEType') & rql_condition('X name "CWEType"') |
0 | 502 |
title = 'bla' |
503 |
||
504 |
class RQLActionTC(ViewSelectorTC): |
|
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
505 |
|
0 | 506 |
def setUp(self): |
507 |
super(RQLActionTC, self).setUp() |
|
1654 | 508 |
self.vreg._loadedmods[__name__] = {} |
4491
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4182
diff
changeset
|
509 |
self.vreg.register(CWETypeRQLAction) |
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4182
diff
changeset
|
510 |
actionsreg = self.vreg['actions'] |
4534 | 511 |
actionsreg['testaction'][0].__registered__(actionsreg) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
512 |
|
0 | 513 |
def tearDown(self): |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
514 |
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
|
515 |
del self.vreg['actions']['testaction'] |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
516 |
|
0 | 517 |
def test(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
518 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
519 |
rset = req.execute('CWEType X WHERE X name "CWEType"') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
520 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 521 |
{'useractions': USERACTIONS, |
522 |
'siteactions': SITEACTIONS, |
|
3587 | 523 |
'footer': FOOTERACTIONS, |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
524 |
'manage': MANAGEACTIONS, |
4492
150f1d57ecfd
fix test broken by introduction of ViewSameEType action
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4491
diff
changeset
|
525 |
'mainactions': [actions.ModifyAction, actions.ViewSameCWEType], |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
526 |
'moreactions': [actions.ManagePermissionsAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
527 |
actions.AddRelatedActions, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
528 |
actions.DeleteAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
529 |
actions.CopyAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
530 |
CWETypeRQLAction, |
1654 | 531 |
], |
0 | 532 |
}) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
533 |
req = self.request() |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
534 |
rset = req.execute('CWEType X WHERE X name "CWRType"') |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
535 |
self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()), |
0 | 536 |
{'useractions': USERACTIONS, |
537 |
'siteactions': SITEACTIONS, |
|
3587 | 538 |
'footer': FOOTERACTIONS, |
7017
cd2ea273007a
[web test] fix some tests broken by recent (and various) changesets
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6367
diff
changeset
|
539 |
'manage': MANAGEACTIONS, |
4492
150f1d57ecfd
fix test broken by introduction of ViewSameEType action
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4491
diff
changeset
|
540 |
'mainactions': [actions.ModifyAction, actions.ViewSameCWEType], |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
541 |
'moreactions': [actions.ManagePermissionsAction, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
542 |
actions.AddRelatedActions, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
543 |
actions.DeleteAction, |
3735 | 544 |
actions.CopyAction,] |
0 | 545 |
}) |
1570
5c40d9fb4e8d
stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
546 |
|
0 | 547 |
|
548 |
||
549 |
if __name__ == '__main__': |
|
550 |
unittest_main() |