192 |
192 |
'text_template': '{{numero}} {{nom_rue}} {{nom_commun}}',
|
193 |
193 |
'q': "rue de l'aubepine",
|
194 |
194 |
'rows': 3,
|
195 |
195 |
}
|
196 |
196 |
mocked_get.return_value = utils.FakedResponse(content=FAKED_CONTENT_Q_SEARCH, status_code=200)
|
197 |
197 |
resp = app.get(endpoint, params=params, status=200)
|
198 |
198 |
assert not resp.json['err']
|
199 |
199 |
assert len(resp.json['data']) == 3
|
200 |
|
# check order is kept
|
|
200 |
# check ordering
|
201 |
201 |
assert [x['id'] for x in resp.json['data']] == [
|
202 |
|
'e00cf6161e52a4c8fe510b2b74d4952036cb3473',
|
203 |
202 |
'7cafcd5c692773e8b863587b2d38d6be82e023d8',
|
204 |
203 |
'0984a5e1745701f71c91af73ce764e1f7132e0ff',
|
|
204 |
'e00cf6161e52a4c8fe510b2b74d4952036cb3473',
|
205 |
205 |
]
|
206 |
206 |
# check text results
|
207 |
207 |
assert [x['text'] for x in resp.json['data']] == [
|
208 |
|
"33 RUE DE L'AUBEPINE Strasbourg",
|
209 |
208 |
"19 RUE DE L'AUBEPINE Lipsheim",
|
210 |
209 |
"29 RUE DE L'AUBEPINE Strasbourg",
|
|
210 |
"33 RUE DE L'AUBEPINE Strasbourg",
|
211 |
211 |
]
|
212 |
212 |
# check additional attributes
|
213 |
|
assert [x['numero'] for x in resp.json['data']] == ['33', '19', '29']
|
|
213 |
assert [x['numero'] for x in resp.json['data']] == ['19', '29', '33']
|
214 |
214 |
|
215 |
215 |
|
216 |
216 |
@mock.patch('passerelle.utils.Request.get')
|
217 |
217 |
def test_search_using_id(mocked_get, app, connector):
|
218 |
218 |
endpoint = utils.generic_endpoint_url('opendatasoft', 'search', slug=connector.slug)
|
219 |
219 |
assert endpoint == '/opendatasoft/my_connector/search'
|
220 |
220 |
params = {
|
221 |
221 |
'dataset': 'referentiel-adresse-test',
|
... | ... | |
234 |
234 |
params = {
|
235 |
235 |
'q': "rue de l'aubepine",
|
236 |
236 |
'rows': 3,
|
237 |
237 |
}
|
238 |
238 |
mocked_get.return_value = utils.FakedResponse(content=FAKED_CONTENT_Q_SEARCH, status_code=200)
|
239 |
239 |
resp = app.get(endpoint, params=params, status=200)
|
240 |
240 |
assert not resp.json['err']
|
241 |
241 |
assert len(resp.json['data']) == 3
|
242 |
|
# check order is kept
|
|
242 |
# check ordering
|
243 |
243 |
assert [x['id'] for x in resp.json['data']] == [
|
244 |
|
'e00cf6161e52a4c8fe510b2b74d4952036cb3473',
|
245 |
244 |
'7cafcd5c692773e8b863587b2d38d6be82e023d8',
|
246 |
245 |
'0984a5e1745701f71c91af73ce764e1f7132e0ff',
|
|
246 |
'e00cf6161e52a4c8fe510b2b74d4952036cb3473',
|
247 |
247 |
]
|
248 |
248 |
# check text results
|
249 |
249 |
assert [x['text'] for x in resp.json['data']] == [
|
250 |
|
"33 RUE DE L'AUBEPINE Strasbourg",
|
251 |
250 |
"19 RUE DE L'AUBEPINE Lipsheim",
|
252 |
251 |
"29 RUE DE L'AUBEPINE Strasbourg",
|
|
252 |
"33 RUE DE L'AUBEPINE Strasbourg",
|
253 |
253 |
]
|
254 |
254 |
# check additional attributes
|
255 |
|
assert [x['numero'] for x in resp.json['data']] == ['33', '19', '29']
|
|
255 |
assert [x['numero'] for x in resp.json['data']] == ['19', '29', '33']
|
256 |
256 |
|
257 |
257 |
|
258 |
258 |
@mock.patch('passerelle.utils.Request.get')
|
259 |
259 |
def test_query_q_using_id(mocked_get, app, query):
|
260 |
260 |
endpoint = '/opendatasoft/my_connector/q/my_query/'
|
261 |
261 |
params = {
|
262 |
262 |
'id': '7cafcd5c692773e8b863587b2d38d6be82e023d8',
|
263 |
263 |
}
|
264 |
|
-
|