author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Tue, 15 Jun 2010 18:00:28 +0200 | |
branch | stable |
changeset 5749 | b4393b681f7a |
parent 5424 | 8ecbcbff9777 |
child 5768 | 1e73a466aa69 |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: utf-8 -*- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
2 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
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:
4252
diff
changeset
|
18 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1654
diff
changeset
|
19 |
"""Unit tests for magic_search service |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1654
diff
changeset
|
20 |
|
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1654
diff
changeset
|
21 |
""" |
0 | 22 |
|
23 |
import sys |
|
24 |
||
25 |
from logilab.common.testlib import TestCase, unittest_main |
|
26 |
||
27 |
from rql import BadRQLQuery, RQLSyntaxError |
|
28 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
29 |
from cubicweb.devtools.testlib import CubicWebTC |
0 | 30 |
|
31 |
||
32 |
translations = { |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
33 |
u'CWUser' : u"Utilisateur", |
0 | 34 |
u'EmailAddress' : u"Adresse", |
35 |
u'name' : u"nom", |
|
36 |
u'alias' : u"nom", |
|
37 |
u'surname' : u"nom", |
|
38 |
u'firstname' : u"prénom", |
|
39 |
u'state' : u"état", |
|
40 |
u'address' : u"adresse", |
|
41 |
u'use_email' : u"adel", |
|
42 |
} |
|
3362
2a2dcfb379a0
[magicsearch] update to match new i18n API: config.translations[lang] now returns a couple of function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2661
diff
changeset
|
43 |
|
0 | 44 |
def _translate(msgid): |
45 |
return translations.get(msgid, msgid) |
|
46 |
||
3362
2a2dcfb379a0
[magicsearch] update to match new i18n API: config.translations[lang] now returns a couple of function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2661
diff
changeset
|
47 |
def _ctxtranslate(ctx, msgid): |
2a2dcfb379a0
[magicsearch] update to match new i18n API: config.translations[lang] now returns a couple of function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2661
diff
changeset
|
48 |
return _translate(msgid) |
0 | 49 |
|
50 |
from cubicweb.web.views.magicsearch import translate_rql_tree, QSPreProcessor, QueryTranslator |
|
51 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
52 |
class QueryTranslatorTC(CubicWebTC): |
0 | 53 |
"""test suite for QueryTranslatorTC""" |
1654 | 54 |
|
0 | 55 |
def setUp(self): |
56 |
super(QueryTranslatorTC, self).setUp() |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
57 |
self.req = self.request() |
3362
2a2dcfb379a0
[magicsearch] update to match new i18n API: config.translations[lang] now returns a couple of function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2661
diff
changeset
|
58 |
self.vreg.config.translations = {'en': (_translate, _ctxtranslate)} |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
59 |
proc = self.vreg['components'].select('magicsearch', self.req) |
0 | 60 |
self.proc = [p for p in proc.processors if isinstance(p, QueryTranslator)][0] |
61 |
||
62 |
def test_basic_translations(self): |
|
63 |
"""tests basic translations (no ambiguities)""" |
|
64 |
rql = "Any C WHERE C is Adresse, P adel C, C adresse 'Logilab'" |
|
3469
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
65 |
rql, = self.proc.preprocess_query(rql) |
0 | 66 |
self.assertEquals(rql, "Any C WHERE C is EmailAddress, P use_email C, C address 'Logilab'") |
67 |
||
68 |
def test_ambiguous_translations(self): |
|
69 |
"""tests possibly ambiguous translations""" |
|
70 |
rql = "Any P WHERE P adel C, C is EmailAddress, C nom 'Logilab'" |
|
3469
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
71 |
rql, = self.proc.preprocess_query(rql) |
0 | 72 |
self.assertEquals(rql, "Any P WHERE P use_email C, C is EmailAddress, C alias 'Logilab'") |
73 |
rql = "Any P WHERE P is Utilisateur, P adel C, P nom 'Smith'" |
|
3469
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
74 |
rql, = self.proc.preprocess_query(rql) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
75 |
self.assertEquals(rql, "Any P WHERE P is CWUser, P use_email C, P surname 'Smith'") |
0 | 76 |
|
77 |
||
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
78 |
class QSPreProcessorTC(CubicWebTC): |
0 | 79 |
"""test suite for QSPreProcessor""" |
80 |
def setUp(self): |
|
81 |
super(QSPreProcessorTC, self).setUp() |
|
3362
2a2dcfb379a0
[magicsearch] update to match new i18n API: config.translations[lang] now returns a couple of function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2661
diff
changeset
|
82 |
self.vreg.config.translations = {'en': (_translate, _ctxtranslate)} |
0 | 83 |
self.req = self.request() |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
84 |
proc = self.vreg['components'].select('magicsearch', self.req) |
0 | 85 |
self.proc = [p for p in proc.processors if isinstance(p, QSPreProcessor)][0] |
3462
3a79fecdd2b4
[magicsearch] make tests pass again: base preprocessor must have access to vreg
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3369
diff
changeset
|
86 |
self.proc._cw = self.req |
0 | 87 |
|
88 |
def test_entity_translation(self): |
|
89 |
"""tests QSPreProcessor._get_entity_name()""" |
|
90 |
translate = self.proc._get_entity_type |
|
91 |
self.assertEquals(translate(u'EmailAddress'), "EmailAddress") |
|
92 |
self.assertEquals(translate(u'emailaddress'), "EmailAddress") |
|
93 |
self.assertEquals(translate(u'Adresse'), "EmailAddress") |
|
94 |
self.assertEquals(translate(u'adresse'), "EmailAddress") |
|
95 |
self.assertRaises(BadRQLQuery, translate, 'whatever') |
|
96 |
||
97 |
def test_attribute_translation(self): |
|
98 |
"""tests QSPreProcessor._get_attribute_name""" |
|
99 |
translate = self.proc._get_attribute_name |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
100 |
eschema = self.schema.eschema('CWUser') |
0 | 101 |
self.assertEquals(translate(u'prénom', eschema), "firstname") |
102 |
self.assertEquals(translate(u'nom', eschema), 'surname') |
|
1654 | 103 |
eschema = self.schema.eschema('EmailAddress') |
0 | 104 |
self.assertEquals(translate(u'adresse', eschema), "address") |
105 |
self.assertEquals(translate(u'nom', eschema), 'alias') |
|
106 |
# should fail if the name is not an attribute for the given entity schema |
|
107 |
self.assertRaises(BadRQLQuery, translate, 'whatever', eschema) |
|
108 |
self.assertRaises(BadRQLQuery, translate, 'prénom', eschema) |
|
109 |
||
110 |
def test_one_word_query(self): |
|
111 |
"""tests the 'one word shortcut queries'""" |
|
112 |
transform = self.proc._one_word_query |
|
113 |
self.assertEquals(transform('123'), |
|
114 |
('Any X WHERE X eid %(x)s', {'x': 123}, 'x')) |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
115 |
self.assertEquals(transform('CWUser'), |
1654 | 116 |
('CWUser C',)) |
0 | 117 |
self.assertEquals(transform('Utilisateur'), |
1654 | 118 |
('CWUser C',)) |
0 | 119 |
self.assertEquals(transform('Adresse'), |
120 |
('EmailAddress E',)) |
|
121 |
self.assertEquals(transform('adresse'), |
|
122 |
('EmailAddress E',)) |
|
123 |
self.assertRaises(BadRQLQuery, transform, 'Workcases') |
|
124 |
||
125 |
def test_two_words_query(self): |
|
126 |
"""tests the 'two words shortcut queries'""" |
|
127 |
transform = self.proc._two_words_query |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
128 |
self.assertEquals(transform('CWUser', 'E'), |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
129 |
("CWUser E",)) |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
130 |
self.assertEquals(transform('CWUser', 'Smith'), |
1654 | 131 |
('CWUser C WHERE C has_text %(text)s', {'text': 'Smith'})) |
0 | 132 |
self.assertEquals(transform('utilisateur', 'Smith'), |
1654 | 133 |
('CWUser C WHERE C has_text %(text)s', {'text': 'Smith'})) |
0 | 134 |
self.assertEquals(transform(u'adresse', 'Logilab'), |
135 |
('EmailAddress E WHERE E has_text %(text)s', {'text': 'Logilab'})) |
|
136 |
self.assertEquals(transform(u'adresse', 'Logi%'), |
|
137 |
('EmailAddress E WHERE E alias LIKE %(text)s', {'text': 'Logi%'})) |
|
138 |
self.assertRaises(BadRQLQuery, transform, "pers", "taratata") |
|
139 |
||
140 |
def test_three_words_query(self): |
|
141 |
"""tests the 'three words shortcut queries'""" |
|
142 |
transform = self.proc._three_words_query |
|
143 |
self.assertEquals(transform('utilisateur', u'prénom', 'cubicweb'), |
|
1654 | 144 |
('CWUser C WHERE C firstname %(text)s', {'text': 'cubicweb'})) |
0 | 145 |
self.assertEquals(transform('utilisateur', 'nom', 'cubicweb'), |
1654 | 146 |
('CWUser C WHERE C surname %(text)s', {'text': 'cubicweb'})) |
0 | 147 |
self.assertEquals(transform(u'adresse', 'nom', 'cubicweb'), |
148 |
('EmailAddress E WHERE E alias %(text)s', {'text': 'cubicweb'})) |
|
149 |
self.assertEquals(transform('EmailAddress', 'nom', 'cubicweb'), |
|
1654 | 150 |
('EmailAddress E WHERE E alias %(text)s', {'text': 'cubicweb'})) |
0 | 151 |
self.assertEquals(transform('utilisateur', u'prénom', 'cubicweb%'), |
1654 | 152 |
('CWUser C WHERE C firstname LIKE %(text)s', {'text': 'cubicweb%'})) |
0 | 153 |
# expanded shortcuts |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
154 |
self.assertEquals(transform('CWUser', 'use_email', 'Logilab'), |
1654 | 155 |
('CWUser C WHERE C use_email C1, C1 has_text %(text)s', {'text': 'Logilab'})) |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
156 |
self.assertEquals(transform('CWUser', 'use_email', '%Logilab'), |
1654 | 157 |
('CWUser C WHERE C use_email C1, C1 alias LIKE %(text)s', {'text': '%Logilab'})) |
0 | 158 |
self.assertRaises(BadRQLQuery, transform, 'word1', 'word2', 'word3') |
1654 | 159 |
|
0 | 160 |
def test_quoted_queries(self): |
161 |
"""tests how quoted queries are handled""" |
|
162 |
queries = [ |
|
163 |
(u'Adresse "My own EmailAddress"', ('EmailAddress E WHERE E has_text %(text)s', {'text': u'My own EmailAddress'})), |
|
1654 | 164 |
(u'Utilisateur prénom "Jean Paul"', ('CWUser C WHERE C firstname %(text)s', {'text': 'Jean Paul'})), |
165 |
(u'Utilisateur firstname "Jean Paul"', ('CWUser C WHERE C firstname %(text)s', {'text': 'Jean Paul'})), |
|
166 |
(u'CWUser firstname "Jean Paul"', ('CWUser C WHERE C firstname %(text)s', {'text': 'Jean Paul'})), |
|
0 | 167 |
] |
168 |
transform = self.proc._quoted_words_query |
|
169 |
for query, expected in queries: |
|
170 |
self.assertEquals(transform(query), expected) |
|
171 |
self.assertRaises(BadRQLQuery, transform, "unquoted rql") |
|
172 |
self.assertRaises(BadRQLQuery, transform, 'pers "Jean Paul"') |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
173 |
self.assertRaises(BadRQLQuery, transform, 'CWUser firstname other "Jean Paul"') |
1654 | 174 |
|
0 | 175 |
def test_process_query(self): |
176 |
"""tests how queries are processed""" |
|
177 |
queries = [ |
|
1654 | 178 |
(u'Utilisateur', (u"CWUser C",)), |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
179 |
(u'Utilisateur P', (u"CWUser P",)), |
1654 | 180 |
(u'Utilisateur cubicweb', (u'CWUser C WHERE C has_text %(text)s', {'text': u'cubicweb'})), |
181 |
(u'CWUser prénom cubicweb', (u'CWUser C WHERE C firstname %(text)s', {'text': 'cubicweb'},)), |
|
0 | 182 |
] |
183 |
for query, expected in queries: |
|
3469
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
184 |
self.assertEquals(self.proc.preprocess_query(query), expected) |
2643
9976f511003b
web test update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2637
diff
changeset
|
185 |
self.assertRaises(BadRQLQuery, |
3469
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
186 |
self.proc.preprocess_query, 'Any X WHERE X is Something') |
1654 | 187 |
|
0 | 188 |
|
189 |
||
190 |
## Processor Chains tests ############################################ |
|
1654 | 191 |
|
0 | 192 |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
193 |
class ProcessorChainTC(CubicWebTC): |
0 | 194 |
"""test suite for magic_search's processor chains""" |
195 |
||
196 |
def setUp(self): |
|
197 |
super(ProcessorChainTC, self).setUp() |
|
3362
2a2dcfb379a0
[magicsearch] update to match new i18n API: config.translations[lang] now returns a couple of function
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2661
diff
changeset
|
198 |
self.vreg.config.translations = {'en': (_translate, _ctxtranslate)} |
0 | 199 |
self.req = self.request() |
2661
f8df42c9da6b
[vreg api update] remove some deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2643
diff
changeset
|
200 |
self.proc = self.vreg['components'].select('magicsearch', self.req) |
0 | 201 |
|
202 |
def test_main_preprocessor_chain(self): |
|
203 |
"""tests QUERY_PROCESSOR""" |
|
204 |
queries = [ |
|
205 |
(u'foo', |
|
206 |
("Any X WHERE X has_text %(text)s", {'text': u'foo'})), |
|
207 |
# XXX this sounds like a language translator test... |
|
2773
b2530e3e0afb
[testlib] #345052 and #344207: major test lib refactoring/cleanup + update usage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2661
diff
changeset
|
208 |
# and it fails |
0 | 209 |
(u'Utilisateur Smith', |
1654 | 210 |
('CWUser C WHERE C has_text %(text)s', {'text': u'Smith'})), |
0 | 211 |
(u'utilisateur nom Smith', |
1654 | 212 |
('CWUser C WHERE C surname %(text)s', {'text': u'Smith'})), |
0 | 213 |
(u'Any P WHERE P is Utilisateur, P nom "Smith"', |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
0
diff
changeset
|
214 |
('Any P WHERE P is CWUser, P surname "Smith"', None)), |
0 | 215 |
] |
216 |
for query, expected in queries: |
|
3469
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
217 |
rset = self.proc.process_query(query) |
0 | 218 |
self.assertEquals((rset.rql, rset.args), expected) |
219 |
||
220 |
def test_iso88591_fulltext(self): |
|
221 |
"""we must be able to type accentuated characters in the search field""" |
|
3469
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
222 |
rset = self.proc.process_query(u'écrire') |
0 | 223 |
self.assertEquals(rset.rql, "Any X WHERE X has_text %(text)s") |
224 |
self.assertEquals(rset.args, {'text': u'écrire'}) |
|
225 |
||
226 |
def test_explicit_component(self): |
|
227 |
self.assertRaises(RQLSyntaxError, |
|
3469
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
228 |
self.proc.process_query, u'rql: CWUser E WHERE E noattr "Smith",') |
0 | 229 |
self.assertRaises(BadRQLQuery, |
3469
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
230 |
self.proc.process_query, u'rql: CWUser E WHERE E noattr "Smith"') |
1e28876c4b55
[magicsearch] (pre_)process_query doesn't need the req argument, instances already have access to self._cw
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3462
diff
changeset
|
231 |
rset = self.proc.process_query(u'text: utilisateur Smith') |
0 | 232 |
self.assertEquals(rset.rql, 'Any X WHERE X has_text %(text)s') |
233 |
self.assertEquals(rset.args, {'text': u'utilisateur Smith'}) |
|
1654 | 234 |
|
0 | 235 |
if __name__ == '__main__': |
236 |
unittest_main() |