web/test/unittest_viewselector.py
author David Douard <david.douard@logilab.fr>
Tue, 12 Jul 2016 12:29:29 +0200
branch3.20
changeset 11402 e60a8e5d29ef
parent 10074 ab956b780d4e
child 10247 7efcfb87b924
permissions -rw-r--r--
[debian] add a lintian override for source-is-missing about jquery.flot.js
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2401
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
     1
# -*- coding: utf-8 -*-
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
     2
# copyright 2003-2014 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
00a78298d30d cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
    19
"""XXX rename, split, reorganize this"""
00a78298d30d cleanups
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 5426
diff changeset
    20
783
45d816326626 fix test in-progress
sylvain.thenault@logilab.fr
parents: 764
diff changeset
    21
from logilab.common.testlib import unittest_main
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
    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
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    24
from cubicweb import Binary, UnknownProperty
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    25
from cubicweb.predicates import (is_instance,
8190
2a3c1b787688 [vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7994
diff changeset
    26
                                 specified_etype_implements, rql_condition)
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
    27
from cubicweb.web import NoSelectableObject
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
from cubicweb.web.action import Action
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    29
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    30
from cubicweb.web.views import (primary, baseviews, tableview,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    31
                                editforms, management, actions, startup, cwuser, schema, xbel,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    32
                                vcard, owl, treeview, idownloadable, wdoc, debug, cwuser,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    33
                                cwproperties, cwsources, xmlrss, rdf, csvexport, json,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    34
                                undohistory)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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>
parents: 3735 3952
diff changeset
    42
FOOTERACTIONS = [wdoc.HelpAction,
3589
a5432f99f2d9 backport stable branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3468 3587
diff changeset
    43
                 wdoc.AboutAction,
a5432f99f2d9 backport stable branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3468 3587
diff changeset
    44
                 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
    45
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
    46
                 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
    47
                 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
    48
                 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
    49
                 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
    50
8591
f7c07e9d4f2e [web test] make unittest_viewselectors work if rdflib isn't available
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8292
diff changeset
    51
if hasattr(rdf, 'RDFView'): # not available if rdflib not installed
f7c07e9d4f2e [web test] make unittest_viewselectors work if rdflib isn't available
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8292
diff changeset
    52
    RDFVIEWS = [('rdf', rdf.RDFView)]
f7c07e9d4f2e [web test] make unittest_viewselectors work if rdflib isn't available
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8292
diff changeset
    53
else:
f7c07e9d4f2e [web test] make unittest_viewselectors work if rdflib isn't available
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8292
diff changeset
    54
    RDFVIEWS = []
f7c07e9d4f2e [web test] make unittest_viewselectors work if rdflib isn't available
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8292
diff changeset
    55
2773
b2530e3e0afb [testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2657
diff changeset
    56
class ViewSelectorTC(CubicWebTC):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    57
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    58
    def setup_database(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    59
        with self.admin_access.repo_cnx() as cnx:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    60
            cnx.create_entity('BlogEntry', title=u"une news !", content=u"cubicweb c'est beau")
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    61
            cnx.create_entity('Bookmark', title=u"un signet !", path=u"view?vid=index")
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    62
            cnx.create_entity('EmailAddress', address=u"devel@logilab.fr", alias=u'devel')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    63
            cnx.create_entity('Tag', name=u'x')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    64
            cnx.commit()
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    66
class VRegistryTC(ViewSelectorTC):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    67
    """test the view selector"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    69
    def _test_registered(self, registry, content):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
        try:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    71
            expected = getattr(self, 'all_%s' % registry)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
        except AttributeError:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    73
            return
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    76
            return
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    77
        try:
8696
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
    78
            self.assertSetEqual(list(content), 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:
8696
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
    80
            print registry, sorted(expected), sorted(content)
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
    81
            print 'no more', [v for v in expected if not v in content]
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
    82
            print 'missing', [v for v in content if not v in expected]
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    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
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
    89
    def test_possible_views_none_rset(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    90
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    91
            self.assertListEqual(self.pviews(req, None),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    92
                                 [('cw.sources-management', cwsources.CWSourcesManagementView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    93
                                  ('cw.users-and-groups-management', cwuser.UsersAndGroupsManagementView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    94
                                  ('gc', debug.GCView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    95
                                  ('index', startup.IndexView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    96
                                  ('info', debug.ProcessInformationView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    97
                                  ('manage', startup.ManageView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    98
                                  ('owl', owl.OWLView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    99
                                  ('propertiesform', cwproperties.CWPropertiesForm),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   100
                                  ('registry', debug.RegistryView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   101
                                  ('schema', schema.SchemaView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   102
                                  ('siteinfo', debug.SiteInfoView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   103
                                  ('systempropertiesform', cwproperties.SystemCWPropertiesForm),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   104
                                  ('tree', folderviews.FolderTreeView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   105
                                  ('undohistory', undohistory.UndoHistoryView)])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   106
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   107
    def test_possible_views_noresult(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   108
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   109
            rset = req.execute('Any X WHERE X eid 999999')
9977
e48e5a597ccc [views] csvexport accept an empty rset (closes #4236928)
Damien Garaud <damien.garaud@logilab.fr>
parents: 9811
diff changeset
   110
            self.assertListEqual(self.pviews(req, rset),
e48e5a597ccc [views] csvexport accept an empty rset (closes #4236928)
Damien Garaud <damien.garaud@logilab.fr>
parents: 9811
diff changeset
   111
                    [('csvexport', csvexport.CSVRsetView),
e48e5a597ccc [views] csvexport accept an empty rset (closes #4236928)
Damien Garaud <damien.garaud@logilab.fr>
parents: 9811
diff changeset
   112
                     ('ecsvexport', csvexport.CSVEntityView),
10013
b68088082280 [web/json] an empty rset is just fine for ejsonexport
Julien Cristau <julien.cristau@logilab.fr>
parents: 9977
diff changeset
   113
                     ('ejsonexport', json.JsonEntityView),
9977
e48e5a597ccc [views] csvexport accept an empty rset (closes #4236928)
Damien Garaud <damien.garaud@logilab.fr>
parents: 9811
diff changeset
   114
                     ('jsonexport', json.JsonRsetView),
e48e5a597ccc [views] csvexport accept an empty rset (closes #4236928)
Damien Garaud <damien.garaud@logilab.fr>
parents: 9811
diff changeset
   115
                     ])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   116
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   117
    def test_possible_views_one_egroup(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   118
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   119
            rset = req.execute('CWGroup X WHERE X name "managers"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   120
            self.assertListEqual(self.pviews(req, rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   121
                                 [('csvexport', csvexport.CSVRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   122
                                  ('ecsvexport', csvexport.CSVEntityView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   123
                                  ('ejsonexport', json.JsonEntityView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   124
                                  ('filetree', treeview.FileTreeView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   125
                                  ('jsonexport', json.JsonRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   126
                                  ('list', baseviews.ListView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   127
                                  ('oneline', baseviews.OneLineView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   128
                                  ('owlabox', owl.OWLABOXView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   129
                                  ('primary', cwuser.CWGroupPrimaryView)] + \
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   130
                                 RDFVIEWS + \
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   131
                                 [('rsetxml', xmlrss.XMLRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   132
                                  ('rss', xmlrss.RSSView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   133
                                  ('sameetypelist', baseviews.SameETypeListView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   134
                                  ('security', management.SecurityManagementView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   135
                                  ('table', tableview.RsetTableView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   136
                                  ('text', baseviews.TextView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   137
                                  ('treeview', treeview.TreeView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   138
                                  ('xbel', xbel.XbelView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   139
                                  ('xml', xmlrss.XMLView)])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   140
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   141
    def test_possible_views_multiple_egroups(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   142
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   143
            rset = req.execute('CWGroup X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   144
            self.assertListEqual(self.pviews(req, rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   145
                                 [('csvexport', csvexport.CSVRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   146
                                  ('ecsvexport', csvexport.CSVEntityView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   147
                                  ('ejsonexport', json.JsonEntityView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   148
                                  ('filetree', treeview.FileTreeView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   149
                                  ('jsonexport', json.JsonRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   150
                                  ('list', baseviews.ListView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   151
                                  ('oneline', baseviews.OneLineView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   152
                                  ('owlabox', owl.OWLABOXView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   153
                                  ('primary', cwuser.CWGroupPrimaryView)] + RDFVIEWS + [
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   154
                                  ('rsetxml', xmlrss.XMLRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   155
                                  ('rss', xmlrss.RSSView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   156
                                  ('sameetypelist', baseviews.SameETypeListView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   157
                                  ('security', management.SecurityManagementView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   158
                                  ('table', tableview.RsetTableView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   159
                                  ('text', baseviews.TextView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   160
                                  ('treeview', treeview.TreeView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   161
                                  ('xbel', xbel.XbelView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   162
                                  ('xml', xmlrss.XMLView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   163
                                  ])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   164
2401
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   165
    def test_propertiesform_admin(self):
2403
74f7fa676a52 fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2401
diff changeset
   166
        assert self.vreg['views']['propertiesform']
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   167
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   168
            rset1 = req.execute('CWUser X WHERE X login "admin"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   169
            self.assertTrue(self.vreg['views'].select('propertiesform', req, rset=None))
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   170
            self.assertTrue(self.vreg['views'].select('propertiesform', req, rset=rset1))
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   171
            rset2 = req.execute('CWUser X WHERE X login "anon"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   172
            self.assertTrue(self.vreg['views'].select('propertiesform', req, rset=rset2))
2401
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   173
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   174
    def test_propertiesform_anon(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   175
        with self.new_access('anon').web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   176
            rset1 = req.execute('CWUser X WHERE X login "admin"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   177
            self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req, rset=None)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   178
            self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req, rset=rset1)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   179
            rset2 = req.execute('CWUser X WHERE X login "anon"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   180
            self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req, rset=rset2)
2401
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   181
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   182
    def test_propertiesform_jdoe(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   183
        with self.admin_access.repo_cnx() as cnx:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   184
            self.create_user(cnx, 'jdoe')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   185
            cnx.commit()
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   186
        with self.new_access('jdoe').web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   187
            rset1 = req.execute('CWUser X WHERE X login "admin"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   188
            rset2 = req.execute('CWUser X WHERE X login "jdoe"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   189
            self.assertTrue(self.vreg['views'].select('propertiesform', req, rset=None))
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   190
            self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'propertiesform', req, rset=rset1)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   191
            self.assertTrue(self.vreg['views'].select('propertiesform', req, rset=rset2))
2401
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   192
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   193
    def test_possible_views_multiple_different_types(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   194
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   195
            rset = req.execute('Any X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   196
            self.assertListEqual(self.pviews(req, rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   197
                                 [('csvexport', csvexport.CSVRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   198
                                  ('ecsvexport', csvexport.CSVEntityView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   199
                                  ('ejsonexport', json.JsonEntityView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   200
                                  ('filetree', treeview.FileTreeView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   201
                                  ('jsonexport', json.JsonRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   202
                                  ('list', baseviews.ListView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   203
                                  ('oneline', baseviews.OneLineView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   204
                                  ('owlabox', owl.OWLABOXView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   205
                                  ('primary', primary.PrimaryView),] + RDFVIEWS + [
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   206
                                  ('rsetxml', xmlrss.XMLRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   207
                                  ('rss', xmlrss.RSSView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   208
                                  ('security', management.SecurityManagementView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   209
                                  ('table', tableview.RsetTableView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   210
                                  ('text', baseviews.TextView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   211
                                  ('treeview', treeview.TreeView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   212
                                  ('xbel', xbel.XbelView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   213
                                  ('xml', xmlrss.XMLView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   214
                                  ])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   215
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   216
    def test_possible_views_any_rset(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   217
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   218
            rset = req.execute('Any N, X WHERE X in_group Y, Y name N')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   219
            self.assertListEqual(self.pviews(req, rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   220
                                 [('csvexport', csvexport.CSVRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   221
                                  ('jsonexport', json.JsonRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   222
                                  ('rsetxml', xmlrss.XMLRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   223
                                  ('table', tableview.RsetTableView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   224
                                  ])
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   225
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   226
    def test_possible_views_multiple_eusers(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   227
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   228
            rset = req.execute('CWUser X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   229
            self.assertListEqual(self.pviews(req, rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   230
                                 [('csvexport', csvexport.CSVRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   231
                                  ('ecsvexport', csvexport.CSVEntityView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   232
                                  ('ejsonexport', json.JsonEntityView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   233
                                  ('filetree', treeview.FileTreeView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   234
                                  ('foaf', cwuser.FoafView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   235
                                  ('jsonexport', json.JsonRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   236
                                  ('list', baseviews.ListView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   237
                                  ('oneline', baseviews.OneLineView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   238
                                  ('owlabox', owl.OWLABOXView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   239
                                  ('primary', primary.PrimaryView)] + RDFVIEWS + [
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   240
                                  ('rsetxml', xmlrss.XMLRsetView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   241
                                  ('rss', xmlrss.RSSView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   242
                                  ('sameetypelist', baseviews.SameETypeListView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   243
                                  ('security', management.SecurityManagementView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   244
                                  ('table', tableview.RsetTableView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   245
                                  ('text', baseviews.TextView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   246
                                  ('treeview', treeview.TreeView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   247
                                  ('vcard', vcard.VCardCWUserView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   248
                                  ('xbel', xbel.XbelView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   249
                                  ('xml', xmlrss.XMLView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   250
                                  ])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   251
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   252
    def test_possible_actions_none_rset(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   253
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   254
            self.assertDictEqual(self.pactionsdict(req, None, skipcategories=()),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   255
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   256
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   257
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   258
                                  'footer': FOOTERACTIONS})
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   259
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   260
    def test_possible_actions_no_entity(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   261
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   262
            rset = req.execute('Any X WHERE X eid 999999')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   263
            self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   264
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   265
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   266
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   267
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   268
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   269
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   270
    def test_possible_actions_same_type_entities(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   271
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   272
            rset = req.execute('CWGroup X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   273
            self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   274
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   275
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   276
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   277
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   278
                                  'mainactions': [actions.MultipleEditAction],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   279
                                  'moreactions': [actions.DeleteAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   280
                                                  actions.AddNewAction]})
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   281
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   282
    def test_possible_actions_different_types_entities(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   283
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   284
            rset = req.execute('Any X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   285
            self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   286
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   287
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   288
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   289
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   290
                                  'moreactions': [actions.DeleteAction],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   291
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   292
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   293
    def test_possible_actions_final_entities(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   294
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   295
            rset = req.execute('Any N, X WHERE X in_group Y, Y name N')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   296
            self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   297
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   298
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   299
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   300
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   301
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   302
1654
57b9fd2462b8 test updates
sylvain.thenault@logilab.fr
parents: 1570
diff changeset
   303
    def test_possible_actions_eetype_cwuser_entity(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   304
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   305
            rset = req.execute('CWEType X WHERE X name "CWUser"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   306
            self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   307
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   308
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   309
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   310
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   311
                                  'mainactions': [actions.ModifyAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   312
                                                  actions.ViewSameCWEType],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   313
                                  'moreactions': [actions.ManagePermissionsAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   314
                                                  actions.AddRelatedActions,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   315
                                                  actions.DeleteAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   316
                                                  actions.CopyAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   317
                                                  ],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   318
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   319
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   320
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   321
    def test_select_creation_form(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   322
        rset = None
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   323
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   324
            # creation form
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   325
            req.form['etype'] = 'CWGroup'
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   326
            self.assertIsInstance(self.vreg['views'].select('creation', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   327
                                  editforms.CreationFormView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   328
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   329
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   330
            # custom creation form
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   331
            class CWUserCreationForm(editforms.CreationFormView):
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   332
                __select__ = specified_etype_implements('CWUser')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   333
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   334
            self.vreg._loadedmods[__name__] = {}
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   335
            self.vreg.register(CWUserCreationForm)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   336
            req.form['etype'] = 'CWUser'
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   337
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   338
            self.assertIsInstance(self.vreg['views'].select('creation', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   339
                                  CWUserCreationForm)
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   340
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   341
    def test_select_view(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   342
        # no entity
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   343
        rset = None
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   344
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   345
            self.assertIsInstance(self.vreg['views'].select('index', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   346
                                  startup.IndexView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   347
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   348
                              self.vreg['views'].select, 'primary', req, rset=rset)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   349
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   350
                              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
   351
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   352
            # no entity
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   353
            rset = req.execute('Any X WHERE X eid 999999')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   354
            self.assertRaises(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, 'index', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   356
            self.assertRaises(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, 'creation', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   358
            self.assertRaises(NoSelectableObject,
2650
18aec79ec3a3 R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2643
diff changeset
   359
                              self.vreg['views'].select, 'primary', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   360
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   361
                              self.vreg['views'].select, 'table', req, rset=rset)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   362
            # one entity
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   363
            rset = req.execute('CWGroup X WHERE X name "managers"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   364
            self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   365
                                  primary.PrimaryView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   366
            self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   367
                                  baseviews.ListView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   368
            self.assertIsInstance(self.vreg['views'].select('edition', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   369
                                  editforms.EditionFormView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   370
            self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   371
                                  tableview.RsetTableView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   372
            self.assertRaises(NoSelectableObject,
2650
18aec79ec3a3 R [vreg] important refactoring of the vregistry, moving behaviour to end dictionnary (and so leaving room for more flexibility ; keep bw compat ; update api usage in cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2643
diff changeset
   373
                              self.vreg['views'].select, 'creation', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   374
            self.assertRaises(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
   375
                              self.vreg['views'].select, 'index', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   376
            # list of entities of the same type
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   377
            rset = req.execute('CWGroup X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   378
            self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   379
                                  primary.PrimaryView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   380
            self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   381
                                  baseviews.ListView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   382
            self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   383
                                  tableview.RsetTableView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   384
            self.assertRaises(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
   385
                              self.vreg['views'].select, 'creation', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   386
            # list of entities of different types
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   387
            rset = req.execute('Any X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   388
            self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset),
1654
57b9fd2462b8 test updates
sylvain.thenault@logilab.fr
parents: 1570
diff changeset
   389
                                  primary.PrimaryView)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   390
            self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset),
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   391
                                  baseviews.ListView)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   392
            self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7845
diff changeset
   393
                                  tableview.RsetTableView)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   394
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   395
                              self.vreg['views'].select, 'creation', req, rset=rset)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   396
            self.assertRaises(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)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   398
            # whatever
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   399
            rset = req.execute('Any N, X WHERE X in_group Y, Y name N')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   400
            self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
7992
4ff9f25cb06e [table views] closes #1986413: refactor TableView, EntityAttributesTableView, PyValTableView
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 7845
diff changeset
   401
                                  tableview.RsetTableView)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   402
            self.assertRaises(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
   403
                              self.vreg['views'].select, 'index', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   404
            self.assertRaises(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
   405
                              self.vreg['views'].select, 'creation', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   406
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   407
                              self.vreg['views'].select, 'primary', req, rset=rset)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   408
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   409
                              self.vreg['views'].select, 'list', req, rset=rset)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   410
            self.assertRaises(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
   411
                              self.vreg['views'].select, 'edition', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   412
            # mixed query
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   413
            rset = req.execute('Any U,G WHERE U is CWUser, G is CWGroup')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   414
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   415
                              self.vreg['views'].select, 'edition', req, rset=rset)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   416
            self.assertRaises(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, 'creation', req, rset=rset)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   418
            self.assertIsInstance(self.vreg['views'].select('table', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   419
                                  tableview.RsetTableView)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   420
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   421
    def test_interface_selector(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   422
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   423
            req.create_entity('File', data_name=u'bim.png', data=Binary('bim'))
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   424
            # image primary view priority
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   425
            rset = req.execute('File X WHERE X data_name "bim.png"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   426
            self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   427
                                  idownloadable.IDownloadablePrimaryView)
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   428
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   429
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   430
    def test_score_entity_selector(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   431
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   432
            req.create_entity('File', data_name=u'bim.png', data=Binary('bim'))
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   433
            # image/ehtml primary view priority
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   434
            rset = req.execute('File X WHERE X data_name "bim.png"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   435
            self.assertIsInstance(self.vreg['views'].select('image', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   436
                                  idownloadable.ImageView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   437
            self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'ehtml', req, rset=rset)
6048
4695b1ee58a0 fix idownload view pb. for xhtml browsers
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 6031
diff changeset
   438
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   439
            fileobj = req.create_entity('File', data_name=u'bim.html', data=Binary('<html>bam</html'))
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   440
            # image/ehtml primary view priority
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   441
            rset = req.execute('File X WHERE X data_name "bim.html"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   442
            self.assertIsInstance(self.vreg['views'].select('ehtml', req, rset=rset),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   443
                                  idownloadable.EHTMLView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   444
            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
   445
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   446
            fileobj = req.create_entity('File', data_name=u'bim.txt', data=Binary('boum'))
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   447
            # image/ehtml primary view priority
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   448
            rset = req.execute('File X WHERE X data_name "bim.txt"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   449
            self.assertRaises(NoSelectableObject, self.vreg['views'].select, 'image', req, rset=rset)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   450
            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
   451
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   452
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   453
    def _test_view(self, vid, rql, args):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   454
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   455
            if rql is None:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   456
                rset = None
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   457
            else:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   458
                rset = req.execute(rql)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   459
            try:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   460
                obj = self.vreg['views'].select(vid, req, rset=rset, **args)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   461
                return obj.render(**args)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   462
            except Exception:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   463
                print vid, rset, args
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   464
                raise
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   465
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   466
    def test_form(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   467
        for vid, rql, args in (
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   468
            #('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
   469
            ('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
   470
            ('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
   471
            ('muledit', 'CWGroup X', {}),
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   472
            #('muledit', 'Any X', {}),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   473
            ):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   474
            self._test_view(vid, rql, args)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   475
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   476
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   477
    def test_properties(self):
8696
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
   478
        self.assertEqual(sorted(k for k in self.vreg['propertydefs'].iterkeys()
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
   479
                                if k.startswith('ctxcomponents.edit_box')),
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
   480
                         ['ctxcomponents.edit_box.context',
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
   481
                          'ctxcomponents.edit_box.order',
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
   482
                          'ctxcomponents.edit_box.visible'])
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
   483
        self.assertEqual([k for k in self.vreg['propertyvalues'].iterkeys()
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
   484
                          if not k.startswith('system.version')],
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
   485
                         [])
6367
d4c485ec1ca1 fix merge, some buffers weren't saved...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6366
diff changeset
   486
        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
   487
        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
   488
        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
   489
        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
   490
        self.assertRaises(UnknownProperty, self.vreg.property_value, 'ctxcomponents.actions_box')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   491
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   492
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   493
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 793
diff changeset
   494
class CWETypeRQLAction(Action):
3408
c92170fca813 [api] use __regid__ instead of deprecated id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3230
diff changeset
   495
    __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
   496
    __select__ = is_instance('CWEType') & rql_condition('X name "CWEType"')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   497
    title = 'bla'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   498
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   499
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   500
class RQLActionTC(ViewSelectorTC):
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   501
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   502
    def setUp(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   503
        super(RQLActionTC, self).setUp()
1654
57b9fd2462b8 test updates
sylvain.thenault@logilab.fr
parents: 1570
diff changeset
   504
        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
   505
        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
   506
        actionsreg = self.vreg['actions']
4534
9e9eb6a22d14 fix test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4494
diff changeset
   507
        actionsreg['testaction'][0].__registered__(actionsreg)
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   508
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   509
    def tearDown(self):
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   510
        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
   511
        del self.vreg['actions']['testaction']
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   512
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   513
    def test(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   514
        with self.admin_access.web_request() as req:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   515
            rset = req.execute('CWEType X WHERE X name "CWEType"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   516
            self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   517
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   518
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   519
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   520
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   521
                                  'mainactions': [actions.ModifyAction, actions.ViewSameCWEType],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   522
                                  'moreactions': [actions.ManagePermissionsAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   523
                                                  actions.AddRelatedActions,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   524
                                                  actions.DeleteAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   525
                                                  actions.CopyAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   526
                                                  CWETypeRQLAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   527
                                                  ],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   528
                                  })
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   529
            rset = req.execute('CWEType X WHERE X name "CWRType"')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   530
            self.assertDictEqual(self.pactionsdict(req, rset, skipcategories=()),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   531
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   532
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   533
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   534
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   535
                                  'mainactions': [actions.ModifyAction, actions.ViewSameCWEType],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   536
                                  'moreactions': [actions.ManagePermissionsAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   537
                                                  actions.AddRelatedActions,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   538
                                                  actions.DeleteAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   539
                                                  actions.CopyAction,]
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   540
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   541
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   542
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   543
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   544
if __name__ == '__main__':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   545
    unittest_main()