author | Nicolas Chauvat <nicolas.chauvat@logilab.fr> |
Thu, 31 Mar 2011 17:12:27 +0200 | |
branch | stable |
changeset 7155 | 4bab50b02927 |
parent 7088 | 76e0dba5f8f3 |
child 7148 | 753b9b48b41e |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: iso-8859-1 -*- |
7043
686010f3a83e
some copyrigh updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
2 |
# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
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:
4848
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
6196 | 19 |
"""unit tests for modules cubicweb.server.querier and cubicweb.server.ssplanner |
0 | 20 |
""" |
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
21 |
from datetime import date, datetime |
0 | 22 |
|
23 |
from logilab.common.testlib import TestCase, unittest_main |
|
24 |
from rql import BadRQLQuery, RQLSyntaxError |
|
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
25 |
|
1949
9064102b4deb
test Bytes storage/retreival
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
26 |
from cubicweb import QueryError, Unauthorized, Binary |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
27 |
from cubicweb.server.sqlutils import SQL_PREFIX |
0 | 28 |
from cubicweb.server.utils import crypt_password |
29 |
from cubicweb.server.sources.native import make_schema |
|
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7043
diff
changeset
|
30 |
from cubicweb.devtools import get_test_db_handler, TestServerConfiguration |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7043
diff
changeset
|
31 |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
32 |
from cubicweb.devtools.repotest import tuplify, BaseQuerierTC |
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
33 |
from unittest_session import Variable |
0 | 34 |
|
35 |
||
36 |
# register priority/severity sorting registered procedure |
|
37 |
from rql.utils import register_function, FunctionDescr |
|
38 |
||
39 |
class group_sort_value(FunctionDescr): |
|
40 |
supported_backends = ('sqlite',) |
|
41 |
rtype = 'Int' |
|
42 |
try: |
|
43 |
register_function(group_sort_value) |
|
44 |
except AssertionError: |
|
45 |
pass |
|
46 |
from cubicweb.server.sqlutils import SQL_CONNECT_HOOKS |
|
47 |
def init_sqlite_connexion(cnx): |
|
48 |
def group_sort_value(text): |
|
49 |
return {"managers": "3", "users": "2", "guests": "1", "owners": "0"}[text] |
|
50 |
cnx.create_function("GROUP_SORT_VALUE", 1, group_sort_value) |
|
51 |
SQL_CONNECT_HOOKS['sqlite'].append(init_sqlite_connexion) |
|
52 |
||
53 |
||
4848
41f84eea63c9
rename logilab.db into logilab.database
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4831
diff
changeset
|
54 |
from logilab.database import _GenericAdvFuncHelper |
0 | 55 |
TYPEMAP = _GenericAdvFuncHelper.TYPE_MAPPING |
56 |
||
57 |
class MakeSchemaTC(TestCase): |
|
58 |
def test_known_values(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
59 |
solution = {'A': 'String', 'B': 'CWUser'} |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
60 |
self.assertEqual(make_schema((Variable('A'), Variable('B')), solution, |
0 | 61 |
'table0', TYPEMAP), |
62 |
('C0 text,C1 integer', {'A': 'table0.C0', 'B': 'table0.C1'})) |
|
1787 | 63 |
|
0 | 64 |
|
6781
5062d86d6ffe
[unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6631
diff
changeset
|
65 |
def setUpModule(*args): |
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
66 |
global repo, cnx |
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7043
diff
changeset
|
67 |
config = TestServerConfiguration(apphome=UtilsTC.datadir) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7043
diff
changeset
|
68 |
handler = get_test_db_handler(config) |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7043
diff
changeset
|
69 |
handler.build_db_cache() |
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7043
diff
changeset
|
70 |
repo, cnx = handler.get_repo_and_cnx() |
0 | 71 |
|
6781
5062d86d6ffe
[unittest2] use unittest2 module fixture api
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
6631
diff
changeset
|
72 |
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:
4758
diff
changeset
|
73 |
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:
4758
diff
changeset
|
74 |
cnx.close() |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4758
diff
changeset
|
75 |
repo.shutdown() |
162b2b127b15
[test] get a chance to get proper garbage collection when running pytest on whole cw
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4758
diff
changeset
|
76 |
del repo, cnx |
0 | 77 |
|
78 |
||
79 |
class UtilsTC(BaseQuerierTC): |
|
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
80 |
def setUp(self): |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
81 |
self.__class__.repo = repo |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
82 |
super(UtilsTC, self).setUp() |
1787 | 83 |
|
0 | 84 |
def get_max_eid(self): |
85 |
# no need for cleanup here |
|
86 |
return None |
|
87 |
def cleanup(self): |
|
88 |
# no need for cleanup here |
|
89 |
pass |
|
1787 | 90 |
|
0 | 91 |
def test_preprocess_1(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
92 |
reid = self.execute('Any X WHERE X is CWRType, X name "owned_by"')[0][0] |
0 | 93 |
rqlst = self._prepare('Any COUNT(RDEF) WHERE RDEF relation_type X, X eid %(x)s', {'x': reid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
94 |
self.assertEqual(rqlst.solutions, [{'RDEF': 'CWAttribute'}, {'RDEF': 'CWRelation'}]) |
1787 | 95 |
|
0 | 96 |
def test_preprocess_2(self): |
97 |
teid = self.execute("INSERT Tag X: X name 'tag'")[0][0] |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
98 |
#geid = self.execute("CWGroup G WHERE G name 'users'")[0][0] |
0 | 99 |
#self.execute("SET X tags Y WHERE X eid %(t)s, Y eid %(g)s", |
100 |
# {'g': geid, 't': teid}, 'g') |
|
101 |
rqlst = self._prepare('Any X WHERE E eid %(x)s, E tags X', {'x': teid}) |
|
102 |
# the query may be optimized, should keep only one solution |
|
103 |
# (any one, etype will be discarded) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
104 |
self.assertEqual(len(rqlst.solutions), 1) |
1787 | 105 |
|
0 | 106 |
def test_preprocess_security(self): |
107 |
plan = self._prepare_plan('Any ETN,COUNT(X) GROUPBY ETN ' |
|
108 |
'WHERE X is ET, ET name ETN') |
|
4674
3d509dbb473a
[test api] rename _user_session to user_groups_session, fix its arguments and return only the session, not (user, session) to make things clearer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
109 |
plan.session = self.user_groups_session('users') |
0 | 110 |
union = plan.rqlst |
111 |
plan.preprocess(union) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
112 |
self.assertEqual(len(union.children), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
113 |
self.assertEqual(len(union.children[0].with_), 1) |
0 | 114 |
subq = union.children[0].with_[0].query |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
115 |
self.assertEqual(len(subq.children), 3) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
116 |
self.assertEqual([t.as_string() for t in union.children[0].selection], |
0 | 117 |
['ETN','COUNT(X)']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
118 |
self.assertEqual([t.as_string() for t in union.children[0].groupby], |
0 | 119 |
['ETN']) |
120 |
partrqls = sorted(((rqlst.as_string(), rqlst.solutions) for rqlst in subq.children)) |
|
121 |
rql, solutions = partrqls[0] |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
122 |
self.assertEqual(rql, |
0 | 123 |
'Any ETN,X WHERE X is ET, ET name ETN, (EXISTS(X owned_by %(B)s))' |
124 |
' OR ((((EXISTS(D concerne C?, C owned_by %(B)s, X identity D, C is Division, D is Affaire))' |
|
125 |
' OR (EXISTS(H concerne G?, G owned_by %(B)s, G is SubDivision, X identity H, H is Affaire)))' |
|
126 |
' OR (EXISTS(I concerne F?, F owned_by %(B)s, F is Societe, X identity I, I is Affaire)))' |
|
127 |
' OR (EXISTS(J concerne E?, E owned_by %(B)s, E is Note, X identity J, J is Affaire)))' |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
128 |
', ET is CWEType, X is Affaire') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
129 |
self.assertEqual(solutions, [{'C': 'Division', |
0 | 130 |
'D': 'Affaire', |
131 |
'E': 'Note', |
|
132 |
'F': 'Societe', |
|
133 |
'G': 'SubDivision', |
|
134 |
'H': 'Affaire', |
|
135 |
'I': 'Affaire', |
|
136 |
'J': 'Affaire', |
|
137 |
'X': 'Affaire', |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
138 |
'ET': 'CWEType', 'ETN': 'String'}]) |
0 | 139 |
rql, solutions = partrqls[1] |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
140 |
self.assertEqual(rql, 'Any ETN,X WHERE X is ET, ET name ETN, ET is CWEType, X is IN(BaseTransition, Bookmark, CWAttribute, CWCache, CWConstraint, CWConstraintType, CWEType, CWGroup, CWPermission, CWProperty, CWRType, CWRelation, CWSource, CWUniqueTogetherConstraint, CWUser, Card, Comment, Division, Email, EmailAddress, EmailPart, EmailThread, ExternalUri, File, Folder, Note, Personne, RQLExpression, Societe, State, SubDivision, SubWorkflowExitPoint, Tag, TrInfo, Transition, Workflow, WorkflowTransition)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
141 |
self.assertListEqual(sorted(solutions), |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
142 |
sorted([{'X': 'BaseTransition', 'ETN': 'String', 'ET': 'CWEType'}, |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
143 |
{'X': 'Bookmark', 'ETN': 'String', 'ET': 'CWEType'}, |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
144 |
{'X': 'Card', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
145 |
{'X': 'Comment', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
146 |
{'X': 'Division', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
147 |
{'X': 'CWCache', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
148 |
{'X': 'CWConstraint', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
149 |
{'X': 'CWConstraintType', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
150 |
{'X': 'CWEType', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
151 |
{'X': 'CWAttribute', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
152 |
{'X': 'CWGroup', 'ETN': 'String', 'ET': 'CWEType'}, |
6209 | 153 |
{'X': 'CWRelation', 'ETN': 'String', 'ET': 'CWEType'}, |
154 |
{'X': 'CWPermission', 'ETN': 'String', 'ET': 'CWEType'}, |
|
155 |
{'X': 'CWProperty', 'ETN': 'String', 'ET': 'CWEType'}, |
|
156 |
{'X': 'CWRType', 'ETN': 'String', 'ET': 'CWEType'}, |
|
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
157 |
{'X': 'CWSource', 'ETN': 'String', 'ET': 'CWEType'}, |
6209 | 158 |
{'X': 'CWUniqueTogetherConstraint', 'ETN': 'String', 'ET': 'CWEType'}, |
159 |
{'X': 'CWUser', 'ETN': 'String', 'ET': 'CWEType'}, |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
160 |
{'X': 'Email', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
161 |
{'X': 'EmailAddress', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
162 |
{'X': 'EmailPart', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
163 |
{'X': 'EmailThread', 'ETN': 'String', 'ET': 'CWEType'}, |
2608
21856eda34f6
[F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
164 |
{'X': 'ExternalUri', 'ETN': 'String', 'ET': 'CWEType'}, |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
165 |
{'X': 'File', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
166 |
{'X': 'Folder', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
167 |
{'X': 'Note', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
168 |
{'X': 'Personne', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
169 |
{'X': 'RQLExpression', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
170 |
{'X': 'Societe', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
171 |
{'X': 'State', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
172 |
{'X': 'SubDivision', 'ETN': 'String', 'ET': 'CWEType'}, |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
173 |
{'X': 'SubWorkflowExitPoint', 'ETN': 'String', 'ET': 'CWEType'}, |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
174 |
{'X': 'Tag', 'ETN': 'String', 'ET': 'CWEType'}, |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
175 |
{'X': 'Transition', 'ETN': 'String', 'ET': 'CWEType'}, |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
176 |
{'X': 'TrInfo', 'ETN': 'String', 'ET': 'CWEType'}, |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
177 |
{'X': 'Workflow', 'ETN': 'String', 'ET': 'CWEType'}, |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
178 |
{'X': 'WorkflowTransition', 'ETN': 'String', 'ET': 'CWEType'}])) |
0 | 179 |
rql, solutions = partrqls[2] |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
180 |
self.assertEqual(rql, |
0 | 181 |
'Any ETN,X WHERE X is ET, ET name ETN, EXISTS(X owned_by %(C)s), ' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
182 |
'ET is CWEType, X is Basket') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
183 |
self.assertEqual(solutions, [{'ET': 'CWEType', |
0 | 184 |
'X': 'Basket', |
185 |
'ETN': 'String', |
|
186 |
}]) |
|
187 |
||
188 |
def test_preprocess_security_aggregat(self): |
|
189 |
plan = self._prepare_plan('Any MAX(X)') |
|
4674
3d509dbb473a
[test api] rename _user_session to user_groups_session, fix its arguments and return only the session, not (user, session) to make things clearer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
190 |
plan.session = self.user_groups_session('users') |
0 | 191 |
union = plan.rqlst |
192 |
plan.preprocess(union) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
193 |
self.assertEqual(len(union.children), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
194 |
self.assertEqual(len(union.children[0].with_), 1) |
0 | 195 |
subq = union.children[0].with_[0].query |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
196 |
self.assertEqual(len(subq.children), 3) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
197 |
self.assertEqual([t.as_string() for t in union.children[0].selection], |
0 | 198 |
['MAX(X)']) |
1787 | 199 |
|
0 | 200 |
def test_preprocess_nonregr(self): |
201 |
rqlst = self._prepare('Any S ORDERBY SI WHERE NOT S ecrit_par O, S para SI') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
202 |
self.assertEqual(len(rqlst.solutions), 1) |
1787 | 203 |
|
0 | 204 |
def test_build_description(self): |
205 |
# should return an empty result set |
|
206 |
rset = self.execute('Any X WHERE X eid %(x)s', {'x': self.session.user.eid}) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
207 |
self.assertEqual(rset.description[0][0], 'CWUser') |
0 | 208 |
rset = self.execute('Any 1') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
209 |
self.assertEqual(rset.description[0][0], 'Int') |
0 | 210 |
rset = self.execute('Any TRUE') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
211 |
self.assertEqual(rset.description[0][0], 'Boolean') |
0 | 212 |
rset = self.execute('Any "hop"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
213 |
self.assertEqual(rset.description[0][0], 'String') |
0 | 214 |
rset = self.execute('Any TODAY') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
215 |
self.assertEqual(rset.description[0][0], 'Date') |
0 | 216 |
rset = self.execute('Any NOW') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
217 |
self.assertEqual(rset.description[0][0], 'Datetime') |
0 | 218 |
rset = self.execute('Any %(x)s', {'x': 1}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
219 |
self.assertEqual(rset.description[0][0], 'Int') |
0 | 220 |
rset = self.execute('Any %(x)s', {'x': 1L}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
221 |
self.assertEqual(rset.description[0][0], 'Int') |
0 | 222 |
rset = self.execute('Any %(x)s', {'x': True}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
223 |
self.assertEqual(rset.description[0][0], 'Boolean') |
0 | 224 |
rset = self.execute('Any %(x)s', {'x': 1.0}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
225 |
self.assertEqual(rset.description[0][0], 'Float') |
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
226 |
rset = self.execute('Any %(x)s', {'x': datetime.now()}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
227 |
self.assertEqual(rset.description[0][0], 'Datetime') |
0 | 228 |
rset = self.execute('Any %(x)s', {'x': 'str'}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
229 |
self.assertEqual(rset.description[0][0], 'String') |
0 | 230 |
rset = self.execute('Any %(x)s', {'x': u'str'}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
231 |
self.assertEqual(rset.description[0][0], 'String') |
0 | 232 |
|
233 |
||
234 |
class QuerierTC(BaseQuerierTC): |
|
6631
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
235 |
def setUp(self): |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
236 |
self.__class__.repo = repo |
26c303c3f1aa
[test] make test independant from the working directory
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6427
diff
changeset
|
237 |
super(QuerierTC, self).setUp() |
0 | 238 |
|
239 |
def test_encoding_pb(self): |
|
240 |
self.assertRaises(RQLSyntaxError, self.execute, |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
241 |
'Any X WHERE X is CWRType, X name "�wned_by"') |
0 | 242 |
|
243 |
def test_unknown_eid(self): |
|
244 |
# should return an empty result set |
|
245 |
self.failIf(self.execute('Any X WHERE X eid 99999999')) |
|
1787 | 246 |
|
3109
e7e1bb06b716
ensure eid given in arguments will be returned correctly typed (though only if they are in the cachekey for now)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
247 |
def test_typed_eid(self): |
e7e1bb06b716
ensure eid given in arguments will be returned correctly typed (though only if they are in the cachekey for now)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
248 |
# should return an empty result set |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
249 |
rset = self.execute('Any X WHERE X eid %(x)s', {'x': '1'}) |
3109
e7e1bb06b716
ensure eid given in arguments will be returned correctly typed (though only if they are in the cachekey for now)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
250 |
self.assertIsInstance(rset[0][0], (int, long)) |
e7e1bb06b716
ensure eid given in arguments will be returned correctly typed (though only if they are in the cachekey for now)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
251 |
|
1949
9064102b4deb
test Bytes storage/retreival
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
252 |
def test_bytes_storage(self): |
3587 | 253 |
feid = self.execute('INSERT File X: X data_name "foo.pdf", X data_format "text/plain", X data %(data)s', |
1949
9064102b4deb
test Bytes storage/retreival
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
254 |
{'data': Binary("xxx")})[0][0] |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
255 |
fdata = self.execute('Any D WHERE X data D, X eid %(x)s', {'x': feid})[0][0] |
1949
9064102b4deb
test Bytes storage/retreival
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
256 |
self.assertIsInstance(fdata, Binary) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
257 |
self.assertEqual(fdata.getvalue(), 'xxx') |
1949
9064102b4deb
test Bytes storage/retreival
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1787
diff
changeset
|
258 |
|
0 | 259 |
# selection queries tests ################################################# |
1787 | 260 |
|
0 | 261 |
def test_select_1(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
262 |
rset = self.execute('Any X ORDERBY X WHERE X is CWGroup') |
0 | 263 |
result, descr = rset.rows, rset.description |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
264 |
self.assertEqual(tuplify(result), [(2,), (3,), (4,), (5,)]) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
265 |
self.assertEqual(descr, [('CWGroup',), ('CWGroup',), ('CWGroup',), ('CWGroup',)]) |
1787 | 266 |
|
0 | 267 |
def test_select_2(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
268 |
rset = self.execute('Any X ORDERBY N WHERE X is CWGroup, X name N') |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
269 |
self.assertEqual(tuplify(rset.rows), [(2,), (3,), (4,), (5,)]) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
270 |
self.assertEqual(rset.description, [('CWGroup',), ('CWGroup',), ('CWGroup',), ('CWGroup',)]) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
271 |
rset = self.execute('Any X ORDERBY N DESC WHERE X is CWGroup, X name N') |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
272 |
self.assertEqual(tuplify(rset.rows), [(5,), (4,), (3,), (2,)]) |
1787 | 273 |
|
0 | 274 |
def test_select_3(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
275 |
rset = self.execute('Any N GROUPBY N WHERE X is CWGroup, X name N') |
0 | 276 |
result, descr = rset.rows, rset.description |
277 |
result.sort() |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
278 |
self.assertEqual(tuplify(result), [('guests',), ('managers',), ('owners',), ('users',)]) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
279 |
self.assertEqual(descr, [('String',), ('String',), ('String',), ('String',)]) |
1787 | 280 |
|
0 | 281 |
def test_select_is(self): |
282 |
rset = self.execute('Any X, TN ORDERBY TN LIMIT 10 WHERE X is T, T name TN') |
|
283 |
result, descr = rset.rows, rset.description |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
284 |
self.assertEqual(result[0][1], descr[0][0]) |
1787 | 285 |
|
0 | 286 |
def test_select_is_aggr(self): |
287 |
rset = self.execute('Any TN, COUNT(X) GROUPBY TN ORDERBY 2 DESC WHERE X is T, T name TN') |
|
288 |
result, descr = rset.rows, rset.description |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
289 |
self.assertEqual(descr[0][0], 'String') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
290 |
self.assertEqual(descr[0][1], 'Int') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
291 |
self.assertEqual(result[0][0], 'CWRelation') # XXX may change as schema evolve |
1787 | 292 |
|
0 | 293 |
def test_select_groupby_orderby(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
294 |
rset = self.execute('Any N GROUPBY N ORDERBY N WHERE X is CWGroup, X name N') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
295 |
self.assertEqual(tuplify(rset.rows), [('guests',), ('managers',), ('owners',), ('users',)]) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
296 |
self.assertEqual(rset.description, [('String',), ('String',), ('String',), ('String',)]) |
1787 | 297 |
|
0 | 298 |
def test_select_complex_groupby(self): |
299 |
rset = self.execute('Any N GROUPBY N WHERE X name N') |
|
300 |
rset = self.execute('Any N,MAX(D) GROUPBY N LIMIT 5 WHERE X name N, X creation_date D') |
|
1787 | 301 |
|
0 | 302 |
def test_select_inlined_groupby(self): |
303 |
seid = self.execute('State X WHERE X name "deactivated"')[0][0] |
|
304 |
rset = self.execute('Any U,L,S GROUPBY U,L,S WHERE X in_state S, U login L, S eid %s' % seid) |
|
1787 | 305 |
|
0 | 306 |
def test_select_complex_orderby(self): |
307 |
rset1 = self.execute('Any N ORDERBY N WHERE X name N') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
308 |
self.assertEqual(sorted(rset1.rows), rset1.rows) |
0 | 309 |
rset = self.execute('Any N ORDERBY N LIMIT 5 OFFSET 1 WHERE X name N') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
310 |
self.assertEqual(rset.rows[0][0], rset1.rows[1][0]) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
311 |
self.assertEqual(len(rset), 5) |
1787 | 312 |
|
0 | 313 |
def test_select_5(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
314 |
rset = self.execute('Any X, TMP ORDERBY TMP WHERE X name TMP, X is CWGroup') |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
315 |
self.assertEqual(tuplify(rset.rows), [(2, 'guests',), (3, 'managers',), (4, 'owners',), (5, 'users',)]) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
316 |
self.assertEqual(rset.description, [('CWGroup', 'String',), ('CWGroup', 'String',), ('CWGroup', 'String',), ('CWGroup', 'String',)]) |
1787 | 317 |
|
0 | 318 |
def test_select_6(self): |
319 |
self.execute("INSERT Personne X: X nom 'bidule'")[0] |
|
320 |
rset = self.execute('Any Y where X name TMP, Y nom in (TMP, "bidule")') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
321 |
#self.assertEqual(rset.description, [('Personne',), ('Personne',)]) |
0 | 322 |
self.assert_(('Personne',) in rset.description) |
323 |
rset = self.execute('DISTINCT Any Y where X name TMP, Y nom in (TMP, "bidule")') |
|
324 |
self.assert_(('Personne',) in rset.description) |
|
1787 | 325 |
|
0 | 326 |
def test_select_not_attr(self): |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
327 |
peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0] |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
328 |
seid = self.execute("INSERT Societe X: X nom 'chouette'")[0][0] |
0 | 329 |
rset = self.execute('Personne X WHERE NOT X nom "bidule"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
330 |
self.assertEqual(len(rset.rows), 0, rset.rows) |
0 | 331 |
rset = self.execute('Personne X WHERE NOT X nom "bid"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
332 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
0 | 333 |
self.execute("SET P travaille S WHERE P nom 'bidule', S nom 'chouette'") |
334 |
rset = self.execute('Personne X WHERE NOT X travaille S') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
335 |
self.assertEqual(len(rset.rows), 0, rset.rows) |
1787 | 336 |
|
0 | 337 |
def test_select_is_in(self): |
338 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
339 |
self.execute("INSERT Societe X: X nom 'chouette'") |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
340 |
self.assertEqual(len(self.execute("Any X WHERE X is IN (Personne, Societe)")), |
0 | 341 |
2) |
1787 | 342 |
|
0 | 343 |
def test_select_not_rel(self): |
344 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
345 |
self.execute("INSERT Societe X: X nom 'chouette'") |
|
346 |
self.execute("INSERT Personne X: X nom 'autre'") |
|
347 |
self.execute("SET P travaille S WHERE P nom 'bidule', S nom 'chouette'") |
|
348 |
rset = self.execute('Personne X WHERE NOT X travaille S') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
349 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
0 | 350 |
rset = self.execute('Personne X WHERE NOT X travaille S, S nom "chouette"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
351 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
1787 | 352 |
|
0 | 353 |
def test_select_nonregr_inlined(self): |
354 |
self.execute("INSERT Note X: X para 'bidule'") |
|
355 |
self.execute("INSERT Personne X: X nom 'chouette'") |
|
356 |
self.execute("INSERT Personne X: X nom 'autre'") |
|
357 |
self.execute("SET X ecrit_par P WHERE X para 'bidule', P nom 'chouette'") |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
358 |
rset = self.execute('Any U,T ORDERBY T DESC WHERE U is CWUser, ' |
0 | 359 |
'N ecrit_par U, N type T')#, {'x': self.ueid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
360 |
self.assertEqual(len(rset.rows), 0) |
1787 | 361 |
|
0 | 362 |
def test_select_nonregr_edition_not(self): |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
363 |
groupeids = set((2, 3, 4)) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
364 |
groupreadperms = set(r[0] for r in self.execute('Any Y WHERE X name "CWGroup", Y eid IN(2, 3, 4), X read_permission Y')) |
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
365 |
rset = self.execute('DISTINCT Any Y WHERE X is CWEType, X name "CWGroup", Y eid IN(2, 3, 4), 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:
6209
diff
changeset
|
366 |
self.assertEqual(sorted(r[0] for r in rset.rows), sorted(groupeids - groupreadperms)) |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
367 |
rset = self.execute('DISTINCT Any Y WHERE X name "CWGroup", Y eid IN(2, 3, 4), 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:
6209
diff
changeset
|
368 |
self.assertEqual(sorted(r[0] for r in rset.rows), sorted(groupeids - groupreadperms)) |
1787 | 369 |
|
0 | 370 |
def test_select_outer_join(self): |
371 |
peid1 = self.execute("INSERT Personne X: X nom 'bidule'")[0][0] |
|
372 |
peid2 = self.execute("INSERT Personne X: X nom 'autre'")[0][0] |
|
373 |
seid1 = self.execute("INSERT Societe X: X nom 'chouette'")[0][0] |
|
374 |
seid2 = self.execute("INSERT Societe X: X nom 'chouetos'")[0][0] |
|
375 |
rset = self.execute('Any X,S ORDERBY X 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:
6209
diff
changeset
|
376 |
self.assertEqual(rset.rows, [[peid1, None], [peid2, None]]) |
0 | 377 |
self.execute("SET P travaille S WHERE P nom 'bidule', S nom 'chouette'") |
378 |
rset = self.execute('Any X,S ORDERBY X 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:
6209
diff
changeset
|
379 |
self.assertEqual(rset.rows, [[peid1, seid1], [peid2, None]]) |
0 | 380 |
rset = self.execute('Any S,X ORDERBY 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:
6209
diff
changeset
|
381 |
self.assertEqual(rset.rows, [[seid1, peid1], [seid2, None]]) |
1787 | 382 |
|
0 | 383 |
def test_select_outer_join_optimized(self): |
384 |
peid1 = self.execute("INSERT Personne X: X nom 'bidule'")[0][0] |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
385 |
rset = self.execute('Any X WHERE X eid %(x)s, P? connait X', {'x':peid1}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
386 |
self.assertEqual(rset.rows, [[peid1]]) |
2608
21856eda34f6
[F repo tests] tests have to be updated:
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
387 |
rset = self.execute('Any X WHERE X eid %(x)s, X require_permission P?', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
388 |
{'x':peid1}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
389 |
self.assertEqual(rset.rows, [[peid1]]) |
0 | 390 |
|
391 |
def test_select_left_outer_join(self): |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
392 |
rset = self.execute('DISTINCT Any G WHERE U? in_group G') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
393 |
self.assertEqual(len(rset), 4) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
394 |
rset = self.execute('DISTINCT Any G WHERE U? in_group G, U eid %(x)s', |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
395 |
{'x': self.session.user.eid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
396 |
self.assertEqual(len(rset), 4) |
0 | 397 |
|
398 |
def test_select_ambigous_outer_join(self): |
|
399 |
teid = self.execute("INSERT Tag X: X name 'tag'")[0][0] |
|
400 |
self.execute("INSERT Tag X: X name 'tagbis'")[0][0] |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
401 |
geid = self.execute("CWGroup G WHERE G name 'users'")[0][0] |
0 | 402 |
self.execute("SET X tags Y WHERE X eid %(t)s, Y eid %(g)s", |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
403 |
{'g': geid, 't': teid}) |
0 | 404 |
rset = self.execute("Any GN,TN ORDERBY GN WHERE T? tags G, T name TN, G name GN") |
405 |
self.failUnless(['users', 'tag'] in rset.rows) |
|
406 |
self.failUnless(['activated', None] in rset.rows) |
|
407 |
rset = self.execute("Any GN,TN ORDERBY GN WHERE T tags G?, T name TN, G name GN") |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
408 |
self.assertEqual(rset.rows, [[None, 'tagbis'], ['users', 'tag']]) |
1787 | 409 |
|
0 | 410 |
def test_select_not_inline_rel(self): |
411 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
412 |
self.execute("INSERT Note X: X type 'a'") |
|
413 |
self.execute("INSERT Note X: X type 'b'") |
|
414 |
self.execute("SET X ecrit_par Y WHERE X type 'a', Y nom 'bidule'") |
|
415 |
rset = self.execute('Note X WHERE NOT X ecrit_par P') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
416 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
1787 | 417 |
|
0 | 418 |
def test_select_not_unlinked_multiple_solutions(self): |
419 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
420 |
self.execute("INSERT Note X: X type 'a'") |
|
421 |
self.execute("INSERT Note X: X type 'b'") |
|
422 |
self.execute("SET Y evaluee X WHERE X type 'a', Y nom 'bidule'") |
|
423 |
rset = self.execute('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:
6209
diff
changeset
|
424 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
0 | 425 |
|
4831
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
426 |
def test_select_date_extraction(self): |
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
427 |
self.execute("INSERT Personne X: X nom 'foo', X datenaiss %(d)s", |
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
428 |
{'d': datetime(2001, 2,3, 12,13)}) |
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
429 |
test_data = [('YEAR', 2001), ('MONTH', 2), ('DAY', 3), |
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
430 |
('HOUR', 12), ('MINUTE', 13)] |
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
431 |
for funcname, result in test_data: |
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
432 |
rset = self.execute('Any %s(D) WHERE X is Personne, X datenaiss D' |
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
433 |
% funcname) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
434 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
435 |
self.assertEqual(rset.rows[0][0], result) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
436 |
self.assertEqual(rset.description, [('Int',)]) |
4831
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
437 |
|
0 | 438 |
def test_select_aggregat_count(self): |
439 |
rset = self.execute('Any COUNT(X)') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
440 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
441 |
self.assertEqual(len(rset.rows[0]), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
442 |
self.assertEqual(rset.description, [('Int',)]) |
1787 | 443 |
|
0 | 444 |
def test_select_aggregat_sum(self): |
445 |
rset = self.execute('Any SUM(O) WHERE X ordernum O') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
446 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
447 |
self.assertEqual(len(rset.rows[0]), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
448 |
self.assertEqual(rset.description, [('Int',)]) |
1787 | 449 |
|
0 | 450 |
def test_select_aggregat_min(self): |
451 |
rset = self.execute('Any MIN(X) WHERE X is Personne') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
452 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
453 |
self.assertEqual(len(rset.rows[0]), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
454 |
self.assertEqual(rset.description, [('Personne',)]) |
0 | 455 |
rset = self.execute('Any MIN(O) WHERE X ordernum O') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
456 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
457 |
self.assertEqual(len(rset.rows[0]), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
458 |
self.assertEqual(rset.description, [('Int',)]) |
1787 | 459 |
|
0 | 460 |
def test_select_aggregat_max(self): |
461 |
rset = self.execute('Any MAX(X) WHERE X is Personne') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
462 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
463 |
self.assertEqual(len(rset.rows[0]), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
464 |
self.assertEqual(rset.description, [('Personne',)]) |
0 | 465 |
rset = self.execute('Any MAX(O) WHERE X ordernum O') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
466 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
467 |
self.assertEqual(len(rset.rows[0]), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
468 |
self.assertEqual(rset.description, [('Int',)]) |
0 | 469 |
|
470 |
def test_select_custom_aggregat_concat_string(self): |
|
4831
c5aec27c1bf7
[repo] use logilab.db instead of lgc.adbh/lgc.db/lgc.sqlgen/indexer, test new date extranction functions
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4795
diff
changeset
|
471 |
rset = self.execute('Any GROUP_CONCAT(N) WHERE X is CWGroup, X name N') |
0 | 472 |
self.failUnless(rset) |
473 |
self.failUnlessEqual(sorted(rset[0][0].split(', ')), ['guests', 'managers', |
|
474 |
'owners', 'users']) |
|
475 |
||
476 |
def test_select_custom_regproc_limit_size(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
477 |
rset = self.execute('Any TEXT_LIMIT_SIZE(N, 3) WHERE X is CWGroup, X name N, X name "managers"') |
0 | 478 |
self.failUnless(rset) |
479 |
self.failUnlessEqual(rset[0][0], 'man...') |
|
480 |
self.execute("INSERT Basket X: X name 'bidule', X description '<b>hop hop</b>', X description_format 'text/html'") |
|
481 |
rset = self.execute('Any LIMIT_SIZE(D, DF, 3) WHERE X is Basket, X description D, X description_format DF') |
|
482 |
self.failUnless(rset) |
|
483 |
self.failUnlessEqual(rset[0][0], 'hop...') |
|
484 |
||
485 |
def test_select_regproc_orderby(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
486 |
rset = self.execute('DISTINCT Any X,N ORDERBY GROUP_SORT_VALUE(N) WHERE X is CWGroup, X name N, X name "managers"') |
0 | 487 |
self.failUnlessEqual(len(rset), 1) |
488 |
self.failUnlessEqual(rset[0][1], 'managers') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
489 |
rset = self.execute('Any X,N ORDERBY GROUP_SORT_VALUE(N) WHERE X is CWGroup, X name N, NOT U in_group X, U login "admin"') |
0 | 490 |
self.failUnlessEqual(len(rset), 3) |
491 |
self.failUnlessEqual(rset[0][1], 'owners') |
|
1787 | 492 |
|
0 | 493 |
def test_select_aggregat_sort(self): |
494 |
rset = self.execute('Any G, COUNT(U) GROUPBY G ORDERBY 2 WHERE U in_group G') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
495 |
self.assertEqual(len(rset.rows), 2) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
496 |
self.assertEqual(len(rset.rows[0]), 2) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
497 |
self.assertEqual(rset.description[0], ('CWGroup', 'Int',)) |
0 | 498 |
|
499 |
def test_select_aggregat_having(self): |
|
500 |
rset = self.execute('Any N,COUNT(RDEF) GROUPBY N ORDERBY 2,N ' |
|
501 |
'WHERE RT name N, RDEF relation_type RT ' |
|
502 |
'HAVING COUNT(RDEF) > 10') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
503 |
self.assertListEqual(rset.rows, |
5575
8a531340c3ef
no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
504 |
[[u'description_format', 12], |
8a531340c3ef
no more Image type w/ cw 3.9
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
505 |
[u'description', 13], |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
506 |
[u'name', 15], |
6944
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
507 |
[u'created_by', 41], |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
508 |
[u'creation_date', 41], |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
509 |
[u'cw_source', 41], |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
510 |
[u'cwuri', 41], |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
511 |
[u'in_basket', 41], |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
512 |
[u'is', 41], |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
513 |
[u'is_instance_of', 41], |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
514 |
[u'modification_date', 41], |
0cf10429ad39
[sources] rewrite the way pyrorql mapping are stored in the database so it can be reused for other sources (eg datafeed+cwxml)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6781
diff
changeset
|
515 |
[u'owned_by', 41]]) |
0 | 516 |
|
517 |
def test_select_aggregat_having_dumb(self): |
|
518 |
# dumb but should not raise an error |
|
519 |
rset = self.execute('Any U,COUNT(X) GROUPBY U ' |
|
520 |
'WHERE U eid %(x)s, X owned_by U ' |
|
521 |
'HAVING COUNT(X) > 10', {'x': self.ueid}) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
522 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
523 |
self.assertEqual(rset.rows[0][0], self.ueid) |
0 | 524 |
|
5782
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
525 |
def test_select_having_non_aggregat_1(self): |
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
526 |
rset = self.execute('Any L WHERE X login L, X creation_date CD ' |
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
527 |
'HAVING YEAR(CD) = %s' % date.today().year) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
528 |
self.assertListEqual(rset.rows, |
5782
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
529 |
[[u'admin'], |
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
530 |
[u'anon']]) |
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
531 |
|
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
532 |
def test_select_having_non_aggregat_2(self): |
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
533 |
rset = self.execute('Any L GROUPBY L WHERE X login L, X in_group G, ' |
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
534 |
'X creation_date CD HAVING YEAR(CD) = %s OR COUNT(G) > 1' |
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
535 |
% date.today().year) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
536 |
self.assertListEqual(rset.rows, |
5782
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
537 |
[[u'admin'], |
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
538 |
[u'anon']]) |
8ff48d1a319f
[rql2sql] when using HAVING to by-pass rql limitation (not to filter on result of an aggregat function), we should emit SQL that doesn't use HAVING to avoid potential backend error because variables are not grouped. Closes #1061603.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5701
diff
changeset
|
539 |
|
0 | 540 |
def test_select_complex_sort(self): |
1950
ab7a41b2cd26
reactivate skipped tests due to sqlite bug which is now fixed (sqlite 3.6.13)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1949
diff
changeset
|
541 |
"""need sqlite including http://www.sqlite.org/cvstrac/tktview?tn=3773 fix""" |
0 | 542 |
rset = self.execute('Any X ORDERBY X,D LIMIT 5 WHERE X creation_date D') |
543 |
result = rset.rows |
|
544 |
result.sort() |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
545 |
self.assertEqual(tuplify(result), [(1,), (2,), (3,), (4,), (5,)]) |
1787 | 546 |
|
0 | 547 |
def test_select_upper(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
548 |
rset = self.execute('Any X, UPPER(L) ORDERBY L WHERE X is CWUser, X login L') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
549 |
self.assertEqual(len(rset.rows), 2) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
550 |
self.assertEqual(rset.rows[0][1], 'ADMIN') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
551 |
self.assertEqual(rset.description[0], ('CWUser', 'String',)) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
552 |
self.assertEqual(rset.rows[1][1], 'ANON') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
553 |
self.assertEqual(rset.description[1], ('CWUser', 'String',)) |
0 | 554 |
eid = rset.rows[0][0] |
555 |
rset = self.execute('Any UPPER(L) WHERE X eid %s, X login L'%eid) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
556 |
self.assertEqual(rset.rows[0][0], 'ADMIN') |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
557 |
self.assertEqual(rset.description, [('String',)]) |
0 | 558 |
|
6081
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
559 |
def test_select_float_abs(self): |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
560 |
# test positive number |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
561 |
eid = self.execute('INSERT Affaire A: A invoiced %(i)s', {'i': 1.2})[0][0] |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
562 |
rset = self.execute('Any ABS(I) WHERE X eid %(x)s, X invoiced I', {'x': eid}) |
6366 | 563 |
self.assertEqual(rset.rows[0][0], 1.2) |
6081
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
564 |
# test negative number |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
565 |
eid = self.execute('INSERT Affaire A: A invoiced %(i)s', {'i': -1.2})[0][0] |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
566 |
rset = self.execute('Any ABS(I) WHERE X eid %(x)s, X invoiced I', {'x': eid}) |
6366 | 567 |
self.assertEqual(rset.rows[0][0], 1.2) |
6081
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
568 |
|
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
569 |
def test_select_int_abs(self): |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
570 |
# test positive number |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
571 |
eid = self.execute('INSERT Affaire A: A duration %(d)s', {'d': 12})[0][0] |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
572 |
rset = self.execute('Any ABS(D) WHERE X eid %(x)s, X duration D', {'x': eid}) |
6366 | 573 |
self.assertEqual(rset.rows[0][0], 12) |
6081
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
574 |
# test negative number |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
575 |
eid = self.execute('INSERT Affaire A: A duration %(d)s', {'d': -12})[0][0] |
ede33e6400ab
[forms] test abs() rql function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
6050
diff
changeset
|
576 |
rset = self.execute('Any ABS(D) WHERE X eid %(x)s, X duration D', {'x': eid}) |
6366 | 577 |
self.assertEqual(rset.rows[0][0], 12) |
578 |
||
0 | 579 |
## def test_select_simplified(self): |
580 |
## ueid = self.session.user.eid |
|
581 |
## rset = self.execute('Any L WHERE %s login L'%ueid) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
582 |
## self.assertEqual(rset.rows[0][0], 'admin') |
0 | 583 |
## rset = self.execute('Any L WHERE %(x)s login L', {'x':ueid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
584 |
## self.assertEqual(rset.rows[0][0], 'admin') |
1787 | 585 |
|
0 | 586 |
def test_select_searchable_text_1(self): |
587 |
rset = self.execute(u"INSERT Personne X: X nom 'bid�le'") |
|
588 |
rset = self.execute(u"INSERT Societe X: X nom 'bid�le'") |
|
589 |
rset = self.execute("INSERT Societe X: X nom 'chouette'") |
|
590 |
self.commit() |
|
591 |
rset = self.execute('Any X where X has_text %(text)s', {'text': u'bid�le'}) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
592 |
self.assertEqual(len(rset.rows), 2, rset.rows) |
0 | 593 |
rset = self.execute(u'Any N where N has_text "bid�le"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
594 |
self.assertEqual(len(rset.rows), 2, rset.rows) |
0 | 595 |
biduleeids = [r[0] for r in rset.rows] |
596 |
rset = self.execute(u'Any N where NOT N has_text "bid�le"') |
|
597 |
self.failIf([r[0] for r in rset.rows if r[0] in biduleeids]) |
|
598 |
# duh? |
|
599 |
rset = self.execute('Any X WHERE X has_text %(text)s', {'text': u'�a'}) |
|
1787 | 600 |
|
0 | 601 |
def test_select_searchable_text_2(self): |
602 |
rset = self.execute("INSERT Personne X: X nom 'bidule'") |
|
603 |
rset = self.execute("INSERT Personne X: X nom 'chouette'") |
|
604 |
rset = self.execute("INSERT Societe X: X nom 'bidule'") |
|
605 |
self.commit() |
|
606 |
rset = self.execute('Personne N where N has_text "bidule"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
607 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
1787 | 608 |
|
0 | 609 |
def test_select_searchable_text_3(self): |
610 |
rset = self.execute("INSERT Personne X: X nom 'bidule', X sexe 'M'") |
|
611 |
rset = self.execute("INSERT Personne X: X nom 'bidule', X sexe 'F'") |
|
612 |
rset = self.execute("INSERT Societe X: X nom 'bidule'") |
|
613 |
self.commit() |
|
614 |
rset = self.execute('Any X where X has_text "bidule" and X sexe "M"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
615 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
1787 | 616 |
|
0 | 617 |
def test_select_multiple_searchable_text(self): |
618 |
self.execute(u"INSERT Personne X: X nom 'bid�le'") |
|
619 |
self.execute("INSERT Societe X: X nom 'chouette', S travaille X") |
|
620 |
self.execute(u"INSERT Personne X: X nom 'bid�le'") |
|
621 |
self.commit() |
|
622 |
rset = self.execute('Personne X WHERE X has_text %(text)s, X travaille S, S has_text %(text2)s', |
|
623 |
{'text': u'bid�le', |
|
624 |
'text2': u'chouette',} |
|
625 |
) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
626 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
1787 | 627 |
|
0 | 628 |
def test_select_no_descr(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
629 |
rset = self.execute('Any X WHERE X is CWGroup', build_descr=0) |
0 | 630 |
rset.rows.sort() |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
631 |
self.assertEqual(tuplify(rset.rows), [(2,), (3,), (4,), (5,)]) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
632 |
self.assertEqual(rset.description, ()) |
0 | 633 |
|
634 |
def test_select_limit_offset(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
635 |
rset = self.execute('CWGroup X ORDERBY N LIMIT 2 WHERE X name N') |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
636 |
self.assertEqual(tuplify(rset.rows), [(2,), (3,)]) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
637 |
self.assertEqual(rset.description, [('CWGroup',), ('CWGroup',)]) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
638 |
rset = self.execute('CWGroup X ORDERBY N LIMIT 2 OFFSET 2 WHERE X name N') |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
639 |
self.assertEqual(tuplify(rset.rows), [(4,), (5,)]) |
1787 | 640 |
|
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4204
diff
changeset
|
641 |
def test_select_symmetric(self): |
0 | 642 |
self.execute("INSERT Personne X: X nom 'machin'") |
643 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
644 |
self.execute("INSERT Personne X: X nom 'chouette'") |
|
645 |
self.execute("INSERT Personne X: X nom 'trucmuche'") |
|
646 |
self.execute("SET X connait Y WHERE X nom 'chouette', Y nom 'bidule'") |
|
647 |
self.execute("SET X connait Y WHERE X nom 'machin', Y nom 'chouette'") |
|
648 |
rset = self.execute('Any P where P connait P2') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
649 |
self.assertEqual(len(rset.rows), 3, rset.rows) |
0 | 650 |
rset = self.execute('Any P where NOT P connait P2') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
651 |
self.assertEqual(len(rset.rows), 1, rset.rows) # trucmuche |
0 | 652 |
rset = self.execute('Any P where P connait P2, P2 nom "bidule"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
653 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
0 | 654 |
rset = self.execute('Any P where P2 connait P, P2 nom "bidule"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
655 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
0 | 656 |
rset = self.execute('Any P where P connait P2, P2 nom "chouette"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
657 |
self.assertEqual(len(rset.rows), 2, rset.rows) |
0 | 658 |
rset = self.execute('Any P where P2 connait P, P2 nom "chouette"') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
659 |
self.assertEqual(len(rset.rows), 2, rset.rows) |
1787 | 660 |
|
0 | 661 |
def test_select_inline(self): |
662 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
663 |
self.execute("INSERT Note X: X type 'a'") |
|
664 |
self.execute("SET X ecrit_par Y WHERE X type 'a', Y nom 'bidule'") |
|
665 |
rset = self.execute('Any N where N ecrit_par X, X nom "bidule"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
666 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
1787 | 667 |
|
0 | 668 |
def test_select_creation_date(self): |
669 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
670 |
rset = self.execute('Any D WHERE X nom "bidule", X creation_date D') |
|
671 |
self.assertEqual(len(rset.rows), 1) |
|
672 |
||
673 |
def test_select_or_relation(self): |
|
674 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
675 |
self.execute("INSERT Personne X: X nom 'chouette'") |
|
676 |
self.execute("INSERT Societe X: X nom 'logilab'") |
|
677 |
self.execute("INSERT Societe X: X nom 'caesium'") |
|
678 |
self.execute("SET P travaille S WHERE P nom 'bidule', S nom 'logilab'") |
|
679 |
rset = self.execute('DISTINCT Any P WHERE P travaille S1 OR P travaille S2, S1 nom "logilab", S2 nom "caesium"') |
|
680 |
self.assertEqual(len(rset.rows), 1) |
|
681 |
self.execute("SET P travaille S WHERE P nom 'chouette', S nom 'caesium'") |
|
682 |
rset = self.execute('DISTINCT Any P WHERE P travaille S1 OR P travaille S2, S1 nom "logilab", S2 nom "caesium"') |
|
683 |
self.assertEqual(len(rset.rows), 2) |
|
1787 | 684 |
|
0 | 685 |
def test_select_or_sym_relation(self): |
686 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
687 |
self.execute("INSERT Personne X: X nom 'chouette'") |
|
688 |
self.execute("INSERT Personne X: X nom 'truc'") |
|
689 |
self.execute("SET P connait S WHERE P nom 'bidule', S nom 'chouette'") |
|
690 |
rset = self.execute('DISTINCT Any P WHERE S connait P, S nom "chouette"') |
|
691 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
|
692 |
rset = self.execute('DISTINCT Any P WHERE P connait S or S connait P, S nom "chouette"') |
|
693 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
|
694 |
self.execute("SET P connait S WHERE P nom 'chouette', S nom 'truc'") |
|
695 |
rset = self.execute('DISTINCT Any P WHERE S connait P, S nom "chouette"') |
|
696 |
self.assertEqual(len(rset.rows), 2, rset.rows) |
|
697 |
rset = self.execute('DISTINCT Any P WHERE P connait S OR S connait P, S nom "chouette"') |
|
698 |
self.assertEqual(len(rset.rows), 2, rset.rows) |
|
1787 | 699 |
|
0 | 700 |
def test_select_follow_relation(self): |
701 |
self.execute("INSERT Affaire X: X sujet 'cool'") |
|
702 |
self.execute("INSERT Societe X: X nom 'chouette'") |
|
703 |
self.execute("SET A concerne S WHERE A is Affaire, S is Societe") |
|
704 |
self.execute("INSERT Note X: X para 'truc'") |
|
705 |
self.execute("SET S evaluee N WHERE S is Societe, N is Note") |
|
706 |
self.execute("INSERT Societe X: X nom 'bidule'") |
|
707 |
self.execute("INSERT Note X: X para 'troc'") |
|
708 |
self.execute("SET S evaluee N WHERE S nom 'bidule', N para 'troc'") |
|
709 |
rset = self.execute('DISTINCT Any A,N WHERE A concerne S, S evaluee N') |
|
710 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
|
711 |
||
712 |
def test_select_ordered_distinct_1(self): |
|
6194
2a1f8cabbe6a
[querier test] remove some actually bad tests that were passing thanks to a sqlite bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6189
diff
changeset
|
713 |
self.assertRaises(BadRQLQuery, |
2a1f8cabbe6a
[querier test] remove some actually bad tests that were passing thanks to a sqlite bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6189
diff
changeset
|
714 |
self.execute, 'DISTINCT Any S ORDERBY R WHERE A is Affaire, A sujet S, A ref R') |
0 | 715 |
|
716 |
def test_select_ordered_distinct_2(self): |
|
717 |
self.execute("INSERT Affaire X: X sujet 'minor'") |
|
718 |
self.execute("INSERT Affaire X: X sujet 'zou'") |
|
719 |
self.execute("INSERT Affaire X: X sujet 'abcd'") |
|
720 |
rset = self.execute('DISTINCT Any S ORDERBY S WHERE A is Affaire, A sujet S') |
|
6196 | 721 |
self.assertEqual(rset.rows, [['abcd'], ['minor'], ['zou']]) |
1787 | 722 |
|
0 | 723 |
def test_select_ordered_distinct_3(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
724 |
rset = self.execute('DISTINCT Any N ORDERBY GROUP_SORT_VALUE(N) WHERE X is CWGroup, X name N') |
0 | 725 |
self.assertEqual(rset.rows, [['owners'], ['guests'], ['users'], ['managers']]) |
726 |
||
727 |
def test_select_or_value(self): |
|
728 |
rset = self.execute('Any U WHERE U in_group G, G name "owners" OR G name "users"') |
|
729 |
self.assertEqual(len(rset.rows), 0) |
|
730 |
rset = self.execute('Any U WHERE U in_group G, G name "guests" OR G name "managers"') |
|
731 |
self.assertEqual(len(rset.rows), 2) |
|
732 |
||
733 |
def test_select_explicit_eid(self): |
|
734 |
rset = self.execute('Any X,E WHERE X owned_by U, X eid E, U eid %(u)s', {'u': self.session.user.eid}) |
|
735 |
self.failUnless(rset) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
736 |
self.assertEqual(rset.description[0][1], 'Int') |
1787 | 737 |
|
0 | 738 |
# def test_select_rewritten_optional(self): |
739 |
# eid = self.execute("INSERT Affaire X: X sujet 'cool'")[0][0] |
|
740 |
# rset = self.execute('Any X WHERE X eid %(x)s, EXISTS(X owned_by U) OR EXISTS(X concerne S?, S owned_by U)', |
|
741 |
# {'x': eid}, 'x') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
742 |
# self.assertEqual(rset.rows, [[eid]]) |
1787 | 743 |
|
0 | 744 |
def test_today_bug(self): |
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
745 |
self.execute("INSERT Tag X: X name 'bidule', X creation_date NOW") |
0 | 746 |
self.execute("INSERT Tag Y: Y name 'toto'") |
747 |
rset = self.execute("Any D WHERE X name in ('bidule', 'toto') , X creation_date D") |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
748 |
self.assert_(isinstance(rset.rows[0][0], datetime), rset.rows) |
0 | 749 |
rset = self.execute('Tag X WHERE X creation_date TODAY') |
750 |
self.assertEqual(len(rset.rows), 2) |
|
751 |
rset = self.execute('Any MAX(D) WHERE X is Tag, X creation_date D') |
|
7078
bad26a22fe29
[test] New Handling of database for test.
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7043
diff
changeset
|
752 |
self.failUnless(isinstance(rset[0][0], datetime), (rset[0][0], type(rset[0][0]))) |
0 | 753 |
|
754 |
def test_today(self): |
|
755 |
self.execute("INSERT Tag X: X name 'bidule', X creation_date TODAY") |
|
756 |
self.execute("INSERT Tag Y: Y name 'toto'") |
|
757 |
rset = self.execute('Tag X WHERE X creation_date TODAY') |
|
758 |
self.assertEqual(len(rset.rows), 2) |
|
759 |
||
760 |
def test_select_boolean(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
761 |
rset = self.execute('Any N WHERE X is CWEType, X name N, X final %(val)s', |
0 | 762 |
{'val': True}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
763 |
self.assertEqual(sorted(r[0] for r in rset.rows), ['Boolean', 'Bytes', |
0 | 764 |
'Date', 'Datetime', |
765 |
'Decimal', 'Float', |
|
766 |
'Int', 'Interval', |
|
767 |
'Password', 'String', |
|
768 |
'Time']) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
769 |
rset = self.execute('Any N WHERE X is CWEType, X name N, X final TRUE') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
770 |
self.assertEqual(sorted(r[0] for r in rset.rows), ['Boolean', 'Bytes', |
0 | 771 |
'Date', 'Datetime', |
772 |
'Decimal', 'Float', |
|
773 |
'Int', 'Interval', |
|
774 |
'Password', 'String', |
|
775 |
'Time']) |
|
1787 | 776 |
|
0 | 777 |
def test_select_constant(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
778 |
rset = self.execute('Any X, "toto" ORDERBY X WHERE X is CWGroup') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
779 |
self.assertEqual(rset.rows, |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
780 |
map(list, zip((2,3,4,5), ('toto','toto','toto','toto',)))) |
0 | 781 |
self.assertIsInstance(rset[0][1], unicode) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
782 |
self.assertEqual(rset.description, |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
783 |
zip(('CWGroup', 'CWGroup', 'CWGroup', 'CWGroup'), |
0 | 784 |
('String', 'String', 'String', 'String',))) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
785 |
rset = self.execute('Any X, %(value)s ORDERBY X WHERE X is CWGroup', {'value': 'toto'}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
786 |
self.assertEqual(rset.rows, |
6427
c8a5ac2d1eaa
[schema / sources] store data sources as cubicweb entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6366
diff
changeset
|
787 |
map(list, zip((2,3,4,5), ('toto','toto','toto','toto',)))) |
0 | 788 |
self.assertIsInstance(rset[0][1], unicode) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
789 |
self.assertEqual(rset.description, |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
790 |
zip(('CWGroup', 'CWGroup', 'CWGroup', 'CWGroup'), |
0 | 791 |
('String', 'String', 'String', 'String',))) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
792 |
rset = self.execute('Any X,GN WHERE X is CWUser, G is CWGroup, X login "syt", X in_group G, G name GN') |
0 | 793 |
|
794 |
def test_select_union(self): |
|
795 |
rset = self.execute('Any X,N ORDERBY N WITH X,N BEING ' |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
796 |
'((Any X,N WHERE X name N, X transition_of WF, WF workflow_of E, E name %(name)s)' |
0 | 797 |
' UNION ' |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
798 |
'(Any X,N WHERE X name N, X state_of WF, WF workflow_of E, E name %(name)s))', |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
799 |
{'name': 'CWUser'}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
800 |
self.assertEqual([x[1] for x in rset.rows], |
0 | 801 |
['activate', 'activated', 'deactivate', 'deactivated']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
802 |
self.assertEqual(rset.description, |
0 | 803 |
[('Transition', 'String'), ('State', 'String'), |
804 |
('Transition', 'String'), ('State', 'String')]) |
|
1787 | 805 |
|
0 | 806 |
def test_select_union_aggregat(self): |
807 |
# meaningless, the goal in to have group by done on different attribute |
|
808 |
# for each sub-query |
|
809 |
self.execute('(Any N,COUNT(X) GROUPBY N WHERE X name N, X is State)' |
|
810 |
' UNION ' |
|
811 |
'(Any N,COUNT(X) GROUPBY N ORDERBY 2 WHERE X login N)') |
|
1787 | 812 |
|
0 | 813 |
def test_select_union_aggregat_independant_group(self): |
814 |
self.execute('INSERT State X: X name "hop"') |
|
815 |
self.execute('INSERT State X: X name "hop"') |
|
816 |
self.execute('INSERT Transition X: X name "hop"') |
|
817 |
self.execute('INSERT Transition X: X name "hop"') |
|
818 |
rset = self.execute('Any N,NX ORDERBY 2 WITH N,NX BEING ' |
|
819 |
'((Any N,COUNT(X) GROUPBY N WHERE X name N, X is State HAVING COUNT(X)>1)' |
|
820 |
' UNION ' |
|
821 |
'(Any N,COUNT(X) GROUPBY N WHERE X name N, X is Transition HAVING COUNT(X)>1))') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
822 |
self.assertEqual(rset.rows, [[u'hop', 2], [u'hop', 2]]) |
1787 | 823 |
|
0 | 824 |
def test_select_union_selection_with_diff_variables(self): |
825 |
rset = self.execute('(Any N WHERE X name N, X is State)' |
|
826 |
' UNION ' |
|
827 |
'(Any NN WHERE XX name NN, XX is Transition)') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
828 |
self.assertEqual(sorted(r[0] for r in rset.rows), |
0 | 829 |
['abort', 'activate', 'activated', 'ben non', |
830 |
'deactivate', 'deactivated', 'done', 'en cours', |
|
831 |
'end', 'finie', 'markasdone', 'pitetre', 'redoit', |
|
832 |
'start', 'todo']) |
|
1787 | 833 |
|
5701
41119f034735
[querier] fix rset description bug with some union queries
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5657
diff
changeset
|
834 |
def test_select_union_description_diff_var(self): |
41119f034735
[querier] fix rset description bug with some union queries
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5657
diff
changeset
|
835 |
eid1 = self.execute('CWGroup X WHERE X name "managers"')[0][0] |
41119f034735
[querier] fix rset description bug with some union queries
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5657
diff
changeset
|
836 |
eid2 = self.execute('CWUser X WHERE X login "admin"')[0][0] |
41119f034735
[querier] fix rset description bug with some union queries
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5657
diff
changeset
|
837 |
rset = self.execute('(Any X WHERE X eid %(x)s)' |
41119f034735
[querier] fix rset description bug with some union queries
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5657
diff
changeset
|
838 |
' UNION ' |
41119f034735
[querier] fix rset description bug with some union queries
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5657
diff
changeset
|
839 |
'(Any Y WHERE Y eid %(y)s)', |
41119f034735
[querier] fix rset description bug with some union queries
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5657
diff
changeset
|
840 |
{'x': eid1, 'y': eid2}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
841 |
self.assertEqual(rset.description[:], [('CWGroup',), ('CWUser',)]) |
5701
41119f034735
[querier] fix rset description bug with some union queries
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5657
diff
changeset
|
842 |
|
0 | 843 |
def test_exists(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
844 |
geid = self.execute("INSERT CWGroup X: X name 'lulufanclub'")[0][0] |
0 | 845 |
self.execute("SET U in_group G WHERE G name 'lulufanclub'") |
846 |
peid = self.execute("INSERT Personne X: X prenom 'lulu', X nom 'petit'")[0][0] |
|
847 |
rset = self.execute("Any X WHERE X prenom 'lulu'," |
|
848 |
"EXISTS (U in_group G, G name 'lulufanclub' OR G name 'managers');") |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
849 |
self.assertEqual(rset.rows, [[peid]]) |
0 | 850 |
|
851 |
def test_identity(self): |
|
852 |
eid = self.execute('Any X WHERE X identity Y, Y eid 1')[0][0] |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
853 |
self.assertEqual(eid, 1) |
0 | 854 |
eid = self.execute('Any X WHERE Y identity X, Y eid 1')[0][0] |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
855 |
self.assertEqual(eid, 1) |
0 | 856 |
login = self.execute('Any L WHERE X login "admin", X identity Y, Y login L')[0][0] |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
857 |
self.assertEqual(login, 'admin') |
0 | 858 |
|
859 |
def test_select_date_mathexp(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
860 |
rset = self.execute('Any X, TODAY - CD WHERE X is CWUser, X creation_date CD') |
0 | 861 |
self.failUnless(rset) |
862 |
self.failUnlessEqual(rset.description[0][1], 'Interval') |
|
863 |
eid, = self.execute("INSERT Personne X: X nom 'bidule'")[0] |
|
864 |
rset = self.execute('Any X, NOW - CD WHERE X is Personne, X creation_date CD') |
|
865 |
self.failUnlessEqual(rset.description[0][1], 'Interval') |
|
866 |
||
6050
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
867 |
def test_select_subquery_aggregat_1(self): |
0 | 868 |
# percent users by groups |
869 |
self.execute('SET X in_group G WHERE G name "users"') |
|
870 |
rset = self.execute('Any GN, COUNT(X)*100/T GROUPBY GN ORDERBY 2,1' |
|
871 |
' WHERE G name GN, X in_group G' |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
872 |
' WITH T BEING (Any COUNT(U) WHERE U is CWUser)') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
873 |
self.assertEqual(rset.rows, [[u'guests', 50], [u'managers', 50], [u'users', 100]]) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
874 |
self.assertEqual(rset.description, [('String', 'Int'), ('String', 'Int'), ('String', 'Int')]) |
0 | 875 |
|
6050
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
876 |
def test_select_subquery_aggregat_2(self): |
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
877 |
expected = self.execute('Any X, 0, COUNT(T) GROUPBY X ' |
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
878 |
'WHERE X is Workflow, T transition_of X').rows |
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
879 |
rset = self.execute(''' |
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
880 |
Any P1,B,E WHERE P1 identity P2 WITH |
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
881 |
P1,B BEING (Any P,COUNT(T) GROUPBY P WHERE P is Workflow, T is Transition, |
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
882 |
T? transition_of P, T type "auto"), |
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
883 |
P2,E BEING (Any P,COUNT(T) GROUPBY P WHERE P is Workflow, T is Transition, |
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
884 |
T? transition_of P, T type "normal")''') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
885 |
self.assertEqual(sorted(rset.rows), sorted(expected)) |
6050
20af96a6fffc
[rql2sql] add test for rql bug #37423, which triggered a cw bug fixed by this changeset (infinite loop with some queries...)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5811
diff
changeset
|
886 |
|
0 | 887 |
def test_select_subquery_const(self): |
888 |
rset = self.execute('Any X WITH X BEING ((Any NULL) UNION (Any "toto"))') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
889 |
self.assertEqual(rset.rows, [[None], ['toto']]) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
890 |
self.assertEqual(rset.description, [(None,), ('String',)]) |
1787 | 891 |
|
0 | 892 |
# insertion queries tests ################################################# |
1787 | 893 |
|
0 | 894 |
def test_insert_is(self): |
895 |
eid, = self.execute("INSERT Personne X: X nom 'bidule'")[0] |
|
896 |
etype, = self.execute("Any TN WHERE X is T, X eid %s, T name TN" % eid)[0] |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
897 |
self.assertEqual(etype, 'Personne') |
0 | 898 |
self.execute("INSERT Personne X: X nom 'managers'") |
1787 | 899 |
|
0 | 900 |
def test_insert_1(self): |
901 |
rset = self.execute("INSERT Personne X: X nom 'bidule'") |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
902 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
903 |
self.assertEqual(rset.description, [('Personne',)]) |
0 | 904 |
rset = self.execute('Personne X WHERE X nom "bidule"') |
905 |
self.assert_(rset.rows) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
906 |
self.assertEqual(rset.description, [('Personne',)]) |
0 | 907 |
|
908 |
def test_insert_1_multiple(self): |
|
909 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
910 |
self.execute("INSERT Personne X: X nom 'chouette'") |
|
911 |
rset = self.execute("INSERT Societe Y: Y nom N, P travaille Y WHERE P nom N") |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
912 |
self.assertEqual(len(rset.rows), 2) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
913 |
self.assertEqual(rset.description, [('Societe',), ('Societe',)]) |
0 | 914 |
|
915 |
def test_insert_2(self): |
|
916 |
rset = self.execute("INSERT Personne X, Personne Y: X nom 'bidule', Y nom 'tutu'") |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
917 |
self.assertEqual(rset.description, [('Personne', 'Personne')]) |
0 | 918 |
rset = self.execute('Personne X WHERE X nom "bidule" or X nom "tutu"') |
919 |
self.assert_(rset.rows) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
920 |
self.assertEqual(rset.description, [('Personne',), ('Personne',)]) |
0 | 921 |
|
922 |
def test_insert_3(self): |
|
923 |
self.execute("INSERT Personne X: X nom Y WHERE U login 'admin', U login Y") |
|
924 |
rset = self.execute('Personne X WHERE X nom "admin"') |
|
925 |
self.assert_(rset.rows) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
926 |
self.assertEqual(rset.description, [('Personne',)]) |
0 | 927 |
|
928 |
def test_insert_4(self): |
|
929 |
self.execute("INSERT Societe Y: Y nom 'toto'") |
|
930 |
self.execute("INSERT Personne X: X nom 'bidule', X travaille Y WHERE Y nom 'toto'") |
|
931 |
rset = self.execute('Any X, Y WHERE X nom "bidule", Y nom "toto", X travaille Y') |
|
932 |
self.assert_(rset.rows) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
933 |
self.assertEqual(rset.description, [('Personne', 'Societe',)]) |
1787 | 934 |
|
0 | 935 |
def test_insert_4bis(self): |
936 |
peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0] |
|
937 |
seid = self.execute("INSERT Societe Y: Y nom 'toto', X travaille Y WHERE X eid %(x)s", |
|
938 |
{'x': str(peid)})[0][0] |
|
939 |
self.assertEqual(len(self.execute('Any X, Y WHERE X travaille Y')), 1) |
|
940 |
self.execute("INSERT Personne X: X nom 'chouette', X travaille Y WHERE Y eid %(x)s", |
|
941 |
{'x': str(seid)}) |
|
942 |
self.assertEqual(len(self.execute('Any X, Y WHERE X travaille Y')), 2) |
|
1787 | 943 |
|
0 | 944 |
def test_insert_4ter(self): |
945 |
peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0] |
|
946 |
seid = self.execute("INSERT Societe Y: Y nom 'toto', X travaille Y WHERE X eid %(x)s", |
|
947 |
{'x': unicode(peid)})[0][0] |
|
948 |
self.assertEqual(len(self.execute('Any X, Y WHERE X travaille Y')), 1) |
|
949 |
self.execute("INSERT Personne X: X nom 'chouette', X travaille Y WHERE Y eid %(x)s", |
|
950 |
{'x': unicode(seid)}) |
|
951 |
self.assertEqual(len(self.execute('Any X, Y WHERE X travaille Y')), 2) |
|
952 |
||
953 |
def test_insert_5(self): |
|
954 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
955 |
self.execute("INSERT Societe Y: Y nom 'toto', X travaille Y WHERE X nom 'bidule'") |
|
956 |
rset = self.execute('Any X, Y WHERE X nom "bidule", Y nom "toto", X travaille Y') |
|
957 |
self.assert_(rset.rows) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
958 |
self.assertEqual(rset.description, [('Personne', 'Societe',)]) |
0 | 959 |
|
4765 | 960 |
def test_insert_5bis(self): |
961 |
peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0] |
|
962 |
self.execute("INSERT Societe Y: Y nom 'toto', X travaille Y WHERE X eid %(x)s", |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
963 |
{'x': peid}) |
4765 | 964 |
rset = self.execute('Any X, Y WHERE X nom "bidule", Y nom "toto", X travaille Y') |
965 |
self.assert_(rset.rows) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
966 |
self.assertEqual(rset.description, [('Personne', 'Societe',)]) |
4765 | 967 |
|
0 | 968 |
def test_insert_6(self): |
969 |
self.execute("INSERT Personne X, Societe Y: X nom 'bidule', Y nom 'toto', X travaille Y") |
|
970 |
rset = self.execute('Any X, Y WHERE X nom "bidule", Y nom "toto", X travaille Y') |
|
971 |
self.assert_(rset.rows) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
972 |
self.assertEqual(rset.description, [('Personne', 'Societe',)]) |
0 | 973 |
|
974 |
def test_insert_7(self): |
|
975 |
self.execute("INSERT Personne X, Societe Y: X nom N, Y nom 'toto', X travaille Y WHERE U login 'admin', U login N") |
|
976 |
rset = self.execute('Any X, Y WHERE X nom "admin", Y nom "toto", X travaille Y') |
|
977 |
self.assert_(rset.rows) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
978 |
self.assertEqual(rset.description, [('Personne', 'Societe',)]) |
0 | 979 |
|
5657
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
980 |
def test_insert_7_2(self): |
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
981 |
self.execute("INSERT Personne X, Societe Y: X nom N, Y nom 'toto', X travaille Y WHERE U login N") |
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
982 |
rset = self.execute('Any X, Y WHERE Y nom "toto", X travaille Y') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
983 |
self.assertEqual(len(rset), 2) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
984 |
self.assertEqual(rset.description, [('Personne', 'Societe',), |
5657
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
985 |
('Personne', 'Societe',)]) |
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
986 |
|
0 | 987 |
def test_insert_8(self): |
988 |
self.execute("INSERT Societe Y, Personne X: Y nom N, X nom 'toto', X travaille Y WHERE U login 'admin', U login N") |
|
989 |
rset = self.execute('Any X, Y WHERE X nom "toto", Y nom "admin", X travaille Y') |
|
990 |
self.assert_(rset.rows) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
991 |
self.assertEqual(rset.description, [('Personne', 'Societe',)]) |
0 | 992 |
|
5657
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
993 |
def test_insert_9(self): |
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
994 |
self.execute("INSERT Societe X: X nom 'Lo'") |
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
995 |
self.execute("INSERT Societe X: X nom 'Gi'") |
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
996 |
self.execute("INSERT SubDivision X: X nom 'Lab'") |
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
997 |
rset = self.execute("INSERT Personne X: X nom N, X travaille Y, X travaille_subdivision Z WHERE Y is Societe, Z is SubDivision, Y nom N") |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
998 |
self.assertEqual(len(rset), 2) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
999 |
self.assertEqual(rset.description, [('Personne',), ('Personne',)]) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1000 |
# self.assertSetEqual(set(x.nom for x in rset.entities()), |
5657
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1001 |
# ['Lo', 'Gi']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1002 |
# self.assertSetEqual(set(y.nom for x in rset.entities() for y in x.travaille), |
5657
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1003 |
# ['Lo', 'Gi']) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1004 |
# self.assertEqual([y.nom for x in rset.entities() for y in x.travaille_subdivision], |
5657
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1005 |
# ['Lab', 'Lab']) |
8f56691f01de
[querier] test and fix potential bug in insertion query with multiple relations inside, caused by a name conflict. Also fix another bug non reproduced by using a set instead of a list (list may leads to compare entity instances which isn't allowed).
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
1006 |
|
0 | 1007 |
def test_insert_query_error(self): |
1008 |
self.assertRaises(Exception, |
|
1009 |
self.execute, |
|
1010 |
"INSERT Personne X: X nom 'toto', X is Personne") |
|
1011 |
self.assertRaises(Exception, |
|
1012 |
self.execute, |
|
1013 |
"INSERT Personne X: X nom 'toto', X is_instance_of Personne") |
|
1014 |
self.assertRaises(QueryError, |
|
1015 |
self.execute, |
|
1016 |
"INSERT Personne X: X nom 'toto', X has_text 'tutu'") |
|
1017 |
||
1018 |
self.assertRaises(QueryError, |
|
1019 |
self.execute, |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1020 |
"INSERT CWUser X: X login 'toto', X eid %s" % cnx.user(self.session).eid) |
0 | 1021 |
|
1022 |
def test_insertion_description_with_where(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1023 |
rset = self.execute('INSERT CWUser E, EmailAddress EM: E login "X", E upassword "X", ' |
0 | 1024 |
'E primary_email EM, EM address "X", E in_group G ' |
1025 |
'WHERE G name "managers"') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1026 |
self.assertEqual(list(rset.description[0]), ['CWUser', 'EmailAddress']) |
1787 | 1027 |
|
0 | 1028 |
# deletion queries tests ################################################## |
1029 |
||
1030 |
def test_delete_1(self): |
|
1031 |
self.execute("INSERT Personne Y: Y nom 'toto'") |
|
1032 |
rset = self.execute('Personne X WHERE X nom "toto"') |
|
1033 |
self.assertEqual(len(rset.rows), 1) |
|
3648
665c37544060
on entity deletion query, return eids of deleted entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3589
diff
changeset
|
1034 |
drset = self.execute("DELETE Personne Y WHERE Y nom 'toto'") |
665c37544060
on entity deletion query, return eids of deleted entities
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3589
diff
changeset
|
1035 |
self.assertEqual(drset.rows, rset.rows) |
0 | 1036 |
rset = self.execute('Personne X WHERE X nom "toto"') |
1037 |
self.assertEqual(len(rset.rows), 0) |
|
1787 | 1038 |
|
0 | 1039 |
def test_delete_2(self): |
1040 |
rset = self.execute("INSERT Personne X, Personne Y, Societe Z : X nom 'syt', Y nom 'adim', Z nom 'Logilab', X travaille Z, Y travaille Z") |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1041 |
self.assertEqual(len(rset), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1042 |
self.assertEqual(len(rset[0]), 3) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1043 |
self.assertEqual(rset.description[0], ('Personne', 'Personne', 'Societe')) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1044 |
self.assertEqual(self.execute('Any N WHERE X nom N, X eid %s'% rset[0][0])[0][0], 'syt') |
0 | 1045 |
rset = self.execute('Personne X WHERE X travaille Y, Y nom "Logilab"') |
1046 |
self.assertEqual(len(rset.rows), 2, rset.rows) |
|
1047 |
self.execute("DELETE X travaille Y WHERE X is Personne, Y nom 'Logilabo'") |
|
1048 |
rset = self.execute('Personne X WHERE X travaille Y, Y nom "Logilab"') |
|
1049 |
self.assertEqual(len(rset.rows), 2, rset.rows) |
|
1050 |
self.execute("DELETE X travaille Y WHERE X is Personne, Y nom 'Logilab'") |
|
1051 |
rset = self.execute('Personne X WHERE X travaille Y, Y nom "Logilab"') |
|
1052 |
self.assertEqual(len(rset.rows), 0, rset.rows) |
|
1053 |
||
1054 |
def test_delete_3(self): |
|
4674
3d509dbb473a
[test api] rename _user_session to user_groups_session, fix its arguments and return only the session, not (user, session) to make things clearer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
1055 |
s = self.user_groups_session('users') |
0 | 1056 |
peid, = self.o.execute(s, "INSERT Personne P: P nom 'toto'")[0] |
1057 |
seid, = self.o.execute(s, "INSERT Societe S: S nom 'logilab'")[0] |
|
1058 |
self.o.execute(s, "SET P travaille S") |
|
1059 |
rset = self.execute('Personne P WHERE P travaille S') |
|
1060 |
self.assertEqual(len(rset.rows), 1) |
|
1061 |
self.execute("DELETE X travaille Y WHERE X eid %s, Y eid %s" % (peid, seid)) |
|
1062 |
rset = self.execute('Personne P WHERE P travaille S') |
|
1063 |
self.assertEqual(len(rset.rows), 0) |
|
1064 |
||
4467
0e73d299730a
fix long-waiting symetric typo: should be spelled symmetric. Add auto database migration on schema deserialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4204
diff
changeset
|
1065 |
def test_delete_symmetric(self): |
0 | 1066 |
teid1 = self.execute("INSERT Folder T: T name 'toto'")[0][0] |
1067 |
teid2 = self.execute("INSERT Folder T: T name 'tutu'")[0][0] |
|
1068 |
self.execute('SET X see_also Y WHERE X eid %s, Y eid %s' % (teid1, teid2)) |
|
1069 |
rset = self.execute('Any X,Y WHERE X see_also Y') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1070 |
self.assertEqual(len(rset) , 2, rset.rows) |
0 | 1071 |
self.execute('DELETE X see_also Y WHERE X eid %s, Y eid %s' % (teid1, teid2)) |
1072 |
rset = self.execute('Any X,Y WHERE X see_also Y') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1073 |
self.assertEqual(len(rset) , 0) |
0 | 1074 |
self.execute('SET X see_also Y WHERE X eid %s, Y eid %s' % (teid1, teid2)) |
1075 |
rset = self.execute('Any X,Y WHERE X see_also Y') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1076 |
self.assertEqual(len(rset) , 2) |
0 | 1077 |
self.execute('DELETE X see_also Y WHERE X eid %s, Y eid %s' % (teid2, teid1)) |
1078 |
rset = self.execute('Any X,Y WHERE X see_also Y') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1079 |
self.assertEqual(len(rset) , 0) |
0 | 1080 |
|
1081 |
def test_nonregr_delete_cache(self): |
|
1082 |
"""test that relations are properly cleaned when an entity is deleted |
|
1083 |
(using cachekey on sql generation returned always the same query for an eid, |
|
1084 |
whatever the relation) |
|
1085 |
""" |
|
4674
3d509dbb473a
[test api] rename _user_session to user_groups_session, fix its arguments and return only the session, not (user, session) to make things clearer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4467
diff
changeset
|
1086 |
s = self.user_groups_session('users') |
0 | 1087 |
aeid, = self.o.execute(s, 'INSERT EmailAddress X: X address "toto@logilab.fr", X alias "hop"')[0] |
1088 |
# XXX would be nice if the rql below was enough... |
|
1089 |
#'INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y' |
|
1090 |
eeid, = self.o.execute(s, 'INSERT Email X: X messageid "<1234>", X subject "test", X sender Y, X recipients Y WHERE Y is EmailAddress')[0] |
|
1091 |
self.o.execute(s, "DELETE Email X") |
|
1092 |
sqlc = s.pool['system'] |
|
1093 |
sqlc.execute('SELECT * FROM recipients_relation') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1094 |
self.assertEqual(len(sqlc.fetchall()), 0) |
0 | 1095 |
sqlc.execute('SELECT * FROM owned_by_relation WHERE eid_from=%s'%eeid) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1096 |
self.assertEqual(len(sqlc.fetchall()), 0) |
1787 | 1097 |
|
0 | 1098 |
def test_nonregr_delete_cache2(self): |
1099 |
eid = self.execute("INSERT Folder T: T name 'toto'")[0][0] |
|
1100 |
self.commit() |
|
1101 |
# fill the cache |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
1102 |
self.execute("Any X WHERE X eid %(x)s", {'x': eid}) |
6189 | 1103 |
self.execute("Any X WHERE X eid %s" % eid) |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
1104 |
self.execute("Folder X WHERE X eid %(x)s", {'x': eid}) |
6189 | 1105 |
self.execute("Folder X WHERE X eid %s" % eid) |
1106 |
self.execute("DELETE Folder T WHERE T eid %s" % eid) |
|
0 | 1107 |
self.commit() |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
1108 |
rset = self.execute("Any X WHERE X eid %(x)s", {'x': eid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1109 |
self.assertEqual(rset.rows, []) |
6189 | 1110 |
rset = self.execute("Any X WHERE X eid %s" % eid) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1111 |
self.assertEqual(rset.rows, []) |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
1112 |
rset = self.execute("Folder X WHERE X eid %(x)s", {'x': eid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1113 |
self.assertEqual(rset.rows, []) |
0 | 1114 |
rset = self.execute("Folder X WHERE X eid %s" %eid) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1115 |
self.assertEqual(rset.rows, []) |
1787 | 1116 |
|
0 | 1117 |
# update queries tests #################################################### |
1118 |
||
1119 |
def test_update_1(self): |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
1120 |
peid = self.execute("INSERT Personne Y: Y nom 'toto'")[0][0] |
0 | 1121 |
rset = self.execute('Personne X WHERE X nom "toto"') |
1122 |
self.assertEqual(len(rset.rows), 1) |
|
2921
8e2544e78a5e
test and fix rset returned by SET query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
1123 |
rset = self.execute("SET X nom 'tutu', X prenom 'original' WHERE X is Personne, X nom 'toto'") |
8e2544e78a5e
test and fix rset returned by SET query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
1124 |
self.assertEqual(tuplify(rset.rows), [(peid, 'tutu', 'original')]) |
0 | 1125 |
rset = self.execute('Any Y, Z WHERE X is Personne, X nom Y, X prenom Z') |
1126 |
self.assertEqual(tuplify(rset.rows), [('tutu', 'original')]) |
|
1787 | 1127 |
|
0 | 1128 |
def test_update_2(self): |
2921
8e2544e78a5e
test and fix rset returned by SET query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
1129 |
peid, seid = self.execute("INSERT Personne X, Societe Y: X nom 'bidule', Y nom 'toto'")[0] |
8e2544e78a5e
test and fix rset returned by SET query
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2920
diff
changeset
|
1130 |
rset = self.execute("SET X travaille Y WHERE X nom 'bidule', Y nom 'toto'") |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1131 |
self.assertEqual(tuplify(rset.rows), [(peid, seid)]) |
0 | 1132 |
rset = self.execute('Any X, Y WHERE X travaille Y') |
1133 |
self.assertEqual(len(rset.rows), 1) |
|
1787 | 1134 |
|
0 | 1135 |
def test_update_2bis(self): |
1136 |
rset = self.execute("INSERT Personne X, Societe Y: X nom 'bidule', Y nom 'toto'") |
|
1137 |
eid1, eid2 = rset[0][0], rset[0][1] |
|
1138 |
self.execute("SET X travaille Y WHERE X eid %(x)s, Y eid %(y)s", |
|
1139 |
{'x': str(eid1), 'y': str(eid2)}) |
|
1140 |
rset = self.execute('Any X, Y WHERE X travaille Y') |
|
1141 |
self.assertEqual(len(rset.rows), 1) |
|
4795
f1c8bc628b45
[repo] fix bug introduced by 4757:ec9c20c6b9f7, testing for select.selection is not enough to avoid the substep query, we should check there is no interesting restriction (test added)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4787
diff
changeset
|
1142 |
# test add of an existant relation but with NOT X rel Y protection |
f1c8bc628b45
[repo] fix bug introduced by 4757:ec9c20c6b9f7, testing for select.selection is not enough to avoid the substep query, we should check there is no interesting restriction (test added)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4787
diff
changeset
|
1143 |
self.failIf(self.execute("SET X travaille Y WHERE X eid %(x)s, Y eid %(y)s," |
f1c8bc628b45
[repo] fix bug introduced by 4757:ec9c20c6b9f7, testing for select.selection is not enough to avoid the substep query, we should check there is no interesting restriction (test added)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4787
diff
changeset
|
1144 |
"NOT X travaille Y", |
f1c8bc628b45
[repo] fix bug introduced by 4757:ec9c20c6b9f7, testing for select.selection is not enough to avoid the substep query, we should check there is no interesting restriction (test added)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4787
diff
changeset
|
1145 |
{'x': str(eid1), 'y': str(eid2)})) |
1787 | 1146 |
|
0 | 1147 |
def test_update_2ter(self): |
1148 |
rset = self.execute("INSERT Personne X, Societe Y: X nom 'bidule', Y nom 'toto'") |
|
1149 |
eid1, eid2 = rset[0][0], rset[0][1] |
|
1150 |
self.execute("SET X travaille Y WHERE X eid %(x)s, Y eid %(y)s", |
|
1151 |
{'x': unicode(eid1), 'y': unicode(eid2)}) |
|
1152 |
rset = self.execute('Any X, Y WHERE X travaille Y') |
|
1153 |
self.assertEqual(len(rset.rows), 1) |
|
1787 | 1154 |
|
0 | 1155 |
def test_update_multiple1(self): |
1156 |
peid1 = self.execute("INSERT Personne Y: Y nom 'tutu'")[0][0] |
|
1157 |
peid2 = self.execute("INSERT Personne Y: Y nom 'toto'")[0][0] |
|
1158 |
self.execute("SET X nom 'tutu', Y nom 'toto' WHERE X nom 'toto', Y nom 'tutu'") |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1159 |
self.assertEqual(self.execute('Any X WHERE X nom "toto"').rows, [[peid1]]) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1160 |
self.assertEqual(self.execute('Any X WHERE X nom "tutu"').rows, [[peid2]]) |
0 | 1161 |
|
1162 |
def test_update_multiple2(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1163 |
ueid = self.execute("INSERT CWUser X: X login 'bob', X upassword 'toto'")[0][0] |
0 | 1164 |
peid1 = self.execute("INSERT Personne Y: Y nom 'turlu'")[0][0] |
1165 |
peid2 = self.execute("INSERT Personne Y: Y nom 'tutu'")[0][0] |
|
1166 |
self.execute('SET P1 owned_by U, P2 owned_by U ' |
|
1167 |
'WHERE P1 eid %s, P2 eid %s, U eid %s' % (peid1, peid2, ueid)) |
|
1168 |
self.failUnless(self.execute('Any X WHERE X eid %s, X owned_by U, U eid %s' |
|
1169 |
% (peid1, ueid))) |
|
1170 |
self.failUnless(self.execute('Any X WHERE X eid %s, X owned_by U, U eid %s' |
|
1171 |
% (peid2, ueid))) |
|
1172 |
||
1173 |
def test_update_math_expr(self): |
|
1174 |
orders = [r[0] for r in self.execute('Any O ORDERBY O WHERE ST name "Personne", X from_entity ST, X ordernum O')] |
|
1175 |
for i,v in enumerate(orders): |
|
1176 |
if v != orders[0]: |
|
1177 |
splitidx = i |
|
1178 |
break |
|
1179 |
self.execute('SET X ordernum Y+1 WHERE X from_entity SE, SE name "Personne", X ordernum Y, X ordernum >= %(order)s', |
|
1180 |
{'order': orders[splitidx]}) |
|
1181 |
orders2 = [r[0] for r in self.execute('Any O ORDERBY O WHERE ST name "Personne", X from_entity ST, X ordernum O')] |
|
1182 |
orders = orders[:splitidx] + [o+1 for o in orders[splitidx:]] |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1183 |
self.assertEqual(orders2, orders) |
0 | 1184 |
|
1185 |
def test_update_string_concat(self): |
|
1186 |
beid = self.execute("INSERT Bookmark Y: Y title 'toto', Y path '/view'")[0][0] |
|
1187 |
self.execute('SET X title XN + %(suffix)s WHERE X is Bookmark, X title XN', {'suffix': u'-moved'}) |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
1188 |
newname = self.execute('Any XN WHERE X eid %(x)s, X title XN', {'x': beid})[0][0] |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1189 |
self.assertEqual(newname, 'toto-moved') |
1787 | 1190 |
|
0 | 1191 |
def test_update_query_error(self): |
1192 |
self.execute("INSERT Personne Y: Y nom 'toto'") |
|
1193 |
self.assertRaises(Exception, self.execute, "SET X nom 'toto', X is Personne") |
|
1194 |
self.assertRaises(QueryError, self.execute, "SET X nom 'toto', X has_text 'tutu' WHERE X is Personne") |
|
1195 |
self.assertRaises(QueryError, self.execute, "SET X login 'tutu', X eid %s" % cnx.user(self.session).eid) |
|
1196 |
||
1197 |
# upassword encryption tests ################################################# |
|
1787 | 1198 |
|
0 | 1199 |
def test_insert_upassword(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1200 |
rset = self.execute("INSERT CWUser X: X login 'bob', X upassword 'toto'") |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1201 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1202 |
self.assertEqual(rset.description, [('CWUser',)]) |
0 | 1203 |
self.assertRaises(Unauthorized, |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1204 |
self.execute, "Any P WHERE X is CWUser, X login 'bob', X upassword P") |
0 | 1205 |
cursor = self.pool['system'] |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1206 |
cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'" |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
1207 |
% (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX)) |
1951
f28e7f300d3f
getting a StringIO here was due to lgc.db sqlite adapter bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1950
diff
changeset
|
1208 |
passwd = str(cursor.fetchone()[0]) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1209 |
self.assertEqual(passwd, crypt_password('toto', passwd[:2])) |
4199
c9526b1ffb1d
must now properly use Binary for password (see 4180:42247d70105b). XXX Though this is somewhat backend related (eg store password using a binary type), this should be either well document or handled properly in the db helper.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3587
diff
changeset
|
1210 |
rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword %(pwd)s", |
c9526b1ffb1d
must now properly use Binary for password (see 4180:42247d70105b). XXX Though this is somewhat backend related (eg store password using a binary type), this should be either well document or handled properly in the db helper.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3587
diff
changeset
|
1211 |
{'pwd': Binary(passwd)}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1212 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1213 |
self.assertEqual(rset.description, [('CWUser',)]) |
1787 | 1214 |
|
0 | 1215 |
def test_update_upassword(self): |
1216 |
cursor = self.pool['system'] |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1217 |
rset = self.execute("INSERT CWUser X: X login 'bob', X upassword %(pwd)s", {'pwd': 'toto'}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1218 |
self.assertEqual(rset.description[0][0], 'CWUser') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1219 |
rset = self.execute("SET X upassword %(pwd)s WHERE X is CWUser, X login 'bob'", |
0 | 1220 |
{'pwd': 'tutu'}) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1221 |
cursor.execute("SELECT %supassword from %sCWUser WHERE %slogin='bob'" |
1251
af40e615dc89
introduce a 'cw_' prefix on entity table and column names so we don't conflict with sql or DBMS specific keywords
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
1222 |
% (SQL_PREFIX, SQL_PREFIX, SQL_PREFIX)) |
1951
f28e7f300d3f
getting a StringIO here was due to lgc.db sqlite adapter bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1950
diff
changeset
|
1223 |
passwd = str(cursor.fetchone()[0]) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1224 |
self.assertEqual(passwd, crypt_password('tutu', passwd[:2])) |
4199
c9526b1ffb1d
must now properly use Binary for password (see 4180:42247d70105b). XXX Though this is somewhat backend related (eg store password using a binary type), this should be either well document or handled properly in the db helper.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3587
diff
changeset
|
1225 |
rset = self.execute("Any X WHERE X is CWUser, X login 'bob', X upassword %(pwd)s", |
c9526b1ffb1d
must now properly use Binary for password (see 4180:42247d70105b). XXX Though this is somewhat backend related (eg store password using a binary type), this should be either well document or handled properly in the db helper.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3587
diff
changeset
|
1226 |
{'pwd': Binary(passwd)}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1227 |
self.assertEqual(len(rset.rows), 1) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1228 |
self.assertEqual(rset.description, [('CWUser',)]) |
0 | 1229 |
|
1230 |
# non regression tests #################################################### |
|
1787 | 1231 |
|
0 | 1232 |
def test_nonregr_1(self): |
1233 |
teid = self.execute("INSERT Tag X: X name 'tag'")[0][0] |
|
1234 |
self.execute("SET X tags Y WHERE X name 'tag', Y is State, Y name 'activated'") |
|
1235 |
rset = self.execute('Any X WHERE T tags X') |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1236 |
self.assertEqual(len(rset.rows), 1, rset.rows) |
0 | 1237 |
rset = self.execute('Any T WHERE T tags X, X is State') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1238 |
self.assertEqual(rset.rows, [[teid]]) |
0 | 1239 |
rset = self.execute('Any T WHERE T tags X') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1240 |
self.assertEqual(rset.rows, [[teid]]) |
0 | 1241 |
|
1242 |
def test_nonregr_2(self): |
|
1243 |
teid = self.execute("INSERT Tag X: X name 'tag'")[0][0] |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1244 |
geid = self.execute("CWGroup G WHERE G name 'users'")[0][0] |
0 | 1245 |
self.execute("SET X tags Y WHERE X eid %(t)s, Y eid %(g)s", |
1246 |
{'g': geid, 't': teid}) |
|
1247 |
rset = self.execute('Any X WHERE E eid %(x)s, E tags X', |
|
1248 |
{'x': teid}) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1249 |
self.assertEqual(rset.rows, [[geid]]) |
1787 | 1250 |
|
0 | 1251 |
def test_nonregr_3(self): |
1252 |
"""bad sql generated on the second query (destination_state is not |
|
1253 |
detected as an inlined relation) |
|
1254 |
""" |
|
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
1255 |
rset = self.execute('Any S,ES,T WHERE S state_of WF, WF workflow_of ET, ET name "CWUser",' |
0 | 1256 |
'ES allowed_transition T, T destination_state S') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1257 |
self.assertEqual(len(rset.rows), 2) |
0 | 1258 |
|
1259 |
def test_nonregr_4(self): |
|
1260 |
# fix variables'type, else we get (nb of entity types with a 'name' attribute)**3 |
|
1261 |
# union queries and that make for instance a 266Ko sql query which is refused |
|
1262 |
# by the server (or client lib) |
|
1263 |
rset = self.execute('Any ER,SE,OE WHERE SE name "Comment", ER name "comments", OE name "Comment",' |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1264 |
'ER is CWRType, SE is CWEType, OE is CWEType') |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1265 |
self.assertEqual(len(rset), 1) |
0 | 1266 |
|
1267 |
def test_nonregr_5(self): |
|
1268 |
# jpl #15505: equivalent queries returning different result sets |
|
1269 |
teid1 = self.execute("INSERT Folder X: X name 'hop'")[0][0] |
|
1270 |
teid2 = self.execute("INSERT Folder X: X name 'hip'")[0][0] |
|
1271 |
neid = self.execute("INSERT Note X: X todo_by U, X filed_under T WHERE U login 'admin', T name 'hop'")[0][0] |
|
1272 |
weid = self.execute("INSERT Affaire X: X concerne N, X filed_under T WHERE N is Note, T name 'hip'")[0][0] |
|
1273 |
rset1 = self.execute('Any N,U WHERE N filed_under T, T eid %s,' |
|
1274 |
'N todo_by U, W concerne N,' |
|
1275 |
'W is Affaire, W filed_under A, A eid %s' % (teid1, teid2)) |
|
1276 |
rset2 = self.execute('Any N,U WHERE N filed_under T, T eid %s,' |
|
1277 |
'N todo_by U, W concerne N,' |
|
1278 |
'W filed_under A, A eid %s' % (teid1, teid2)) |
|
1279 |
rset3 = self.execute('Any N,U WHERE N todo_by U, T eid %s,' |
|
1280 |
'N filed_under T, W concerne N,' |
|
1281 |
'W is Affaire, W filed_under A, A eid %s' % (teid1, teid2)) |
|
1282 |
rset4 = self.execute('Any N,U WHERE N todo_by U, T eid %s,' |
|
1283 |
'N filed_under T, W concerne N,' |
|
1284 |
'W filed_under A, A eid %s' % (teid1, teid2)) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1285 |
self.assertEqual(rset1.rows, rset2.rows) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1286 |
self.assertEqual(rset1.rows, rset3.rows) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1287 |
self.assertEqual(rset1.rows, rset4.rows) |
1787 | 1288 |
|
0 | 1289 |
def test_nonregr_6(self): |
1290 |
self.execute('Any N,COUNT(S) GROUPBY N ORDERBY COUNT(N) WHERE S name N, S is State') |
|
1787 | 1291 |
|
0 | 1292 |
def test_sqlite_encoding(self): |
1293 |
"""XXX this test was trying to show a bug on use of lower which only |
|
1294 |
occurs with non ascii string and misconfigured locale |
|
1295 |
""" |
|
1296 |
self.execute("INSERT Tag X: X name %(name)s," |
|
1297 |
"X modification_date %(modification_date)s," |
|
1298 |
"X creation_date %(creation_date)s", |
|
1299 |
{'name': u'�name0', |
|
1300 |
'modification_date': '2003/03/12 11:00', |
|
1301 |
'creation_date': '2000/07/03 11:00'}) |
|
1302 |
rset = self.execute('Any lower(N) ORDERBY LOWER(N) WHERE X is Tag, X name N,' |
|
1303 |
'X owned_by U, U eid %(x)s', |
|
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
1304 |
{'x':self.session.user.eid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1305 |
self.assertEqual(rset.rows, [[u'\xe9name0']]) |
0 | 1306 |
|
1307 |
||
1308 |
def test_nonregr_description(self): |
|
1309 |
"""check that a correct description is built in case where infered |
|
1310 |
solutions may be "fusionned" into one by the querier while all solutions |
|
1311 |
are needed to build the result's description |
|
1312 |
""" |
|
1313 |
self.execute("INSERT Personne X: X nom 'bidule'") |
|
1314 |
self.execute("INSERT Societe Y: Y nom 'toto'") |
|
1315 |
beid = self.execute("INSERT Basket B: B name 'mybasket'")[0][0] |
|
1316 |
self.execute("SET X in_basket B WHERE X is Personne") |
|
1317 |
self.execute("SET X in_basket B WHERE X is Societe") |
|
1318 |
rset = self.execute('Any X WHERE X in_basket B, B eid %s' % beid) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1319 |
self.assertEqual(len(rset), 2) |
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1320 |
self.assertEqual(rset.description, [('Personne',), ('Societe',)]) |
0 | 1321 |
|
1322 |
||
1323 |
def test_nonregr_cache_1(self): |
|
1324 |
peid = self.execute("INSERT Personne X: X nom 'bidule'")[0][0] |
|
1325 |
beid = self.execute("INSERT Basket X: X name 'tag'")[0][0] |
|
1326 |
self.execute("SET X in_basket Y WHERE X is Personne, Y eid %(y)s", |
|
1327 |
{'y': beid}) |
|
1328 |
rset = self.execute("Any X WHERE X in_basket B, B eid %(x)s", |
|
1329 |
{'x': beid}) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1330 |
self.assertEqual(rset.rows, [[peid]]) |
0 | 1331 |
rset = self.execute("Any X WHERE X in_basket B, B eid %(x)s", |
1332 |
{'x': beid}) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1333 |
self.assertEqual(rset.rows, [[peid]]) |
0 | 1334 |
|
1335 |
def test_nonregr_has_text_cache(self): |
|
1336 |
eid1 = self.execute("INSERT Personne X: X nom 'bidule'")[0][0] |
|
1337 |
eid2 = self.execute("INSERT Personne X: X nom 'tag'")[0][0] |
|
1338 |
self.commit() |
|
1339 |
rset = self.execute("Any X WHERE X has_text %(text)s", {'text': 'bidule'}) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1340 |
self.assertEqual(rset.rows, [[eid1]]) |
0 | 1341 |
rset = self.execute("Any X WHERE X has_text %(text)s", {'text': 'tag'}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1342 |
self.assertEqual(rset.rows, [[eid2]]) |
0 | 1343 |
|
1344 |
def test_nonregr_sortterm_management(self): |
|
1345 |
"""Error: Variable has no attribute 'sql' in rql2sql.py (visit_variable) |
|
1346 |
||
1347 |
cause: old variable ref inserted into a fresh rqlst copy |
|
1348 |
(in RQLSpliter._complex_select_plan) |
|
1950
ab7a41b2cd26
reactivate skipped tests due to sqlite bug which is now fixed (sqlite 3.6.13)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1949
diff
changeset
|
1349 |
|
ab7a41b2cd26
reactivate skipped tests due to sqlite bug which is now fixed (sqlite 3.6.13)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1949
diff
changeset
|
1350 |
need sqlite including http://www.sqlite.org/cvstrac/tktview?tn=3773 fix |
0 | 1351 |
""" |
1352 |
self.execute('Any X ORDERBY D DESC WHERE X creation_date D') |
|
1787 | 1353 |
|
0 | 1354 |
def test_nonregr_extra_joins(self): |
1355 |
ueid = self.session.user.eid |
|
1356 |
teid1 = self.execute("INSERT Folder X: X name 'folder1'")[0][0] |
|
1357 |
teid2 = self.execute("INSERT Folder X: X name 'folder2'")[0][0] |
|
1358 |
neid1 = self.execute("INSERT Note X: X para 'note1'")[0][0] |
|
1359 |
neid2 = self.execute("INSERT Note X: X para 'note2'")[0][0] |
|
1360 |
self.execute("SET X filed_under Y WHERE X eid %s, Y eid %s" |
|
1361 |
% (neid1, teid1)) |
|
1362 |
self.execute("SET X filed_under Y WHERE X eid %s, Y eid %s" |
|
1363 |
% (neid2, teid2)) |
|
1364 |
self.execute("SET X todo_by Y WHERE X is Note, Y eid %s" % ueid) |
|
1365 |
rset = self.execute('Any N WHERE N todo_by U, N is Note, U eid %s, N filed_under T, T eid %s' |
|
1366 |
% (ueid, teid1)) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1367 |
self.assertEqual(len(rset), 1) |
0 | 1368 |
|
1369 |
def test_nonregr_XXX(self): |
|
1370 |
teid = self.execute('Transition S WHERE S name "deactivate"')[0][0] |
|
1371 |
rset = self.execute('Any O WHERE O is State, ' |
|
1372 |
'S eid %(x)s, S transition_of ET, O state_of ET', {'x': teid}) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1373 |
self.assertEqual(len(rset), 2) |
0 | 1374 |
rset = self.execute('Any O WHERE O is State, NOT S destination_state O, ' |
1375 |
'S eid %(x)s, S transition_of ET, O state_of ET', {'x': teid}) |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1376 |
self.assertEqual(len(rset), 1) |
0 | 1377 |
|
1378 |
||
1379 |
def test_nonregr_set_datetime(self): |
|
1380 |
# huum, psycopg specific |
|
1016
26387b836099
use datetime instead of mx.DateTime
sylvain.thenault@logilab.fr
parents:
439
diff
changeset
|
1381 |
self.execute('SET X creation_date %(date)s WHERE X eid 1', {'date': date.today()}) |
0 | 1382 |
|
1383 |
def test_nonregr_set_query(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1384 |
ueid = self.execute("INSERT CWUser X: X login 'bob', X upassword 'toto'")[0][0] |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
1385 |
self.execute("SET E in_group G, E firstname %(firstname)s, E surname %(surname)s " |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2608
diff
changeset
|
1386 |
"WHERE E eid %(x)s, G name 'users'", |
5174
78438ad513ca
#759035: Automate addition of eid cachekey in RQL analysis
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4848
diff
changeset
|
1387 |
{'x':ueid, 'firstname': u'jean', 'surname': u'paul'}) |
1787 | 1388 |
|
0 | 1389 |
def test_nonregr_u_owned_by_u(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1390 |
ueid = self.execute("INSERT CWUser X: X login 'bob', X upassword 'toto', X in_group G " |
0 | 1391 |
"WHERE G name 'users'")[0][0] |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1392 |
rset = self.execute("CWUser U") |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1393 |
self.assertEqual(len(rset), 3) # bob + admin + anon |
0 | 1394 |
rset = self.execute("Any U WHERE NOT U owned_by U") |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1395 |
self.assertEqual(len(rset), 0) # even admin created at repo initialization time should belong to itself |
0 | 1396 |
|
1397 |
def test_nonreg_update_index(self): |
|
1398 |
# this is the kind of queries generated by "cubicweb-ctl db-check -ry" |
|
1399 |
self.execute("SET X description D WHERE X is State, X description D") |
|
1400 |
||
1401 |
def test_nonregr_is(self): |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1402 |
uteid = self.execute('Any ET WHERE ET name "CWUser"')[0][0] |
0 | 1403 |
self.execute('Any X, ET WHERE X is ET, ET eid %s' % uteid) |
1404 |
||
1405 |
def test_nonregr_orderby(self): |
|
1406 |
seid = self.execute('Any X WHERE X name "activated"')[0][0] |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1407 |
self.execute('Any X,S, MAX(T) GROUPBY X,S ORDERBY S WHERE X is CWUser, T tags X, S eid IN(%s), X in_state S' % seid) |
0 | 1408 |
|
1409 |
def test_nonregr_solution_cache(self): |
|
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1410 |
self.skipTest('XXX should be fixed or documented') # (doesn't occur if cache key is provided.) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1411 |
rset = self.execute('Any X WHERE X is CWUser, X eid %(x)s', {'x':self.ueid}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1412 |
self.assertEqual(len(rset), 1) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
1413 |
rset = self.execute('Any X WHERE X is CWUser, X eid %(x)s', {'x':12345}) |
6340
470d8e828fda
[test] update test to unittest2 api (still using lgc.testlib though)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6209
diff
changeset
|
1414 |
self.assertEqual(len(rset), 0) |
0 | 1415 |
|
1416 |
def test_nonregr_final_norestr(self): |
|
1417 |
self.assertRaises(BadRQLQuery, self.execute, 'Date X') |
|
1418 |
||
1419 |
||
1420 |
if __name__ == '__main__': |
|
1421 |
unittest_main() |