web/test/unittest_viewselector.py
author David Douard <david.douard@logilab.fr>
Fri, 03 Jul 2015 13:43:40 +0200
changeset 10504 3755cd64fff8
parent 10319 0d3ede4865a8
child 10589 7c23b7de2b8d
permissions -rw-r--r--
[doc] small rst fixes and cleanups in changelog files Related to #4832808
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
3468
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3451
diff changeset
    37
USERACTIONS = [actions.UserPreferencesAction,
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3451
diff changeset
    38
               actions.UserInfoAction,
b02fa4db2868 [tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3451
diff changeset
    39
               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
    40
SITEACTIONS = [actions.ManageAction]
3998
94cc7cad3d2d backport stable into default
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3735 3952
diff changeset
    41
FOOTERACTIONS = [wdoc.HelpAction,
3589
a5432f99f2d9 backport stable branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3468 3587
diff changeset
    42
                 wdoc.AboutAction,
a5432f99f2d9 backport stable branch
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3468 3587
diff changeset
    43
                 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
    44
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
    45
                 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
    46
                 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
    47
                 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
    48
                 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
    49
8591
f7c07e9d4f2e [web test] make unittest_viewselectors work if rdflib isn't available
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8292
diff changeset
    50
if hasattr(rdf, 'RDFView'): # not available if rdflib not installed
10319
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
    51
    RDFVIEWS = [('rdf', rdf.RDFView), ('n3rdf', rdf.RDFN3View)]
8591
f7c07e9d4f2e [web test] make unittest_viewselectors work if rdflib isn't available
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8292
diff changeset
    52
else:
f7c07e9d4f2e [web test] make unittest_viewselectors work if rdflib isn't available
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8292
diff changeset
    53
    RDFVIEWS = []
f7c07e9d4f2e [web test] make unittest_viewselectors work if rdflib isn't available
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 8292
diff changeset
    54
2773
b2530e3e0afb [testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2657
diff changeset
    55
class ViewSelectorTC(CubicWebTC):
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    56
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    57
    def setup_database(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    58
        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
    59
            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
    60
            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
    61
            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
    62
            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
    63
            cnx.commit()
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
class VRegistryTC(ViewSelectorTC):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    66
    """test the view selector"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    67
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
    def _test_registered(self, registry, content):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    69
        try:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
            expected = getattr(self, 'all_%s' % registry)
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    71
        except AttributeError:
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
            return
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    73
        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
    74
            self.assertEqual(len(content), expected, content)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    75
            return
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    76
        try:
8696
0bb18407c053 [toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 8645
diff changeset
    77
            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
    78
        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
    79
            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
    80
            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
    81
            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
    82
            raise
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    83
2403
74f7fa676a52 fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2401
diff changeset
    84
    def setUp(self):
74f7fa676a52 fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2401
diff changeset
    85
        super(VRegistryTC, self).setUp()
74f7fa676a52 fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2401
diff changeset
    86
        assert self.vreg['views']['propertiesform']
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
    87
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
    88
    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
    89
        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
    90
            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
    91
                                 [('cw.sources-management', cwsources.CWSourcesManagementView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    92
                                  ('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
    93
                                  ('gc', debug.GCView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    94
                                  ('index', startup.IndexView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    95
                                  ('info', debug.ProcessInformationView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    96
                                  ('manage', startup.ManageView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    97
                                  ('owl', owl.OWLView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    98
                                  ('propertiesform', cwproperties.CWPropertiesForm),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
    99
                                  ('registry', debug.RegistryView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   100
                                  ('schema', schema.SchemaView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   101
                                  ('siteinfo', debug.SiteInfoView),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   102
                                  ('systempropertiesform', cwproperties.SystemCWPropertiesForm),
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   103
                                  ('undohistory', undohistory.UndoHistoryView)])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   104
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   105
    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
   106
        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
   107
            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
   108
            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
   109
                    [('csvexport', csvexport.CSVRsetView),
e48e5a597ccc [views] csvexport accept an empty rset (closes #4236928)
Damien Garaud <damien.garaud@logilab.fr>
parents: 9811
diff changeset
   110
                     ('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
   111
                     ('ejsonexport', json.JsonEntityView),
9977
e48e5a597ccc [views] csvexport accept an empty rset (closes #4236928)
Damien Garaud <damien.garaud@logilab.fr>
parents: 9811
diff changeset
   112
                     ('jsonexport', json.JsonRsetView),
e48e5a597ccc [views] csvexport accept an empty rset (closes #4236928)
Damien Garaud <damien.garaud@logilab.fr>
parents: 9811
diff changeset
   113
                     ])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   114
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   115
    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
   116
        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
   117
            rset = req.execute('CWGroup X WHERE X name "managers"')
10319
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   118
            self.assertCountEqual(self.pviews(req, rset),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   119
                                  RDFVIEWS +
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   120
                                  [('csvexport', csvexport.CSVRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   121
                                   ('ecsvexport', csvexport.CSVEntityView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   122
                                   ('ejsonexport', json.JsonEntityView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   123
                                   ('filetree', treeview.FileTreeView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   124
                                   ('jsonexport', json.JsonRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   125
                                   ('list', baseviews.ListView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   126
                                   ('oneline', baseviews.OneLineView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   127
                                   ('owlabox', owl.OWLABOXView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   128
                                   ('primary', cwuser.CWGroupPrimaryView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   129
                                   ('rsetxml', xmlrss.XMLRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   130
                                   ('rss', xmlrss.RSSView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   131
                                   ('sameetypelist', baseviews.SameETypeListView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   132
                                   ('security', management.SecurityManagementView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   133
                                   ('table', tableview.RsetTableView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   134
                                   ('text', baseviews.TextView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   135
                                   ('treeview', treeview.TreeView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   136
                                   ('xbel', xbel.XbelView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   137
                                   ('xml', xmlrss.XMLView)])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   138
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   139
    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
   140
        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
   141
            rset = req.execute('CWGroup X')
10319
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   142
            self.assertCountEqual(self.pviews(req, rset),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   143
                                  RDFVIEWS +
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   144
                                  [('csvexport', csvexport.CSVRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   145
                                   ('ecsvexport', csvexport.CSVEntityView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   146
                                   ('ejsonexport', json.JsonEntityView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   147
                                   ('filetree', treeview.FileTreeView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   148
                                   ('jsonexport', json.JsonRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   149
                                   ('list', baseviews.ListView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   150
                                   ('oneline', baseviews.OneLineView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   151
                                   ('owlabox', owl.OWLABOXView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   152
                                   ('primary', cwuser.CWGroupPrimaryView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   153
                                   ('rsetxml', xmlrss.XMLRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   154
                                   ('rss', xmlrss.RSSView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   155
                                   ('sameetypelist', baseviews.SameETypeListView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   156
                                   ('security', management.SecurityManagementView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   157
                                   ('table', tableview.RsetTableView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   158
                                   ('text', baseviews.TextView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   159
                                   ('treeview', treeview.TreeView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   160
                                   ('xbel', xbel.XbelView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   161
                                   ('xml', xmlrss.XMLView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   162
                                   ])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   163
2401
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   164
    def test_propertiesform_admin(self):
2403
74f7fa676a52 fix typo, remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2401
diff changeset
   165
        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
   166
        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
   167
            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
   168
            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
   169
            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
   170
            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
   171
            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
   172
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   173
    def test_propertiesform_anon(self):
10247
7efcfb87b924 [web/test] use unicode object as user login
Julien Cristau <julien.cristau@logilab.fr>
parents: 10074
diff changeset
   174
        with self.new_access(u'anon').web_request() as req:
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   175
            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
   176
            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
   177
            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
   178
            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
   179
            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
   180
890f6b990dd7 [views] epropertiesform renamed propertiesform
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   181
    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
   182
        with self.admin_access.repo_cnx() as cnx:
10247
7efcfb87b924 [web/test] use unicode object as user login
Julien Cristau <julien.cristau@logilab.fr>
parents: 10074
diff changeset
   183
            self.create_user(cnx, u'jdoe')
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   184
            cnx.commit()
10247
7efcfb87b924 [web/test] use unicode object as user login
Julien Cristau <julien.cristau@logilab.fr>
parents: 10074
diff changeset
   185
        with self.new_access(u'jdoe').web_request() as req:
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   186
            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
   187
            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
   188
            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
   189
            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
   190
            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
   191
793
06b05dce4831 fix tests
sylvain.thenault@logilab.fr
parents: 783
diff changeset
   192
    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
   193
        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
   194
            rset = req.execute('Any X')
10319
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   195
            self.assertCountEqual(self.pviews(req, rset),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   196
                                  RDFVIEWS +
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   197
                                  [('csvexport', csvexport.CSVRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   198
                                   ('ecsvexport', csvexport.CSVEntityView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   199
                                   ('ejsonexport', json.JsonEntityView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   200
                                   ('filetree', treeview.FileTreeView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   201
                                   ('jsonexport', json.JsonRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   202
                                   ('list', baseviews.ListView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   203
                                   ('oneline', baseviews.OneLineView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   204
                                   ('owlabox', owl.OWLABOXView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   205
                                   ('primary', primary.PrimaryView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   206
                                   ('rsetxml', xmlrss.XMLRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   207
                                   ('rss', xmlrss.RSSView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   208
                                   ('security', management.SecurityManagementView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   209
                                   ('table', tableview.RsetTableView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   210
                                   ('text', baseviews.TextView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   211
                                   ('treeview', treeview.TreeView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   212
                                   ('xbel', xbel.XbelView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   213
                                   ('xml', xmlrss.XMLView),
9811
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')
10319
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   229
            self.assertCountEqual(self.pviews(req, rset),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   230
                                  RDFVIEWS +
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   231
                                  [('csvexport', csvexport.CSVRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   232
                                   ('ecsvexport', csvexport.CSVEntityView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   233
                                   ('ejsonexport', json.JsonEntityView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   234
                                   ('filetree', treeview.FileTreeView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   235
                                   ('foaf', cwuser.FoafView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   236
                                   ('jsonexport', json.JsonRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   237
                                   ('list', baseviews.ListView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   238
                                   ('oneline', baseviews.OneLineView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   239
                                   ('owlabox', owl.OWLABOXView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   240
                                   ('primary', primary.PrimaryView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   241
                                   ('rsetxml', xmlrss.XMLRsetView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   242
                                   ('rss', xmlrss.RSSView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   243
                                   ('sameetypelist', baseviews.SameETypeListView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   244
                                   ('security', management.SecurityManagementView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   245
                                   ('table', tableview.RsetTableView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   246
                                   ('text', baseviews.TextView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   247
                                   ('treeview', treeview.TreeView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   248
                                   ('vcard', vcard.VCardCWUserView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   249
                                   ('xbel', xbel.XbelView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   250
                                   ('xml', xmlrss.XMLView),
0d3ede4865a8 [web/test] Fix broken tests after commit b81adb5e32f9
Rémi Cardona <remi.cardona@logilab.fr>
parents: 10302
diff changeset
   251
                                   ])
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   252
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   253
    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
   254
        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
   255
            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
   256
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   257
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   258
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   259
                                  'footer': FOOTERACTIONS})
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   260
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   261
    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
   262
        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
   263
            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
   264
            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
   265
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   266
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   267
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   268
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   269
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   270
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   271
    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
   272
        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
   273
            rset = req.execute('CWGroup X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   274
            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
   275
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   276
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   277
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   278
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   279
                                  'mainactions': [actions.MultipleEditAction],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   280
                                  'moreactions': [actions.DeleteAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   281
                                                  actions.AddNewAction]})
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   282
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   283
    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
   284
        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
   285
            rset = req.execute('Any X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   286
            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
   287
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   288
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   289
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   290
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   291
                                  'moreactions': [actions.DeleteAction],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   292
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   293
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   294
    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
   295
        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
   296
            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
   297
            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
   298
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   299
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   300
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   301
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   302
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   303
1654
57b9fd2462b8 test updates
sylvain.thenault@logilab.fr
parents: 1570
diff changeset
   304
    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
   305
        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
   306
            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
   307
            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
   308
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   309
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   310
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   311
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   312
                                  'mainactions': [actions.ModifyAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   313
                                                  actions.ViewSameCWEType],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   314
                                  'moreactions': [actions.ManagePermissionsAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   315
                                                  actions.AddRelatedActions,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   316
                                                  actions.DeleteAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   317
                                                  actions.CopyAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   318
                                                  ],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   319
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   320
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   321
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   322
    def test_select_creation_form(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   323
        rset = None
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   324
        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
   325
            # creation form
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   326
            req.form['etype'] = 'CWGroup'
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   327
            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
   328
                                  editforms.CreationFormView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   329
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   330
        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
   331
            # custom creation form
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   332
            class CWUserCreationForm(editforms.CreationFormView):
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   333
                __select__ = specified_etype_implements('CWUser')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   334
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   335
            self.vreg._loadedmods[__name__] = {}
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   336
            self.vreg.register(CWUserCreationForm)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   337
            req.form['etype'] = 'CWUser'
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   338
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   339
            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
   340
                                  CWUserCreationForm)
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   341
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   342
    def test_select_view(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   343
        # no entity
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   344
        rset = None
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   345
        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
   346
            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
   347
                                  startup.IndexView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   348
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   349
                              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
   350
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   351
                              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
   352
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   353
            # no entity
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   354
            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
   355
            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
   356
                              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
   357
            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
   358
                              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
   359
            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
   360
                              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
   361
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   362
                              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
   363
            # one entity
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   364
            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
   365
            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
   366
                                  primary.PrimaryView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   367
            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
   368
                                  baseviews.ListView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   369
            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
   370
                                  editforms.EditionFormView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   371
            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
   372
                                  tableview.RsetTableView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   373
            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
   374
                              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
   375
            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
   376
                              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
   377
            # 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
   378
            rset = req.execute('CWGroup X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   379
            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
   380
                                  primary.PrimaryView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   381
            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
   382
                                  baseviews.ListView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   383
            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
   384
                                  tableview.RsetTableView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   385
            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
   386
                              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
   387
            # 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
   388
            rset = req.execute('Any X')
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   389
            self.assertIsInstance(self.vreg['views'].select('primary', req, rset=rset),
1654
57b9fd2462b8 test updates
sylvain.thenault@logilab.fr
parents: 1570
diff changeset
   390
                                  primary.PrimaryView)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   391
            self.assertIsInstance(self.vreg['views'].select('list', req, rset=rset),
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   392
                                  baseviews.ListView)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   393
            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
   394
                                  tableview.RsetTableView)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   395
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   396
                              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
   397
            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
   398
                              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
   399
            # whatever
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   400
            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
   401
            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
   402
                                  tableview.RsetTableView)
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   403
            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
   404
                              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
   405
            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
   406
                              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
   407
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   408
                              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
   409
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   410
                              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
   411
            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
   412
                              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
   413
            # mixed query
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   414
            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
   415
            self.assertRaises(NoSelectableObject,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   416
                              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
   417
            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
   418
                              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
   419
            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
   420
                                  tableview.RsetTableView)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   421
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   422
    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
   423
        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
   424
            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
   425
            # image primary view priority
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   426
            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
   427
            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
   428
                                  idownloadable.IDownloadablePrimaryView)
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   429
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   430
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   431
    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
   432
        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
   433
            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
   434
            # image/ehtml primary view priority
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   435
            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
   436
            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
   437
                                  idownloadable.ImageView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   438
            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
   439
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   440
            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
   441
            # image/ehtml primary view priority
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   442
            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
   443
            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
   444
                                  idownloadable.EHTMLView)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   445
            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
   446
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   447
            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
   448
            # image/ehtml primary view priority
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   449
            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
   450
            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
   451
            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
   452
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   453
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   454
    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
   455
        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
   456
            if rql is None:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   457
                rset = None
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   458
            else:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   459
                rset = req.execute(rql)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   460
            try:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   461
                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
   462
                return obj.render(**args)
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   463
            except Exception:
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   464
                print vid, rset, args
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   465
                raise
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   466
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   467
    def test_form(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   468
        for vid, rql, args in (
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   469
            #('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
   470
            ('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
   471
            ('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
   472
            ('muledit', 'CWGroup X', {}),
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   473
            #('muledit', 'Any X', {}),
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   474
            ):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   475
            self._test_view(vid, rql, args)
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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   478
    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
   479
        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
   480
                                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
   481
                         ['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
   482
                          '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
   483
                          '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
   484
        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
   485
                          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
   486
                         [])
6367
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.visible'), True)
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.edit_box.order'), 2)
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.visible'), False)
d4c485ec1ca1 fix merge, some buffers weren't saved...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 6366
diff changeset
   490
        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
   491
        self.assertRaises(UnknownProperty, self.vreg.property_value, 'ctxcomponents.actions_box')
0
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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   494
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 793
diff changeset
   495
class CWETypeRQLAction(Action):
3408
c92170fca813 [api] use __regid__ instead of deprecated id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3230
diff changeset
   496
    __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
   497
    __select__ = is_instance('CWEType') & rql_condition('X name "CWEType"')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   498
    title = 'bla'
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   499
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   500
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   501
class RQLActionTC(ViewSelectorTC):
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   502
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   503
    def setUp(self):
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   504
        super(RQLActionTC, self).setUp()
1654
57b9fd2462b8 test updates
sylvain.thenault@logilab.fr
parents: 1570
diff changeset
   505
        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
   506
        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
   507
        actionsreg = self.vreg['actions']
4534
9e9eb6a22d14 fix test
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4494
diff changeset
   508
        actionsreg['testaction'][0].__registered__(actionsreg)
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   509
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   510
    def tearDown(self):
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   511
        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
   512
        del self.vreg['actions']['testaction']
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   513
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   514
    def test(self):
9811
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   515
        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
   516
            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
   517
            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
   518
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   519
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   520
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   521
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   522
                                  'mainactions': [actions.ModifyAction, actions.ViewSameCWEType],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   523
                                  'moreactions': [actions.ManagePermissionsAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   524
                                                  actions.AddRelatedActions,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   525
                                                  actions.DeleteAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   526
                                                  actions.CopyAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   527
                                                  CWETypeRQLAction,
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
                                  })
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   530
            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
   531
            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
   532
                                 {'useractions': USERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   533
                                  'siteactions': SITEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   534
                                  'footer': FOOTERACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   535
                                  'manage': MANAGEACTIONS,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   536
                                  'mainactions': [actions.ModifyAction, actions.ViewSameCWEType],
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   537
                                  'moreactions': [actions.ManagePermissionsAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   538
                                                  actions.AddRelatedActions,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   539
                                                  actions.DeleteAction,
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   540
                                                  actions.CopyAction,]
25ba231d2910 [webtests/views_selectors] use the new connection api
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 8908
diff changeset
   541
                                  })
1570
5c40d9fb4e8d stop using card in test, update form tests
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   542
0
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
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   545
if __name__ == '__main__':
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   546
    unittest_main()