Merge branch 'master' into new-readme

This commit is contained in:
Markus Heiser 2020-06-12 05:35:14 +00:00 committed by GitHub
commit 1789184386
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -7,7 +7,7 @@ from mock import Mock
def get_search_mock(query, **kwargs): def get_search_mock(query, **kwargs):
return Mock(search_query=Mock(query=query, **kwargs), return Mock(search_query=Mock(query=query, **kwargs),
result_container=Mock(answers=set())) result_container=Mock(answers=dict()))
class PluginStoreTest(SearxTestCase): class PluginStoreTest(SearxTestCase):
@ -50,11 +50,11 @@ class SelfIPTest(SearxTestCase):
request.headers.getlist.return_value = [] request.headers.getlist.return_value = []
search = get_search_mock(query=b'ip', pageno=1) search = get_search_mock(query=b'ip', pageno=1)
store.call(store.plugins, 'post_search', request, search) store.call(store.plugins, 'post_search', request, search)
self.assertTrue('127.0.0.1' in search.result_container.answers) self.assertTrue('127.0.0.1' in search.result_container.answers["ip"]["answer"])
search = get_search_mock(query=b'ip', pageno=2) search = get_search_mock(query=b'ip', pageno=2)
store.call(store.plugins, 'post_search', request, search) store.call(store.plugins, 'post_search', request, search)
self.assertFalse('127.0.0.1' in search.result_container.answers) self.assertFalse('ip' in search.result_container.answers)
# User agent test # User agent test
request = Mock(user_agent='Mock') request = Mock(user_agent='Mock')
@ -62,24 +62,24 @@ class SelfIPTest(SearxTestCase):
search = get_search_mock(query=b'user-agent', pageno=1) search = get_search_mock(query=b'user-agent', pageno=1)
store.call(store.plugins, 'post_search', request, search) store.call(store.plugins, 'post_search', request, search)
self.assertTrue('Mock' in search.result_container.answers) self.assertTrue('Mock' in search.result_container.answers["user-agent"]["answer"])
search = get_search_mock(query=b'user-agent', pageno=2) search = get_search_mock(query=b'user-agent', pageno=2)
store.call(store.plugins, 'post_search', request, search) store.call(store.plugins, 'post_search', request, search)
self.assertFalse('Mock' in search.result_container.answers) self.assertFalse('user-agent' in search.result_container.answers)
search = get_search_mock(query=b'user-agent', pageno=1) search = get_search_mock(query=b'user-agent', pageno=1)
store.call(store.plugins, 'post_search', request, search) store.call(store.plugins, 'post_search', request, search)
self.assertTrue('Mock' in search.result_container.answers) self.assertTrue('Mock' in search.result_container.answers["user-agent"]["answer"])
search = get_search_mock(query=b'user-agent', pageno=2) search = get_search_mock(query=b'user-agent', pageno=2)
store.call(store.plugins, 'post_search', request, search) store.call(store.plugins, 'post_search', request, search)
self.assertFalse('Mock' in search.result_container.answers) self.assertFalse('user-agent' in search.result_container.answers)
search = get_search_mock(query=b'What is my User-Agent?', pageno=1) search = get_search_mock(query=b'What is my User-Agent?', pageno=1)
store.call(store.plugins, 'post_search', request, search) store.call(store.plugins, 'post_search', request, search)
self.assertTrue('Mock' in search.result_container.answers) self.assertTrue('Mock' in search.result_container.answers["user-agent"]["answer"])
search = get_search_mock(query=b'What is my User-Agent?', pageno=2) search = get_search_mock(query=b'What is my User-Agent?', pageno=2)
store.call(store.plugins, 'post_search', request, search) store.call(store.plugins, 'post_search', request, search)
self.assertFalse('Mock' in search.result_container.answers) self.assertFalse('user-agent' in search.result_container.answers)

View File

@ -48,7 +48,7 @@ class ViewsTestCase(SearxTestCase):
def search_mock(search_self, *args): def search_mock(search_self, *args):
search_self.result_container = Mock(get_ordered_results=lambda: test_results, search_self.result_container = Mock(get_ordered_results=lambda: test_results,
answers=set(), answers=dict(),
corrections=set(), corrections=set(),
suggestions=set(), suggestions=set(),
infoboxes=[], infoboxes=[],