author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 17 Feb 2011 16:46:18 +0100 | |
branch | stable |
changeset 7007 | 3804794b1ccd |
parent 6781 | 5062d86d6ffe |
child 7522 | 6f6b334a14b7 |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: iso-8859-1 -*- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
2 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
3 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
4 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
5 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
6 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
7 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
8 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
9 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
10 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
11 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
12 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
13 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
14 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
15 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
16 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
17 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
6632 | 19 |
"""unit tests for modules cubicweb.server.rqlannotation""" |
0 | 20 |
|
21 |
from cubicweb.devtools import init_test_database |
|
22 |
from cubicweb.devtools.repotest import BaseQuerierTC |
|
23 |
||
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
24 |
|
6781
5062d86d6ffe
[unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6632
diff
changeset
|
25 |
def setUpModule(*args): |
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
26 |
global repo, cnx |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
27 |
repo, cnx = init_test_database(apphome=SQLGenAnnotatorTC.datadir) |
0 | 28 |
|
6781
5062d86d6ffe
[unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6632
diff
changeset
|
29 |
def tearDownModule(*args): |
4766
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
30 |
global repo, cnx |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
31 |
del repo, cnx |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
32 |
|
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4191
diff
changeset
|
33 |
|
0 | 34 |
class SQLGenAnnotatorTC(BaseQuerierTC): |
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
35 |
|
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
36 |
def setUp(self): |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
37 |
self.__class__.repo = repo |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6340
diff
changeset
|
38 |
super(SQLGenAnnotatorTC, self).setUp() |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
39 |
|
0 | 40 |
def get_max_eid(self): |
41 |
# no need for cleanup here |
|
42 |
return None |
|
43 |
def cleanup(self): |
|
44 |
# no need for cleanup here |
|
45 |
pass |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
46 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
47 |
def test_0_1(self): |
0 | 48 |
rqlst = self._prepare('Any SEN,RN,OEN WHERE X from_entity SE, SE eid 44, X relation_type R, R eid 139, X to_entity OE, OE eid 42, R name RN, SE name SEN, OE name OEN') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
49 |
self.assertEqual(rqlst.defined_vars['SE']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
50 |
self.assertEqual(rqlst.defined_vars['OE']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
51 |
self.assertEqual(rqlst.defined_vars['R']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
52 |
self.assertEqual(rqlst.defined_vars['SE'].stinfo['attrvar'], None) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
53 |
self.assertEqual(rqlst.defined_vars['OE'].stinfo['attrvar'], None) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
54 |
self.assertEqual(rqlst.defined_vars['R'].stinfo['attrvar'], None) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
55 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
56 |
def test_0_2(self): |
0 | 57 |
rqlst = self._prepare('Any O WHERE NOT S ecrit_par O, S eid 1, S inline1 P, O inline2 P') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
58 |
self.assertEqual(rqlst.defined_vars['P']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
59 |
self.assertEqual(rqlst.defined_vars['O'].stinfo['attrvar'], None) |
0 | 60 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
61 |
def test_0_4(self): |
0 | 62 |
rqlst = self._prepare('Any A,B,C WHERE A eid 12,A comment B, A ?wf_info_for C') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
63 |
self.assertEqual(rqlst.defined_vars['A']._q_invariant, False) |
0 | 64 |
self.assert_(rqlst.defined_vars['B'].stinfo['attrvar']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
65 |
self.assertEqual(rqlst.defined_vars['C']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
66 |
self.assertEqual(rqlst.solutions, [{'A': 'TrInfo', 'B': 'String', 'C': 'Affaire'}, |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
967
diff
changeset
|
67 |
{'A': 'TrInfo', 'B': 'String', 'C': 'CWUser'}, |
0 | 68 |
{'A': 'TrInfo', 'B': 'String', 'C': 'Note'}]) |
69 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
70 |
def test_0_5(self): |
0 | 71 |
rqlst = self._prepare('Any P WHERE N ecrit_par P, N eid 0') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
72 |
self.assertEqual(rqlst.defined_vars['N']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
73 |
self.assertEqual(rqlst.defined_vars['P']._q_invariant, True) |
0 | 74 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
75 |
def test_0_6(self): |
0 | 76 |
rqlst = self._prepare('Any P WHERE NOT N ecrit_par P, N eid 512') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
77 |
self.assertEqual(rqlst.defined_vars['P']._q_invariant, False) |
0 | 78 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
79 |
def test_0_7(self): |
0 | 80 |
rqlst = self._prepare('Personne X,Y where X nom NX, Y nom NX, X eid XE, not Y eid XE') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
81 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
82 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
0 | 83 |
self.assert_(rqlst.defined_vars['XE'].stinfo['attrvar']) |
84 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
85 |
def test_0_8(self): |
0 | 86 |
rqlst = self._prepare('Any P WHERE X eid 0, NOT X connait P') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
87 |
self.assertEqual(rqlst.defined_vars['P']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
88 |
#self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
89 |
self.assertEqual(len(rqlst.solutions), 1, rqlst.solutions) |
0 | 90 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
91 |
def test_0_10(self): |
0 | 92 |
rqlst = self._prepare('Any X WHERE X concerne Y, Y is Note') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
93 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
94 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
0 | 95 |
|
96 |
def test_0_11(self): |
|
97 |
rqlst = self._prepare('Any X WHERE X todo_by Y, X is Affaire') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
98 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
99 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, True) |
0 | 100 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
101 |
def test_0_12(self): |
0 | 102 |
rqlst = self._prepare('Personne P WHERE P concerne A, A concerne S, S nom "Logilab"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
103 |
self.assertEqual(rqlst.defined_vars['P']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
104 |
self.assertEqual(rqlst.defined_vars['A']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
105 |
self.assertEqual(rqlst.defined_vars['S']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
106 |
|
0 | 107 |
def test_1_0(self): |
108 |
rqlst = self._prepare('Any X,Y WHERE X created_by Y, X eid 5, NOT Y eid 6') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
109 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
110 |
|
0 | 111 |
def test_1_1(self): |
112 |
rqlst = self._prepare('Any X,Y WHERE X created_by Y, X eid 5, NOT Y eid IN (6,7)') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
113 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
114 |
|
0 | 115 |
def test_2(self): |
116 |
rqlst = self._prepare('Any X WHERE X identity Y, Y eid 1') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
117 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
118 |
|
0 | 119 |
def test_7(self): |
120 |
rqlst = self._prepare('Personne X,Y where X nom NX, Y nom NX, X eid XE, not Y eid XE') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
121 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
122 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
123 |
|
5173
73760bbb66bd
[rql annotation] add test and fix for bug introduced by 5004:4cc020ee70e2. While it sounded good, it wasn't because stinfo['relations'] didn't include anymore stinfo['typerels']
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
124 |
def test_8(self): |
73760bbb66bd
[rql annotation] add test and fix for bug introduced by 5004:4cc020ee70e2. While it sounded good, it wasn't because stinfo['relations'] didn't include anymore stinfo['typerels']
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
125 |
# DISTINCT Any P WHERE P require_group %(g)s, NOT %(u)s has_group_permission P, P is CWPermission |
73760bbb66bd
[rql annotation] add test and fix for bug introduced by 5004:4cc020ee70e2. While it sounded good, it wasn't because stinfo['relations'] didn't include anymore stinfo['typerels']
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
126 |
rqlst = self._prepare('DISTINCT Any X WHERE A concerne X, NOT N migrated_from X, ' |
73760bbb66bd
[rql annotation] add test and fix for bug introduced by 5004:4cc020ee70e2. While it sounded good, it wasn't because stinfo['relations'] didn't include anymore stinfo['typerels']
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
127 |
'X is Note, N eid 1') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
128 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
5173
73760bbb66bd
[rql annotation] add test and fix for bug introduced by 5004:4cc020ee70e2. While it sounded good, it wasn't because stinfo['relations'] didn't include anymore stinfo['typerels']
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4766
diff
changeset
|
129 |
|
3249
280080eadb22
fix rqlannotation bug w/ identity relation in subscope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
130 |
def test_diff_scope_identity_deamb(self): |
280080eadb22
fix rqlannotation bug w/ identity relation in subscope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
131 |
rqlst = self._prepare('Any X WHERE X concerne Y, Y is Note, EXISTS(Y identity Z, Z migrated_from N)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
132 |
self.assertEqual(rqlst.defined_vars['Z']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
133 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, True) |
3249
280080eadb22
fix rqlannotation bug w/ identity relation in subscope
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
134 |
|
0 | 135 |
def test_optional_inlined(self): |
136 |
rqlst = self._prepare('Any X,S where X from_state S?') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
137 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
138 |
self.assertEqual(rqlst.defined_vars['S']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
139 |
|
0 | 140 |
def test_optional_inlined_2(self): |
141 |
rqlst = self._prepare('Any N,A WHERE N? inline1 A') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
142 |
self.assertEqual(rqlst.defined_vars['N']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
143 |
self.assertEqual(rqlst.defined_vars['A']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
144 |
|
0 | 145 |
def test_optional_1(self): |
146 |
rqlst = self._prepare('Any X,S WHERE X travaille S?') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
147 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
148 |
self.assertEqual(rqlst.defined_vars['S']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
149 |
|
0 | 150 |
def test_greater_eid(self): |
151 |
rqlst = self._prepare('Any X WHERE X eid > 5') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
152 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
153 |
|
0 | 154 |
def test_greater_eid_typed(self): |
155 |
rqlst = self._prepare('Any X WHERE X eid > 5, X is Note') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
156 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
157 |
|
0 | 158 |
def test_max_eid(self): |
159 |
rqlst = self._prepare('Any MAX(X)') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
160 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
161 |
|
0 | 162 |
def test_max_eid_typed(self): |
163 |
rqlst = self._prepare('Any MAX(X) WHERE X is Note') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
164 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
165 |
|
0 | 166 |
def test_all_entities(self): |
167 |
rqlst = self._prepare('Any X') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
168 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
169 |
|
0 | 170 |
def test_all_typed_entity(self): |
171 |
rqlst = self._prepare('Any X WHERE X is Note') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
172 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
173 |
|
0 | 174 |
def test_has_text_1(self): |
175 |
rqlst = self._prepare('Any X WHERE X has_text "toto tata"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
176 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
177 |
self.assertEqual(rqlst.defined_vars['X'].stinfo['principal'].r_type, 'has_text') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
178 |
|
0 | 179 |
def test_has_text_2(self): |
180 |
rqlst = self._prepare('Any X WHERE X is Personne, X has_text "coucou"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
181 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
182 |
self.assertEqual(rqlst.defined_vars['X'].stinfo['principal'].r_type, 'has_text') |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
183 |
|
0 | 184 |
def test_not_relation_1(self): |
185 |
# P can't be invariant since deambiguification caused by "NOT X require_permission P" |
|
186 |
# is not considered by generated sql (NOT EXISTS(...)) |
|
187 |
rqlst = self._prepare('Any P,G WHERE P require_group G, NOT X require_permission P') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
188 |
self.assertEqual(rqlst.defined_vars['P']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
189 |
self.assertEqual(rqlst.defined_vars['G']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
190 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
191 |
|
0 | 192 |
def test_not_relation_2(self): |
193 |
rqlst = self._prepare('TrInfo X WHERE X eid 2, NOT X from_state Y, Y is State') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
194 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
195 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
196 |
|
0 | 197 |
def test_not_relation_3(self): |
198 |
rqlst = self._prepare('Any X, Y WHERE X eid 1, Y eid in (2, 3)') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
199 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
200 |
|
0 | 201 |
def test_not_relation_4_1(self): |
202 |
rqlst = self._prepare('Note X WHERE NOT Y evaluee X') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
203 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
204 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
205 |
|
0 | 206 |
def test_not_relation_4_2(self): |
207 |
rqlst = self._prepare('Any X WHERE NOT Y evaluee X') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
208 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
209 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
210 |
|
0 | 211 |
def test_not_relation_4_3(self): |
212 |
rqlst = self._prepare('Any Y WHERE NOT Y evaluee X') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
213 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
214 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
215 |
|
0 | 216 |
def test_not_relation_4_4(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
967
diff
changeset
|
217 |
rqlst = self._prepare('Any X WHERE NOT Y evaluee X, Y is CWUser') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
218 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
219 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
0 | 220 |
|
221 |
def test_not_relation_4_5(self): |
|
222 |
rqlst = self._prepare('Any X WHERE NOT Y evaluee X, Y eid %s, X is Note' % self.ueid) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
223 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
224 |
self.assertEqual(rqlst.solutions, [{'X': 'Note'}]) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
225 |
|
0 | 226 |
def test_not_relation_5_1(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
967
diff
changeset
|
227 |
rqlst = self._prepare('Any X,Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), NOT X read_permission Y') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
228 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
229 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
0 | 230 |
|
231 |
def test_not_relation_5_2(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
967
diff
changeset
|
232 |
rqlst = self._prepare('DISTINCT Any X,Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), NOT X read_permission Y') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
233 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
234 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
0 | 235 |
|
236 |
def test_not_relation_6(self): |
|
237 |
rqlst = self._prepare('Personne P where NOT P concerne A') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
238 |
self.assertEqual(rqlst.defined_vars['P']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
239 |
self.assertEqual(rqlst.defined_vars['A']._q_invariant, True) |
0 | 240 |
|
241 |
def test_not_relation_7(self): |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
242 |
rqlst = self._prepare('Any K,V WHERE P is CWProperty, P pkey K, P value V, NOT P for_user U') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
243 |
self.assertEqual(rqlst.defined_vars['P']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
244 |
self.assertEqual(rqlst.defined_vars['U']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
245 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
246 |
def test_exists_1(self): |
0 | 247 |
rqlst = self._prepare('Any U WHERE U eid IN (1,2), EXISTS(X owned_by U)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
248 |
self.assertEqual(rqlst.defined_vars['U']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
249 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
250 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
251 |
def test_exists_2(self): |
0 | 252 |
rqlst = self._prepare('Any U WHERE EXISTS(U eid IN (1,2), X owned_by U)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
253 |
self.assertEqual(rqlst.defined_vars['U']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
254 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
0 | 255 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
256 |
def test_exists_3(self): |
0 | 257 |
rqlst = self._prepare('Any U WHERE EXISTS(X owned_by U, X bookmarked_by U)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
258 |
self.assertEqual(rqlst.defined_vars['U']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
259 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
260 |
|
0 | 261 |
def test_exists_4(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
967
diff
changeset
|
262 |
rqlst = self._prepare('Any X,Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), EXISTS(X read_permission Y)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
263 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
264 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
265 |
|
0 | 266 |
def test_exists_5(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
967
diff
changeset
|
267 |
rqlst = self._prepare('DISTINCT Any X,Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), EXISTS(X read_permission Y)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
268 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
269 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, True) |
0 | 270 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
271 |
def test_not_exists_1(self): |
0 | 272 |
rqlst = self._prepare('Any U WHERE NOT EXISTS(X owned_by U, X bookmarked_by U)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
273 |
self.assertEqual(rqlst.defined_vars['U']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
274 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
0 | 275 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
276 |
def test_not_exists_2(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
967
diff
changeset
|
277 |
rqlst = self._prepare('Any X,Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), NOT EXISTS(X read_permission Y)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
278 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
0 | 279 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
280 |
def test_not_exists_distinct_1(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
967
diff
changeset
|
281 |
rqlst = self._prepare('DISTINCT Any X,Y WHERE X name "CWGroup", Y eid IN(1, 2, 3), NOT EXISTS(X read_permission Y)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
282 |
self.assertEqual(rqlst.defined_vars['Y']._q_invariant, False) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
283 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
284 |
def test_or_1(self): |
0 | 285 |
rqlst = self._prepare('Any X WHERE X concerne B OR C concerne X, B eid 12, C eid 13') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
286 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, False) |
0 | 287 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
288 |
def test_or_2(self): |
0 | 289 |
rqlst = self._prepare('Any X WHERE X created_by U, X concerne B OR C concerne X, B eid 12, C eid 13') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
290 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
291 |
self.assertEqual(rqlst.defined_vars['U']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
292 |
self.assertEqual(rqlst.defined_vars['X'].stinfo['principal'].r_type, 'created_by') |
0 | 293 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
294 |
def test_or_3(self): |
0 | 295 |
rqlst = self._prepare('Any N WHERE A evaluee N or EXISTS(N todo_by U)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
296 |
self.assertEqual(rqlst.defined_vars['N']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
297 |
self.assertEqual(rqlst.defined_vars['A']._q_invariant, True) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
298 |
self.assertEqual(rqlst.defined_vars['U']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
299 |
|
0 | 300 |
def test_or_exists_1(self): |
301 |
# query generated by security rewriting |
|
302 |
rqlst = self._prepare('DISTINCT Any A,S WHERE A is Affaire, S nom "chouette", S is IN(Division, Societe, SubDivision),' |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
303 |
'(EXISTS(A owned_by D)) ' |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
304 |
'OR ((((EXISTS(E concerne C?, C owned_by D, A identity E, C is Note, E is Affaire)) ' |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
305 |
'OR (EXISTS(I concerne H?, H owned_by D, H is Societe, A identity I, I is Affaire))) ' |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
306 |
'OR (EXISTS(J concerne G?, G owned_by D, G is SubDivision, A identity J, J is Affaire))) ' |
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
307 |
'OR (EXISTS(K concerne F?, F owned_by D, F is Division, A identity K, K is Affaire)))') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
308 |
self.assertEqual(rqlst.defined_vars['A']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
309 |
self.assertEqual(rqlst.defined_vars['S']._q_invariant, False) |
0 | 310 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
311 |
def test_or_exists_2(self): |
0 | 312 |
rqlst = self._prepare('Any U WHERE EXISTS(U in_group G, G name "managers") OR EXISTS(X owned_by U, X bookmarked_by U)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
313 |
self.assertEqual(rqlst.defined_vars['U']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
314 |
self.assertEqual(rqlst.defined_vars['G']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
315 |
self.assertEqual(rqlst.defined_vars['X']._q_invariant, True) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
316 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
317 |
def test_or_exists_3(self): |
0 | 318 |
rqlst = self._prepare('Any COUNT(S),CS GROUPBY CS ORDERBY 1 DESC LIMIT 10 ' |
319 |
'WHERE C is Societe, S concerne C, C nom CS, ' |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
320 |
'(EXISTS(S owned_by D)) OR (EXISTS(S documented_by N, N title "published"))') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
321 |
self.assertEqual(rqlst.defined_vars['S']._q_invariant, True) |
0 | 322 |
rqlst = self._prepare('Any COUNT(S),CS GROUPBY CS ORDERBY 1 DESC LIMIT 10 ' |
323 |
'WHERE S is Affaire, C is Societe, S concerne C, C nom CS, ' |
|
4191
01638461d4b0
test update. All cw tests OK
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
324 |
'(EXISTS(S owned_by D)) OR (EXISTS(S documented_by N, N title "published"))') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
325 |
self.assertEqual(rqlst.defined_vars['S']._q_invariant, True) |
0 | 326 |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
327 |
def test_nonregr_ambiguity(self): |
967 | 328 |
rqlst = self._prepare('Note N WHERE N attachment F') |
329 |
# N may be an image as well, not invariant |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
330 |
self.assertEqual(rqlst.defined_vars['N']._q_invariant, False) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
331 |
self.assertEqual(rqlst.defined_vars['F']._q_invariant, True) |
967 | 332 |
|
0 | 333 |
if __name__ == '__main__': |
334 |
from logilab.common.testlib import unittest_main |
|
335 |
unittest_main() |