Skip to content
Snippets Groups Projects
Commit 760e4f664adb authored by Arthur Lutz's avatar Arthur Lutz
Browse files

[test] test pagination, fix html bug

parent 452c9e6ab6d9
No related branches found
No related tags found
No related merge requests found
......@@ -4,6 +4,7 @@
import sys
import unittest
from io import StringIO
from itertools import repeat
from mock import patch
......@@ -112,7 +113,8 @@
'title': 'test'},
'_type': 'BaseContent',
'_score': 1}
return FacetedResponse({'hits': {'hits': [result],
'total': 1
}})
search = {'hits': {'hits': repeat(result,15),
'total': 15
}}
return FacetedResponse(search, search)
......@@ -118,5 +120,7 @@
def mock_cnx(*args, **kwargs):
return True
class ElasticSearchViewsTC(testlib.CubicWebTC):
@patch('elasticsearch_dsl.search.Search.execute', new=mock_execute)
......@@ -119,7 +123,8 @@
class ElasticSearchViewsTC(testlib.CubicWebTC):
@patch('elasticsearch_dsl.search.Search.execute', new=mock_execute)
@patch('elasticsearch_dsl.connections.connections.get_connection', new=mock_cnx)
def test_search_view(self):
with self.new_access('anon').web_request() as req:
# self._cw.form.get('search'))
......
......@@ -113,7 +113,7 @@
self.w(u'index not found in elasticsearch')
return
self.w(u'Résultats: %s' % response.hits.total)
if response.facets:
if hasattr(response, 'facets'):
self.display_facets(response)
self.display_results(response)
......@@ -157,6 +157,6 @@
current_page = int(url_params.get('page', 1))
url_params['page'] = current_page - 1
if current_page - 1 >= 1:
ul(t.li(t.a('<<<',
ul(t.li(t.a('&gt;' * 3,
href=self._cw.build_url(**url_params))))
else:
......@@ -161,6 +161,6 @@
href=self._cw.build_url(**url_params))))
else:
ul(t.li(t.a('<<<')))
ul(t.li(t.a('&lt;' * 3)))
total_pages = response.hits.total / 10
page_padding = 3
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment