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