Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46e8be53 authored by Nicolas Gelot's avatar Nicolas Gelot
Browse files

Fix unit test test_index_html

parent 4b0c4062
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -9,3 +9,4 @@ transifex-client==0.12.2
unittest2==1.1.0
zope.testrunner==4.5.1
selenium==3.5.0
mockredispy==2.9.3
+2 −1
Original line number Diff line number Diff line
@@ -32,7 +32,8 @@ class SearchData(object):


def _get_connection(host):
    return redis.StrictRedis(host if host else settings['redis']['host'], decode_responses=True)
    host = host if host else settings['redis']['host']
    return redis.StrictRedis(host=host, decode_responses=True)


def read(q, host):
+15 −11
Original line number Diff line number Diff line
# -*- coding: utf-8 -*-

import json
from mock import Mock
from mock import Mock, patch
from mockredis import mock_strict_redis_client
from searx import webapp
from searx.testing import SearxTestCase
from searx.search import Search
@@ -19,12 +20,14 @@ class ViewsTestCase(SearxTestCase):
            {
                'content': 'first test content',
                'title': 'First Test',
                'category': 'general',
                'url': 'http://first.test.xyz',
                'engines': ['youtube', 'startpage'],
                'engine': 'startpage',
                'parsed_url': ParseResult(scheme='http', netloc='first.test.xyz', path='/', params='', query='', fragment=''),  # noqa
            }, {
                'content': 'second test content',
                'category': 'general',
                'title': 'Second Test',
                'url': 'http://second.test.xyz',
                'engines': ['youtube', 'startpage'],
@@ -33,8 +36,8 @@ class ViewsTestCase(SearxTestCase):
            },
        ]

        def search_mock(search_self, *args):
            search_self.result_container = Mock(get_ordered_results=lambda: self.test_results,
        def search_mock(*args):
            return Mock(get_ordered_results=lambda: self.test_results,
                        answers=set(),
                        corrections=set(),
                        suggestions=set(),
@@ -60,6 +63,7 @@ class ViewsTestCase(SearxTestCase):
        self.assertEqual(result.status_code, 200)
        self.assertIn(b'<div class="title"><h1>searx</h1></div>', result.data)

    @patch('redis.StrictRedis', mock_strict_redis_client)
    def test_index_html(self):
        result = self.app.post('/', data={'q': 'test'})
        self.assertIn(