# HG changeset patch
# User Arthur Lutz <arthur.lutz@logilab.fr>
# Date 1464804552 -7200
#      Wed Jun 01 20:09:12 2016 +0200
# Node ID 760e4f664adb3bf4e1046d5c3ec21ff3f36b623a
# Parent  452c9e6ab6d97a9ba22ab567ca2676f855a414be
[test] test pagination, fix html bug

diff --git a/test/test_elastic_search.py b/test/test_elastic_search.py
--- a/test/test_elastic_search.py
+++ b/test/test_elastic_search.py
@@ -4,6 +4,7 @@
 import sys
 import unittest
 from io import StringIO
+from itertools import repeat
 
 from mock import patch
 
@@ -112,14 +113,18 @@
                           '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)
 
+def mock_cnx(*args, **kwargs):
+    return True
 
 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'))
diff --git a/views.py b/views.py
--- a/views.py
+++ b/views.py
@@ -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,10 +157,10 @@
             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:
-                ul(t.li(t.a('<<<')))
+                ul(t.li(t.a('&lt;' * 3)))
             total_pages = response.hits.total / 10
             page_padding = 3