test/unittest_selectors.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Fri, 11 Sep 2009 08:39:17 +0200
branchstable
changeset 3174 97273eeaaead
parent 2657 de974465d381
child 2773 b2530e3e0afb
child 4212 ab6573088b4a
permissions -rw-r--r--
Added tag cubicweb-version-3.4.8 for changeset ba43e084e884
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
630
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     1
"""unit tests for selectors mechanism
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     2
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     3
:organization: Logilab
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1640
diff changeset
     4
:copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2.
630
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     5
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
1977
606923dff11b big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 1640
diff changeset
     6
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses
630
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     7
"""
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     8
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
     9
from logilab.common.testlib import TestCase, unittest_main
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    10
1473
717dea3362c0 more implements selector tests
sylvain.thenault@logilab.fr
parents: 779
diff changeset
    11
from cubicweb.devtools.testlib import EnvBasedTC
2657
de974465d381 [appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    12
from cubicweb.appobject import Selector, AndSelector, OrSelector
1640
65b60f177eb1 fix tests
sylvain.thenault@logilab.fr
parents: 1571
diff changeset
    13
from cubicweb.selectors import implements, match_user_groups
779
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    14
from cubicweb.interfaces import IDownloadable
1571
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
    15
from cubicweb.web import action
630
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    16
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    17
class _1_(Selector):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    18
    def __call__(self, *args, **kwargs):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
        return 1
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
class _0_(Selector):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
    def __call__(self, *args, **kwargs):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    23
        return 0
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    25
def _2_(*args, **kwargs):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    26
    return 2
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    27
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    28
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    29
class SelectorsTC(TestCase):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    30
    def test_basic_and(self):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    31
        selector = _1_() & _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    32
        self.assertEquals(selector(None), 2)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    33
        selector = _1_() & _0_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    34
        self.assertEquals(selector(None), 0)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    35
        selector = _0_() & _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    36
        self.assertEquals(selector(None), 0)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    37
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    38
    def test_basic_or(self):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    39
        selector = _1_() | _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    40
        self.assertEquals(selector(None), 1)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    41
        selector = _1_() | _0_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    42
        self.assertEquals(selector(None), 1)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    43
        selector = _0_() | _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    44
        self.assertEquals(selector(None), 1)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    45
        selector = _0_() | _0_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    46
        self.assertEquals(selector(None), 0)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    47
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    48
    def test_selector_and_function(self):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    49
        selector = _1_() & _2_
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    50
        self.assertEquals(selector(None), 3)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    51
        selector = _2_ & _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    52
        self.assertEquals(selector(None), 3)
1473
717dea3362c0 more implements selector tests
sylvain.thenault@logilab.fr
parents: 779
diff changeset
    53
630
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    54
    def test_three_and(self):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    55
        selector = _1_() & _1_() & _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    56
        self.assertEquals(selector(None), 3)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    57
        selector = _1_() & _0_() & _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    58
        self.assertEquals(selector(None), 0)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    59
        selector = _0_() & _1_() & _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    60
        self.assertEquals(selector(None), 0)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    61
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    62
    def test_three_or(self):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    63
        selector = _1_() | _1_() | _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    64
        self.assertEquals(selector(None), 1)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    65
        selector = _1_() | _0_() | _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    66
        self.assertEquals(selector(None), 1)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    67
        selector = _0_() | _1_() | _1_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    68
        self.assertEquals(selector(None), 1)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    69
        selector = _0_() | _0_() | _0_()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    70
        self.assertEquals(selector(None), 0)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    71
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    72
    def test_composition(self):
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    73
        selector = (_1_() & _1_()) & (_1_() & _1_())
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    74
        self.failUnless(isinstance(selector, AndSelector))
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    75
        self.assertEquals(len(selector.selectors), 4)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    76
        self.assertEquals(selector(None), 4)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    77
        selector = (_1_() & _0_()) | (_1_() & _1_())
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    78
        self.failUnless(isinstance(selector, OrSelector))
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    79
        self.assertEquals(len(selector.selectors), 2)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    80
        self.assertEquals(selector(None), 2)
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    81
779
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    82
    def test_search_selectors(self):
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    83
        sel = implements('something')
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    84
        self.assertIs(sel.search_selector(implements), sel)
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    85
        csel = AndSelector(sel, Selector())
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    86
        self.assertIs(csel.search_selector(implements), sel)
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    87
        csel = AndSelector(Selector(), sel)
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    88
        self.assertIs(csel.search_selector(implements), sel)
1473
717dea3362c0 more implements selector tests
sylvain.thenault@logilab.fr
parents: 779
diff changeset
    89
630
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    90
779
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    91
class ImplementsSelectorTC(EnvBasedTC):
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    92
    def test_etype_priority(self):
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    93
        req = self.request()
2657
de974465d381 [appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
    94
        cls = self.vreg['etypes'].etype_class('File')
779
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    95
        anyscore = implements('Any').score_class(cls, req)
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    96
        idownscore = implements(IDownloadable).score_class(cls, req)
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    97
        self.failUnless(idownscore > anyscore, (idownscore, anyscore))
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    98
        filescore = implements('File').score_class(cls, req)
8510e14335e1 implements some str, fix implements selector, test and fixes
sylvain.thenault@logilab.fr
parents: 630
diff changeset
    99
        self.failUnless(filescore > idownscore, (filescore, idownscore))
1473
717dea3362c0 more implements selector tests
sylvain.thenault@logilab.fr
parents: 779
diff changeset
   100
717dea3362c0 more implements selector tests
sylvain.thenault@logilab.fr
parents: 779
diff changeset
   101
    def test_etype_inheritance_no_yams_inheritance(self):
2657
de974465d381 [appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   102
        cls = self.vreg['etypes'].etype_class('Personne')
1473
717dea3362c0 more implements selector tests
sylvain.thenault@logilab.fr
parents: 779
diff changeset
   103
        self.failIf(implements('Societe').score_class(cls, self.request()))
717dea3362c0 more implements selector tests
sylvain.thenault@logilab.fr
parents: 779
diff changeset
   104
1571
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   105
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   106
class MatchUserGroupsTC(EnvBasedTC):
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   107
    def test_owners_group(self):
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   108
        """tests usage of 'owners' group with match_user_group"""
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   109
        class SomeAction(action.Action):
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   110
            id = 'yo'
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   111
            category = 'foo'
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   112
            __select__ = match_user_groups('owners')
1640
65b60f177eb1 fix tests
sylvain.thenault@logilab.fr
parents: 1571
diff changeset
   113
        self.vreg._loadedmods[__name__] = {}
2657
de974465d381 [appobject] kill VObject class, move base selector classes to appobject
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1977
diff changeset
   114
        self.vreg.register_appobject_class(SomeAction)
1571
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   115
        self.failUnless(SomeAction in self.vreg['actions']['yo'], self.vreg['actions'])
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   116
        try:
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   117
            # login as a simple user
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   118
            self.create_user('john')
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   119
            self.login('john')
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   120
            # it should not be possible to use SomeAction not owned objects
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   121
            rset, req = self.env.get_rset_and_req('Any G WHERE G is CWGroup, G name "managers"')
1640
65b60f177eb1 fix tests
sylvain.thenault@logilab.fr
parents: 1571
diff changeset
   122
            self.failIf('yo' in dict(self.pactions(req, rset)))
1571
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   123
            # insert a new card, and check that we can use SomeAction on our object
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   124
            self.execute('INSERT Card C: C title "zoubidou"')
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   125
            self.commit()
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   126
            rset, req = self.env.get_rset_and_req('Card C WHERE C title "zoubidou"')
1640
65b60f177eb1 fix tests
sylvain.thenault@logilab.fr
parents: 1571
diff changeset
   127
            self.failUnless('yo' in dict(self.pactions(req, rset)), self.pactions(req, rset))
1571
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   128
            # make sure even managers can't use the action
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   129
            self.restore_connection()
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   130
            rset, req = self.env.get_rset_and_req('Card C WHERE C title "zoubidou"')
1640
65b60f177eb1 fix tests
sylvain.thenault@logilab.fr
parents: 1571
diff changeset
   131
            self.failIf('yo' in dict(self.pactions(req, rset)))
1571
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   132
        finally:
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   133
            del self.vreg[SomeAction.__registry__][SomeAction.id]
e9ad2724659d tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents: 1473
diff changeset
   134
630
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   135
if __name__ == '__main__':
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   136
    unittest_main()
66ff0b2f7d03 simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   137