author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 26 Mar 2010 08:30:25 +0100 | |
branch | stable |
changeset 5031 | 60c4dea96afa |
parent 4212 | ab6573088b4a |
child 5421 | 8167de96c523 |
permissions | -rw-r--r-- |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
1 |
""" |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
2 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
3 |
:organization: Logilab |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1802
diff
changeset
|
7 |
""" |
0 | 8 |
from cubicweb.goa.testlib import * |
9 |
||
10 |
from cubicweb import Binary |
|
11 |
||
12 |
from logilab.common.testlib import unittest_main |
|
13 |
from mx.DateTime import now, today, DateTimeType |
|
14 |
import rql |
|
15 |
||
16 |
from google.appengine.api.datastore_types import Blob, Text |
|
17 |
||
18 |
# stored procedure definition ################################################# |
|
19 |
||
20 |
from rql.utils import register_function, FunctionDescr |
|
21 |
||
22 |
class itemtype_sort_value(FunctionDescr): |
|
23 |
supported_backends = ('sqlite',) |
|
24 |
rtype = 'Int' |
|
25 |
||
26 |
try: |
|
27 |
register_function(itemtype_sort_value) |
|
28 |
except AssertionError: |
|
29 |
pass |
|
30 |
||
31 |
def init_sqlite_connexion(cnx): |
|
32 |
def itemtype_sort_value(text): |
|
33 |
return {"personal":2, "business":1}[text] |
|
34 |
cnx.create_function("ITEMTYPE_SORT_VALUE", 1, itemtype_sort_value) |
|
35 |
||
36 |
from cubicweb.server import SQL_CONNECT_HOOKS |
|
37 |
sqlite_hooks = SQL_CONNECT_HOOKS.setdefault('sqlite', []) |
|
38 |
sqlite_hooks.append(init_sqlite_connexion) |
|
39 |
||
40 |
# end stored procedure definition ############################################# |
|
41 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
42 |
class Article(db.Model): |
0 | 43 |
content = db.TextProperty() |
44 |
synopsis = db.StringProperty(default=u'hello') |
|
45 |
||
46 |
class Blog(db.Model): |
|
47 |
diem = db.DateProperty(required=True, auto_now_add=True) |
|
48 |
content = db.TextProperty() |
|
49 |
itemtype = db.StringProperty(required=True, choices=(u'personal', u'business')) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
50 |
talks_about = db.ReferenceProperty(Article) |
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
51 |
cites = db.SelfReferenceProperty() |
0 | 52 |
data = db.BlobProperty() |
53 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
54 |
|
0 | 55 |
class RQLTest(GAEBasedTC): |
56 |
MODEL_CLASSES = (Article, Blog) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
57 |
|
0 | 58 |
def setUp(self): |
59 |
GAEBasedTC.setUp(self) |
|
60 |
# hack to make talks_about cardinality to ** instead of ?* |
|
61 |
self.schema.rschema('talks_about').set_rproperty('Blog', 'Article', |
|
62 |
'cardinality', '**') |
|
63 |
self.req = self.request() |
|
64 |
self.article = self.add_entity('Article', content=u'very interesting') |
|
65 |
self.blog = self.add_entity('Blog', itemtype=u'personal', content=u'hop') |
|
66 |
self.execute('SET X talks_about Y WHERE X eid %(x)s, Y eid %(y)s', |
|
67 |
{'x': self.blog.eid, 'y': self.article.eid}) |
|
68 |
self.commit() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
69 |
|
0 | 70 |
def _check_rset_size(self, rset, row, col): |
71 |
self.assertEquals(len(rset), row) |
|
72 |
self.assertEquals(len(rset[0]), col) |
|
73 |
self.assertEquals(len(rset.description), row) |
|
74 |
self.assertEquals(len(rset.description[0]), col) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
75 |
|
0 | 76 |
def _check_blog_rset(self, rset): |
77 |
self._check_rset_size(rset, 1, 1) |
|
78 |
self.assertEquals(rset.description[0][0], 'Blog') |
|
79 |
self.assertEquals(rset[0][0], self.blog.eid) |
|
80 |
self.assertEquals(rset.get_entity(0, 0).eid, self.blog.eid) |
|
81 |
||
82 |
def test_0_const(self): |
|
83 |
rset = self.req.execute('Any 1') |
|
84 |
self._check_rset_size(rset, 1, 1) |
|
85 |
self.assertEquals(rset[0][0], 1) |
|
86 |
self.assertEquals(rset.description[0][0], 'Int') |
|
87 |
||
88 |
def test_0_now_const(self): |
|
89 |
rset = self.req.execute('Any NOW') |
|
90 |
self._check_rset_size(rset, 1, 1) |
|
91 |
self.assertIsInstance(rset[0][0], DateTimeType) |
|
92 |
self.assertEquals(rset.description[0][0], 'Datetime') |
|
93 |
||
94 |
def test_0_today_const(self): |
|
95 |
rset = self.req.execute('Any TODAY') |
|
96 |
self._check_rset_size(rset, 1, 1) |
|
97 |
self.assertIsInstance(rset[0][0], DateTimeType) |
|
98 |
self.assertEquals(rset[0][0], today()) |
|
99 |
self.assertEquals(rset.description[0][0], 'Date') |
|
100 |
||
101 |
||
102 |
def test_1_eid(self): |
|
103 |
rset = self.req.execute('Any X WHERE X eid %(x)s', {'x': self.blog.eid}) |
|
104 |
self._check_blog_rset(rset) |
|
105 |
rset = self.req.execute('Any X WHERE X eid "%s"' % self.blog.eid) |
|
106 |
self._check_blog_rset(rset) |
|
107 |
||
108 |
def test_1_eid_eid(self): |
|
109 |
rset = self.req.execute('Any X,Y WHERE X eid %(x)s, Y eid %(y)s', {'x': self.blog.eid, |
|
110 |
'y': self.article.eid}) |
|
111 |
self._check_rset_size(rset, 1, 2) |
|
112 |
self.assertEquals(rset.description[0], ('Blog', 'Article')) |
|
113 |
self.assertEquals(rset[0][0], self.blog.eid) |
|
114 |
self.assertEquals(rset[0][1], self.article.eid) |
|
115 |
||
116 |
def test_1_eid_with_is(self): |
|
117 |
self.assertRaises(rql.TypeResolverException, |
|
118 |
self.req.execute, 'Any X WHERE X eid %(x)s, X is Article', {'x': self.blog.eid}) |
|
119 |
rset = self.req.execute('Any X WHERE X eid %(x)s, X is Blog', {'x': self.blog.eid}) |
|
120 |
self._check_blog_rset(rset) |
|
121 |
||
122 |
def test_1_is(self): |
|
123 |
rset = self.req.execute('Any X WHERE X is Blog') |
|
124 |
self._check_blog_rset(rset) |
|
125 |
blog2 = Blog(itemtype=u'personal', content=u'hop') |
|
126 |
blog2.put() |
|
127 |
rset = self.req.execute('Any X WHERE X is Blog') |
|
128 |
self.assertEquals(len(rset), 2) |
|
129 |
self.assertEquals(rset.description, [('Blog',), ('Blog',)]) |
|
130 |
||
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
131 |
|
0 | 132 |
def test_2_attribute_selection_1(self): |
133 |
rset = self.req.execute('Any X,D,C WHERE X is Blog, X diem D, X content C') |
|
134 |
self._check_rset_size(rset, 1, 3) |
|
135 |
self.assertEquals(rset[0], [self.blog.eid, today(), u'hop']) |
|
136 |
self.assertEquals(rset.description[0], ('Blog', 'Date', 'String')) |
|
137 |
self.assertIsInstance(rset[0][1], DateTimeType) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
138 |
|
0 | 139 |
def test_2_attribute_selection_2(self): |
140 |
rset = self.req.execute('Any D,C WHERE X is Blog, X diem D, X content C') |
|
141 |
self._check_rset_size(rset, 1, 2) |
|
142 |
self.assertEquals(rset[0], [today(), u'hop']) |
|
143 |
self.assertEquals(rset.description[0], ('Date', 'String')) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
144 |
|
0 | 145 |
def test_2_attribute_selection_binary(self): |
146 |
rset = self.req.execute('Any D WHERE X is Blog, X data D') |
|
147 |
self._check_rset_size(rset, 1, 1) |
|
148 |
self.assertEquals(rset[0], [None]) |
|
149 |
self.assertEquals(rset.description[0], ('Bytes',)) |
|
150 |
self.blog['data'] = Binary('raw data') |
|
151 |
self.blog.put() |
|
152 |
rset = self.req.execute('Any D WHERE X is Blog, X data D') |
|
153 |
self._check_rset_size(rset, 1, 1) |
|
154 |
self.assertIsInstance(rset[0][0], Binary) |
|
155 |
value = rset[0][0].getvalue() |
|
156 |
self.assertIsInstance(value, str) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
157 |
self.failIf(isinstance(value, Blob)) |
0 | 158 |
self.assertEquals(value, 'raw data') |
159 |
self.assertEquals(rset.description[0], ('Bytes',)) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
160 |
|
0 | 161 |
def test_2_attribute_selection_long_text(self): |
162 |
self.blog['content'] = text = 'a'*501 |
|
163 |
self.blog.put() |
|
164 |
rset = self.req.execute('Any C WHERE X is Blog, X content C') |
|
165 |
self._check_rset_size(rset, 1, 1) |
|
166 |
self.assertIsInstance(rset[0][0], unicode) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
167 |
self.failIf(isinstance(rset[0][0], Text)) |
0 | 168 |
self.assertEquals(rset[0][0], text) |
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
169 |
|
0 | 170 |
def test_2_attribute_selection_transformation(self): |
171 |
rset = self.req.execute('Any X,UPPER(C) WHERE X is Blog, X content C') |
|
172 |
self._check_rset_size(rset, 1, 2) |
|
173 |
self.assertEquals(rset[0], [self.blog.eid, u'HOP']) |
|
174 |
self.assertEquals(rset.description[0], ('Blog', 'String',)) |
|
175 |
||
176 |
||
177 |
def test_3_attribute_restriction(self): |
|
178 |
rset = self.req.execute('Any X WHERE X itemtype "personal"') |
|
179 |
self._check_blog_rset(rset) |
|
180 |
rset = self.req.execute('Any X WHERE X itemtype "business"') |
|
181 |
self.assertEquals(len(rset), 0) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
182 |
|
0 | 183 |
def test_3_ambigous_attribute_restriction_1(self): |
184 |
rset = self.req.execute('Any X WHERE X content "hello"') |
|
185 |
self.assertEquals(len(rset), 0) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
186 |
|
0 | 187 |
def test_3_ambigous_attribute_restriction_2(self): |
188 |
rset = self.req.execute('Any X WHERE X content "hop"') |
|
189 |
self._check_blog_rset(rset) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
190 |
|
0 | 191 |
def test_3_ambigous_attribute_restriction_3(self): |
192 |
article = Article(content=u'hop') |
|
193 |
article.put() |
|
194 |
rset = self.req.execute('Any X WHERE X content "hop"') |
|
195 |
self._check_rset_size(rset, 2, 1) |
|
196 |
self.assertUnorderedIterableEquals([r[0] for r in rset], [self.blog.eid, article.eid]) |
|
197 |
self.assertUnorderedIterableEquals([r[0] for r in rset.description], ['Blog', 'Article']) |
|
198 |
||
199 |
def test_3_incoherant_attribute_restriction(self): |
|
200 |
rset = self.req.execute('Any X WHERE X eid %(x)s, X content "hola"', |
|
201 |
{'x': self.blog.eid}) |
|
202 |
self.assertEquals(len(rset), 0) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
203 |
|
0 | 204 |
def test_3_multiple_attribute_restriction(self): |
205 |
rset = self.req.execute('Any X WHERE X content "hop", X itemtype "personal"') |
|
206 |
self._check_blog_rset(rset) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
207 |
|
0 | 208 |
def test_3_incoherant_multiple_attribute_restriction(self): |
209 |
rset = self.req.execute('Any X WHERE X content "hip", X itemtype "personal"') |
|
210 |
self.assertEquals(len(rset), 0) |
|
211 |
||
212 |
def test_3_today_attribute_restriction(self): |
|
213 |
rset = self.req.execute('Any X WHERE X diem < TODAY') |
|
214 |
self.assertEquals(len(rset), 0) |
|
215 |
rset = self.req.execute('Any X WHERE X diem <= TODAY') |
|
216 |
self._check_blog_rset(rset) |
|
217 |
rset = self.req.execute('Any X WHERE X diem > TODAY') |
|
218 |
self.assertEquals(len(rset), 0) |
|
219 |
rset = self.req.execute('Any X WHERE X diem >= TODAY') |
|
220 |
self._check_blog_rset(rset) |
|
221 |
||
222 |
def test_3_now_attribute_restriction(self): |
|
223 |
rset = self.req.execute('Any X WHERE X diem < NOW') |
|
224 |
self._check_blog_rset(rset) |
|
225 |
rset = self.req.execute('Any X WHERE X diem <= NOW') |
|
226 |
self._check_blog_rset(rset) |
|
227 |
rset = self.req.execute('Any X WHERE X diem > NOW') |
|
228 |
self.assertEquals(len(rset), 0) |
|
229 |
rset = self.req.execute('Any X WHERE X diem >= NOW') |
|
230 |
self.assertEquals(len(rset), 0) |
|
231 |
||
232 |
def test_3_in_attribute_restriction(self): |
|
233 |
self.skip('missing actual gae support, retry latter') |
|
234 |
article2 = Article(content=u'hip') |
|
235 |
rset = self.req.execute('Any X WHERE X content IN ("hop", "hip")') |
|
236 |
self._check_rset_size(rset, 2, 1) |
|
237 |
self.assertUnorderedIterableEquals([r[0] for r in rset], [self.blog.eid, article.eid]) |
|
238 |
self.assertUnorderedIterableEquals([r[0] for r in rset.description], ['Blog', 'Article']) |
|
239 |
||
240 |
def test_3_like(self): |
|
241 |
repo = self.config.repository() |
|
242 |
versions = repo.get_versions() |
|
243 |
self.assertEquals(versions.keys(), ['cubicweb']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
244 |
|
0 | 245 |
def _setup_relation_description(self): |
246 |
self.article2 = self.add_entity('Article', content=u'hop') |
|
247 |
self.blog2 = self.add_entity('Blog', itemtype=u'personal', content=u'hip') |
|
248 |
self.execute('SET X talks_about Y WHERE X eid %(x)s, Y eid %(y)s', |
|
249 |
{'x': self.blog2.eid, 'y': self.article2.eid}) |
|
250 |
self.blog3 = self.add_entity('Blog', itemtype=u'business', content=u'hep') |
|
251 |
self.commit() |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
252 |
|
0 | 253 |
def test_4_relation_restriction_1(self): |
254 |
self._setup_relation_description() |
|
255 |
rset = self.req.execute('Any X WHERE X talks_about Y') |
|
256 |
self._check_rset_size(rset, 2, 1) |
|
257 |
self.assertUnorderedIterableEquals([r[0] for r in rset], |
|
258 |
[self.blog.eid, self.blog2.eid]) |
|
259 |
self.assertUnorderedIterableEquals([r[0] for r in rset.description], ['Blog', 'Blog']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
260 |
|
0 | 261 |
def test_4_relation_restriction_2(self): |
262 |
self._setup_relation_description() |
|
263 |
rset = self.req.execute('Any Y WHERE X talks_about Y') |
|
264 |
self._check_rset_size(rset, 2, 1) |
|
265 |
self.assertUnorderedIterableEquals([r[0] for r in rset], |
|
266 |
[self.article.eid, self.article2.eid]) |
|
267 |
self.assertUnorderedIterableEquals([r[0] for r in rset.description], |
|
268 |
['Article', 'Article']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
269 |
|
0 | 270 |
def test_4_relation_restriction_3(self): |
271 |
self._setup_relation_description() |
|
272 |
rset = self.req.execute('Any X,Y WHERE X talks_about Y') |
|
273 |
self._check_rset_size(rset, 2, 2) |
|
274 |
self.assertUnorderedIterableEquals([tuple(r) for r in rset], |
|
275 |
[(self.blog.eid, self.article.eid), |
|
276 |
(self.blog2.eid, self.article2.eid)]) |
|
277 |
self.assertUnorderedIterableEquals([tuple(r) for r in rset.description], |
|
278 |
[('Blog', 'Article'), |
|
279 |
('Blog', 'Article')]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
280 |
|
0 | 281 |
def test_4_relation_restriction_4(self): |
282 |
self._setup_relation_description() |
|
283 |
rset = self.req.execute('Any X,Y WHERE X talks_about Y, X eid %(x)s', |
|
284 |
{'x': self.blog.eid}) |
|
285 |
self._check_rset_size(rset, 1, 2) |
|
286 |
self.assertEquals(rset[0], [self.blog.eid, self.article.eid]) |
|
287 |
self.assertUnorderedIterableEquals(rset.description[0], ['Blog', 'Article']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
288 |
|
0 | 289 |
def test_4_relation_restriction_5(self): |
290 |
self._setup_relation_description() |
|
291 |
rset = self.req.execute('Any X,Y WHERE X talks_about Y, Y eid %(x)s', |
|
292 |
{'x': self.article.eid}) |
|
293 |
self._check_rset_size(rset, 1, 2) |
|
294 |
self.assertEquals(rset[0], [self.blog.eid, self.article.eid]) |
|
295 |
self.assertUnorderedIterableEquals(rset.description[0], ['Blog', 'Article']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
296 |
|
0 | 297 |
def test_4_relation_subject_restriction(self): |
298 |
self._setup_relation_description() |
|
299 |
rset = self.req.execute('Any X,Y WHERE X talks_about Y, X content %(c)s', |
|
300 |
{'c': 'hop'}) |
|
301 |
self._check_rset_size(rset, 1, 2) |
|
302 |
self.assertEquals(rset[0], [self.blog.eid, self.article.eid]) |
|
303 |
self.assertUnorderedIterableEquals(rset.description[0], ['Blog', 'Article']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
304 |
|
0 | 305 |
def test_4_relation_object_restriction(self): |
306 |
self._setup_relation_description() |
|
307 |
rset = self.req.execute('Any X WHERE X is Blog, X talks_about Y, Y content %(c)s', |
|
308 |
{'c': 'very interesting'}) |
|
309 |
self._check_rset_size(rset, 1, 1) |
|
310 |
self.assertEquals(rset[0], [self.blog.eid]) |
|
311 |
self.assertUnorderedIterableEquals(rset.description[0], ['Blog']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
312 |
|
0 | 313 |
def test_4_relation_subject_object_restriction(self): |
314 |
article2 = self.add_entity('Article', content=u'very interesting') |
|
315 |
rset = self.req.execute('Any X,XC WHERE X is Blog, X content XC, X content %(xc)s, ' |
|
316 |
'X talks_about Y, Y content %(c)s', |
|
317 |
{'xc': 'hop', 'c': 'very interesting'}) |
|
318 |
self._check_rset_size(rset, 1, 2) |
|
319 |
self.assertEquals(rset[0], [self.blog.eid, self.blog.content]) |
|
320 |
self.assertUnorderedIterableEquals(rset.description[0], ['Blog', 'String']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
321 |
|
0 | 322 |
def test_4_relation_subject_object_restriction_no_res(self): |
323 |
article2 = self.add_entity('Article', content=u'very interesting') |
|
324 |
rset = self.req.execute('Any X,XC WHERE X is Blog, X content XC, X content %(xc)s, ' |
|
325 |
'X talks_about Y, Y content %(c)s', |
|
326 |
{'xc': 'hip', 'c': 'very interesting'}) |
|
327 |
self.assertEquals(len(rset), 0) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
328 |
|
0 | 329 |
def test_4_relation_subject_object_restriction_no_res_2(self): |
330 |
rset = self.req.execute('Any X,XC WHERE X is Blog, X content XC, X content %(xc)s, ' |
|
331 |
'X talks_about Y, Y content %(c)s', |
|
332 |
{'xc': 'hop', 'c': 'not interesting'}) |
|
333 |
self.assertEquals(len(rset), 0) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
334 |
|
0 | 335 |
def test_4_relation_restriction_7(self): |
336 |
self._setup_relation_description() |
|
337 |
rset = self.req.execute('Any XC,XD,YC WHERE X talks_about Y, Y eid %(x)s,' |
|
338 |
'X content XC, X diem XD, Y content YC', |
|
339 |
{'x': self.article.eid}) |
|
340 |
self._check_rset_size(rset, 1, 3) |
|
341 |
self.assertEquals(rset[0], [self.blog.content, self.blog.diem, self.article.content]) |
|
342 |
self.assertUnorderedIterableEquals(rset.description[0], ['String', 'Date', 'String']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
343 |
|
0 | 344 |
def test_4_relation_restriction_8(self): |
345 |
self._setup_relation_description() |
|
346 |
rset = self.req.execute('Any X,Y WHERE X cites Y, Y eid %(x)s', {'x': self.blog.eid}) |
|
347 |
self.assertEquals(len(rset), 0) |
|
348 |
||
349 |
def test_4_relation_restriction_9(self): |
|
350 |
article2 = self.add_entity('Article', content=u'hop') |
|
351 |
self.req.execute('SET X talks_about Y WHERE X eid %(x)s, Y eid %(y)s', |
|
352 |
{'x': self.blog.eid, 'y': article2.eid}) |
|
353 |
rset = self.req.execute('Any X,Y WHERE X talks_about Y, X eid %(x)s, Y eid %(y)s', |
|
354 |
{'x': self.blog.eid, 'y': article2.eid}) |
|
355 |
self._check_rset_size(rset, 1, 2) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
356 |
|
0 | 357 |
def test_4_ambiguous_subject_relation(self): |
358 |
ye = self.add_entity('YamsEntity') |
|
359 |
self.req.execute('SET X ambiguous_relation Y WHERE X eid %(x)s, Y eid %(y)s', |
|
360 |
{'x': ye.eid, 'y': self.blog.eid}) |
|
361 |
self.req.execute('SET X ambiguous_relation Y WHERE X eid %(x)s, Y eid %(y)s', |
|
362 |
{'x': ye.eid, 'y': self.article.eid}) |
|
363 |
self.commit() |
|
364 |
#ye = self.vreg.etype_class('YamsEntity ')(req, None) |
|
365 |
#ye.to_gae_model()['s_ambiguous_relation'] = [self.blog.key(), self.article.key()] |
|
366 |
#ye.put() |
|
367 |
rset = self.req.execute('Any X WHERE Y ambiguous_relation X') |
|
368 |
self._check_rset_size(rset, 2, 1) |
|
369 |
self.assertUnorderedIterableEquals([r[0] for r in rset], [self.blog.eid, self.article.eid]) |
|
370 |
self.assertUnorderedIterableEquals([r[0] for r in rset.description], ['Blog', 'Article']) |
|
371 |
rset = self.req.execute('Any X WHERE Y ambiguous_relation X, Y eid %(x)s', {'x': ye.eid}) |
|
372 |
self._check_rset_size(rset, 2, 1) |
|
373 |
self.assertUnorderedIterableEquals([r[0] for r in rset], [self.blog.eid, self.article.eid]) |
|
374 |
self.assertUnorderedIterableEquals([r[0] for r in rset.description], ['Blog', 'Article']) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
375 |
|
0 | 376 |
def test_4_relation_selection(self): |
377 |
req = self.request() |
|
378 |
rset = req.execute('Any N WHERE G content N, U talks_about G, U eid %(u)s', {'u': self.blog.eid}) |
|
379 |
self._check_rset_size(rset, 1, 1) |
|
380 |
self.assertEquals(rset[0][0], 'very interesting') |
|
381 |
||
382 |
||
383 |
def test_5_orderby(self): |
|
384 |
self._setup_relation_description() |
|
385 |
rset = self.req.execute('Any X,XC ORDERBY XC WHERE X is Blog, X content XC') |
|
386 |
self._check_rset_size(rset, 3, 2) |
|
387 |
self.assertEquals(rset.rows, |
|
388 |
[[self.blog3.eid, 'hep'], |
|
389 |
[self.blog2.eid, 'hip'], |
|
390 |
[self.blog.eid, 'hop']]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
391 |
|
0 | 392 |
def test_5_orderby_desc(self): |
393 |
self._setup_relation_description() |
|
394 |
rset = self.req.execute('Any X,XC ORDERBY XC DESC WHERE X is Blog, X content XC') |
|
395 |
self._check_rset_size(rset, 3, 2) |
|
396 |
self.assertEquals(rset.rows, |
|
397 |
[[self.blog.eid, 'hop'], |
|
398 |
[self.blog2.eid, 'hip'], |
|
399 |
[self.blog3.eid, 'hep']]) |
|
400 |
||
401 |
def test_5_orderby_several_terms(self): |
|
402 |
self._setup_relation_description() |
|
403 |
rset = self.req.execute('Any X,XC,XI ORDERBY XI,XC WHERE X is Blog, X content XC, X itemtype XI') |
|
404 |
self._check_rset_size(rset, 3, 3) |
|
405 |
self.assertEquals(rset.rows, |
|
406 |
[[self.blog3.eid, 'hep', 'business'], |
|
407 |
[self.blog2.eid, 'hip', 'personal'], |
|
408 |
[self.blog.eid, 'hop', 'personal']]) |
|
409 |
||
410 |
def test_5_orderby_several_terms_mixed_implicit(self): |
|
411 |
self._setup_relation_description() |
|
412 |
rset = self.req.execute('Any X,XC,XI ORDERBY XI,XC DESC WHERE X is Blog, X content XC, X itemtype XI') |
|
413 |
self._check_rset_size(rset, 3, 3) |
|
414 |
self.assertEquals(rset.rows, |
|
415 |
[[self.blog3.eid, 'hep', 'business'], |
|
416 |
[self.blog.eid, 'hop', 'personal'], |
|
417 |
[self.blog2.eid, 'hip', 'personal']]) |
|
418 |
||
419 |
def test_5_orderby_several_terms_explicit_order(self): |
|
420 |
self._setup_relation_description() |
|
421 |
rset = self.req.execute('Any X,XC,XI ORDERBY XI DESC,XC DESC WHERE X is Blog, X content XC, X itemtype XI') |
|
422 |
self._check_rset_size(rset, 3, 3) |
|
423 |
self.assertEquals(rset.rows, |
|
424 |
[[self.blog.eid, 'hop', 'personal'], |
|
425 |
[self.blog2.eid, 'hip', 'personal'], |
|
426 |
[self.blog3.eid, 'hep', 'business']]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
427 |
|
0 | 428 |
def test_5_orderby_several_terms_mixed_order(self): |
429 |
self._setup_relation_description() |
|
430 |
rset = self.req.execute('Any X,XC,XI ORDERBY XI ASC,XC DESC WHERE X is Blog, X content XC, X itemtype XI') |
|
431 |
self._check_rset_size(rset, 3, 3) |
|
432 |
self.assertEquals(rset.rows, |
|
433 |
[[self.blog3.eid, 'hep', 'business'], |
|
434 |
[self.blog.eid, 'hop', 'personal'], |
|
435 |
[self.blog2.eid, 'hip', 'personal']]) |
|
436 |
||
437 |
||
438 |
def test_5_orderby_lower(self): |
|
439 |
blog2 = self.add_entity('Blog', itemtype=u'business', content=u'Hup') |
|
440 |
rset = self.req.execute('Any X ORDERBY LOWER(XC) ' |
|
441 |
'WHERE X is Blog, X content XC') |
|
442 |
self._check_rset_size(rset, 2, 1) |
|
443 |
self.assertEquals(rset.rows, [[self.blog.eid], [blog2.eid]]) |
|
444 |
rset = self.req.execute('Any X ORDERBY LOWER(XC) DESC' |
|
445 |
'WHERE X is Blog, X content XC') |
|
446 |
self._check_rset_size(rset, 2, 1) |
|
447 |
self.assertEquals(rset.rows, [[blog2.eid], [self.blog.eid]]) |
|
448 |
||
449 |
def test_5_orderby_stored_proc(self): |
|
450 |
blog2 = self.add_entity('Blog', itemtype=u'business', content=u'hop') |
|
451 |
rset = self.req.execute('Any X ORDERBY ITEMTYPE_SORT_VALUE(XIT) ' |
|
452 |
'WHERE X is Blog, X itemtype XIT') |
|
453 |
self._check_rset_size(rset, 2, 1) |
|
454 |
self.assertEquals(rset.rows, [[blog2.eid], [self.blog.eid]]) |
|
455 |
rset = self.req.execute('Any X ORDERBY ITEMTYPE_SORT_VALUE(XIT) DESC' |
|
456 |
'WHERE X is Blog, X itemtype XIT') |
|
457 |
self._check_rset_size(rset, 2, 1) |
|
458 |
self.assertEquals(rset.rows, [[self.blog.eid], [blog2.eid]]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
459 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
460 |
|
0 | 461 |
def test_6_limit(self): |
462 |
self._setup_relation_description() |
|
463 |
rset = self.req.execute('Any X LIMIT 2 WHERE X is Blog') |
|
464 |
self._check_rset_size(rset, 2, 1) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
465 |
|
0 | 466 |
def test_6_offset(self): |
467 |
self._setup_relation_description() |
|
468 |
rset = self.req.execute('Any XC ORDERBY XC DESC OFFSET 1 WHERE X is Blog, X content XC') |
|
469 |
self._check_rset_size(rset, 2, 1) |
|
470 |
self.assertEquals(rset.rows, [['hip'], ['hep']]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
471 |
|
0 | 472 |
def test_6_limit_and_orderby(self): |
473 |
self._setup_relation_description() |
|
474 |
rset = self.req.execute('Any XC ORDERBY XC LIMIT 2 WHERE X is Blog, X content XC') |
|
475 |
self._check_rset_size(rset, 2, 1) |
|
476 |
self.assertEquals(rset.rows, [['hep'], ['hip']]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
477 |
|
0 | 478 |
def test_6_limit_offset_and_orderby(self): |
479 |
self._setup_relation_description() |
|
480 |
rset = self.req.execute('Any XC ORDERBY XC LIMIT 2 OFFSET 0 WHERE X is Blog, X content XC') |
|
481 |
self._check_rset_size(rset, 2, 1) |
|
482 |
self.assertEquals(rset.rows, [['hep'], ['hip']]) |
|
483 |
rset = self.req.execute('Any XC ORDERBY XC LIMIT 2 OFFSET 1 WHERE X is Blog, X content XC') |
|
484 |
self._check_rset_size(rset, 2, 1) |
|
485 |
self.assertEquals(rset.rows, [['hip'], ['hop']]) |
|
486 |
rset = self.req.execute('Any XC ORDERBY XC LIMIT 2 OFFSET 2 WHERE X is Blog, X content XC') |
|
487 |
self._check_rset_size(rset, 1, 1) |
|
488 |
self.assertEquals(rset.rows, [['hop']]) |
|
489 |
rset = self.req.execute('Any XC ORDERBY XC LIMIT 2 OFFSET 3 WHERE X is Blog, X content XC') |
|
490 |
self.failIf(rset) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
491 |
|
0 | 492 |
|
493 |
def test_7_simple_datetimecast(self): |
|
494 |
self._setup_relation_description() |
|
495 |
_today = today() |
|
496 |
_tomorrow = _today + 1 |
|
497 |
rset = self.req.execute('Any X WHERE X is Blog, X creation_date >= "%s"' |
|
498 |
% _tomorrow.strftime('%Y-%m-%d')) |
|
499 |
self.failUnless(len(rset) == 0) |
|
500 |
rset = self.req.execute('Any X WHERE X is Blog, X creation_date >= "%s"' |
|
501 |
% _today.strftime('%Y-%m-%d')) |
|
502 |
self._check_rset_size(rset, 3, 1) |
|
503 |
rset = self.req.execute('Any X WHERE X is Blog, X creation_date <= "%s"' |
|
504 |
% _tomorrow.strftime('%Y-%m-%d')) |
|
505 |
self._check_rset_size(rset, 3, 1) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
506 |
|
0 | 507 |
def test_7_identity_relation(self): |
508 |
rset = self.req.execute('Any X WHERE X identity Y, X eid %(x)s, Y eid %(y)s', |
|
509 |
{'x': self.user.eid, 'y': self.user.eid}) |
|
510 |
self._check_rset_size(rset, 1, 1) |
|
511 |
rset = self.req.execute('Any Y WHERE X identity Y, X eid %(x)s', |
|
512 |
{'x': self.user.eid}) |
|
513 |
self._check_rset_size(rset, 1, 1) |
|
514 |
self.assertEquals(rset.rows, [[self.user.eid]]) |
|
515 |
blog2 = self.add_entity('Blog', itemtype=u'personal', content=u'hip') |
|
516 |
rset = self.req.execute('Any X WHERE X identity Y, X eid %(x)s, Y eid %(y)s', |
|
517 |
{'x': self.blog.eid, 'y': blog2.eid}) |
|
518 |
self.failIf(rset) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
519 |
|
0 | 520 |
def test_8_not_relation_1(self): |
521 |
rset = self.req.execute('Any X WHERE X identity U, NOT U in_group G, ' |
|
522 |
'G name "guests", X eid %(x)s, U eid %(u)s', |
|
523 |
{'x': self.user.eid, 'u': self.user.eid}) |
|
524 |
self._check_rset_size(rset, 1, 1) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
525 |
self.assertEquals(rset.rows, [[self.user.eid]]) |
0 | 526 |
|
527 |
def test_8_not_relation_linked_subject(self): |
|
528 |
rset = self.req.execute('Any X WHERE NOT X talks_about Y, Y eid %(y)s', |
|
529 |
{'y': self.article.eid}) |
|
530 |
self.failIf(rset) |
|
531 |
blog2 = self.add_entity('Blog', content=u'hop', itemtype=u'personal') |
|
532 |
self.commit() |
|
533 |
rset = self.req.execute('Any X WHERE NOT X talks_about Y, Y eid %(y)s', |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
534 |
{'y': self.article.eid}) |
0 | 535 |
self._check_rset_size(rset, 1, 1) |
536 |
self.assertEquals(rset.rows, [[blog2.eid]]) |
|
537 |
||
538 |
def test_8_not_relation_linked_object(self): |
|
539 |
rset = self.req.execute('Any Y WHERE NOT X talks_about Y, X eid %(x)s', |
|
540 |
{'x': self.blog.eid}) |
|
541 |
self.failIf(rset) |
|
542 |
article2 = self.add_entity('Article', content=u'hop') |
|
543 |
self.commit() |
|
544 |
rset = self.req.execute('Any Y WHERE NOT X talks_about Y, X eid %(x)s', |
|
545 |
{'x': self.blog.eid}) |
|
546 |
self._check_rset_size(rset, 1, 1) |
|
547 |
self.assertEquals(rset.rows, [[article2.eid]]) |
|
548 |
||
549 |
def test_8_not_relation_linked_attr(self): |
|
550 |
self.skip('not yet implemented') |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
551 |
# TODO: this should generated |
0 | 552 |
# Query(X)[s_talks_about] > "hop" || Query(X)[s_talks_about] < "hop" |
553 |
article2 = self.add_entity('Article', content=u'hop') |
|
554 |
self.req.execute('SET X talks_about Y WHERE X eid %(x)s, Y eid %(y)s', |
|
555 |
{'x': self.blog.eid, 'y': article2.eid}) |
|
556 |
self.commit() |
|
557 |
rset = self.req.execute('Any X WHERE NOT X talks_about Y, Y content "hop"') |
|
558 |
self._check_rset_size(rset, 1, 2) |
|
559 |
self.assertEquals(rset.rows, [[self.blog.eid, self.article.eid]]) |
|
560 |
||
561 |
def test_8_not_relation_unlinked_subject(self): |
|
562 |
blog2 = self.add_entity('Blog', content=u'hop', itemtype=u'personal') |
|
563 |
self.commit() |
|
564 |
rset = self.req.execute('Any X WHERE NOT X talks_about Y') |
|
565 |
self._check_rset_size(rset, 1, 1) |
|
566 |
self.assertEquals(rset.rows, [[blog2.eid]]) |
|
567 |
||
568 |
def test_8_not_relation_unlinked_object(self): |
|
569 |
article2 = self.add_entity('Article', content=u'hop') |
|
570 |
self.commit() |
|
571 |
rset = self.req.execute('Any Y WHERE NOT X talks_about Y') |
|
572 |
self._check_rset_size(rset, 1, 1) |
|
573 |
self.assertEquals(rset.rows, [[article2.eid]]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
574 |
|
0 | 575 |
def test_8_not_relation_final_1(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
576 |
rset = self.req.execute('Any G WHERE G is CWGroup, NOT G name "guests"') |
0 | 577 |
self._check_rset_size(rset, 2, 1) |
578 |
self.assertUnorderedIterableEquals([g.name for g in rset.entities()], |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
579 |
['users', 'managers']) |
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
580 |
|
0 | 581 |
def test_8_not_relation_final_2(self): |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
582 |
rset = self.req.execute('Any GN WHERE G is CWGroup, NOT G name "guests", G name GN') |
0 | 583 |
self._check_rset_size(rset, 2, 1) |
584 |
self.assertUnorderedIterableEquals([gn for gn, in rset.rows], |
|
585 |
['users', 'managers']) |
|
586 |
||
587 |
||
588 |
def test_9_exists(self): |
|
589 |
blog2 = self.add_entity('Article', content=u'hop') |
|
590 |
article2 = self.add_entity('Article', content=u'hop') |
|
591 |
self.req.execute('SET X talks_about Y WHERE X eid %(x)s, Y eid %(y)s', |
|
592 |
{'x': self.blog.eid, 'y': article2.eid}) |
|
593 |
self.commit() |
|
594 |
rset = self.req.execute('Any X WHERE X is Blog, EXISTS(X talks_about Y)') |
|
595 |
self._check_rset_size(rset, 1, 1) |
|
596 |
self.assertEquals(rset.rows, [[self.blog.eid]]) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
597 |
|
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
598 |
|
0 | 599 |
def test_error_unknown_eid(self): |
600 |
rset = self.req.execute('Any X WHERE X eid %(x)s', {'x': '1234'}) |
|
601 |
self.assertEquals(len(rset), 0) |
|
602 |
self.blog.delete() |
|
603 |
rset = self.req.execute('Any X WHERE X eid %(x)s', {'x': self.blog.eid}) |
|
604 |
self.assertEquals(len(rset), 0) |
|
605 |
||
606 |
def test_nonregr_inlined_relation(self): |
|
607 |
eid = self.execute('INSERT YamsEntity X: X inlined_relation Y WHERE Y eid %(y)s', |
|
608 |
{'y': self.blog.eid})[0][0] |
|
609 |
self.commit() |
|
610 |
rset = self.execute('Any X WHERE Y inlined_relation X, Y eid %(y)s', {'y': eid}) |
|
611 |
self._check_rset_size(rset, 1, 1) |
|
612 |
self.assertEquals(rset[0][0], self.blog.eid) |
|
1802
d628defebc17
delete-trailing-whitespace + some copyright update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1398
diff
changeset
|
613 |
|
0 | 614 |
if __name__ == '__main__': |
615 |
unittest_main() |