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