search: do not try to parse results in case of error (#76022) #80
|
@ -284,6 +284,9 @@ class SearchCell(CellBase):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return render_response(service)
|
return render_response(service)
|
||||||
|
|
||||||
|
if results.get('err'):
|
||||||
|
return render_response(service)
|
||||||
|
|
||||||
if service.get('data_key'):
|
if service.get('data_key'):
|
||||||
results['data'] = results.get(service['data_key']) or []
|
results['data'] = results.get(service['data_key']) or []
|
||||||
hit_templates = {}
|
hit_templates = {}
|
||||||
|
|
|
@ -317,6 +317,13 @@ def test_search_custom_templates(app):
|
||||||
assert '<li><a href="http://example.net/123/">A B</a>' in resp.text
|
assert '<li><a href="http://example.net/123/">A B</a>' in resp.text
|
||||||
assert '<div>description A</div>' in resp.text
|
assert '<div>description A</div>' in resp.text
|
||||||
|
|
||||||
|
# err != 0 is handled
|
||||||
|
response = {'err': 1, 'data': 'something'}
|
||||||
|
mock_json.json.return_value = response
|
||||||
|
|
||||||
|
resp = app.get('/ajax/search/%s/search2/?q=foo' % cell.pk, status=200)
|
||||||
|
assert 'no result found' in resp.text
|
||||||
|
|
||||||
|
|
||||||
def test_search_cell_visibility(settings, app):
|
def test_search_cell_visibility(settings, app):
|
||||||
request = RequestFactory().get('/')
|
request = RequestFactory().get('/')
|
||||||
|
|
Loading…
Reference in New Issue