author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 26 Feb 2010 06:59:16 +0100 | |
branch | stable |
changeset 4703 | 4e803c30b7db |
parent 4491 | a0f48c31b58a |
child 5373 | 24a873060692 |
child 5421 | 8167de96c523 |
permissions | -rw-r--r-- |
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 |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2657
diff
changeset
|
4 |
:copyright: 2001-2010 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 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
11 |
from cubicweb.devtools.testlib import CubicWebTC |
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 | 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 | 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 | 89 |
|
630
66ff0b2f7d03
simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
90 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
91 |
class ImplementsSelectorTC(CubicWebTC): |
779
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 | 100 |
|
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 | 103 |
self.failIf(implements('Societe').score_class(cls, self.request())) |
104 |
||
1571
e9ad2724659d
tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents:
1473
diff
changeset
|
105 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2657
diff
changeset
|
106 |
class MatchUserGroupsTC(CubicWebTC): |
1571
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): |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
110 |
__regid__ = 'yo' |
1571
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 | 113 |
self.vreg._loadedmods[__name__] = {} |
4491
a0f48c31b58a
kill register_appobject_class method, simplifying autoregistration. Update test accordingly (test which manually registers object should also properly call there __register__ method). Drop the disable-appobjects config file entry: no one used it since its introduction years ago.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4490
diff
changeset
|
114 |
self.vreg.register(SomeAction) |
4490
d45cde54d464
backport stable branch and some vreg cleanups:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
115 |
SomeAction.__registered__(self.vreg['actions']) |
1571
e9ad2724659d
tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents:
1473
diff
changeset
|
116 |
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
|
117 |
try: |
e9ad2724659d
tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents:
1473
diff
changeset
|
118 |
# login as a simple user |
e9ad2724659d
tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents:
1473
diff
changeset
|
119 |
self.create_user('john') |
e9ad2724659d
tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents:
1473
diff
changeset
|
120 |
self.login('john') |
e9ad2724659d
tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents:
1473
diff
changeset
|
121 |
# it should not be possible to use SomeAction not owned objects |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
122 |
req = self.request() |
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
123 |
rset = req.execute('Any G WHERE G is CWGroup, G name "managers"') |
1640 | 124 |
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
|
125 |
# 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
|
126 |
self.execute('INSERT Card C: C title "zoubidou"') |
e9ad2724659d
tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents:
1473
diff
changeset
|
127 |
self.commit() |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
128 |
req = self.request() |
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
129 |
rset = req.execute('Card C WHERE C title "zoubidou"') |
1640 | 130 |
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
|
131 |
# make sure even managers can't use the action |
e9ad2724659d
tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents:
1473
diff
changeset
|
132 |
self.restore_connection() |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
133 |
req = self.request() |
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
134 |
rset = req.execute('Card C WHERE C title "zoubidou"') |
1640 | 135 |
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
|
136 |
finally: |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2773
diff
changeset
|
137 |
del self.vreg[SomeAction.__registry__][SomeAction.__regid__] |
1571
e9ad2724659d
tests depends on the bootstrap cube
sylvain.thenault@logilab.fr
parents:
1473
diff
changeset
|
138 |
|
630
66ff0b2f7d03
simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
139 |
if __name__ == '__main__': |
66ff0b2f7d03
simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
140 |
unittest_main() |
66ff0b2f7d03
simple test implementation for binary operators on selectors
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff
changeset
|
141 |