From a959977ab445bca91059d98bf8ca822fffc51fdf Mon Sep 17 00:00:00 2001 From: Adam Tauber Date: Fri, 23 Oct 2015 23:31:53 +0200 Subject: [PATCH] [fix] tests fix after result refactor --- searx/tests/test_plugins.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/searx/tests/test_plugins.py b/searx/tests/test_plugins.py index c5171127..98d39ec1 100644 --- a/searx/tests/test_plugins.py +++ b/searx/tests/test_plugins.py @@ -5,6 +5,12 @@ from searx import plugins from mock import Mock +def get_search_mock(query, **kwargs): + return {'search': Mock(query=query, + result_container=Mock(answers=set()), + **kwargs)} + + class PluginStoreTest(SearxTestCase): def test_PluginStore_init(self): @@ -46,23 +52,23 @@ class SelfIPTest(SearxTestCase): request = Mock(user_plugins=store.plugins, remote_addr='127.0.0.1') request.headers.getlist.return_value = [] - ctx = {'search': Mock(answers=set(), - query='ip')} + ctx = get_search_mock(query='ip') store.call('post_search', request, ctx) - self.assertTrue('127.0.0.1' in ctx['search'].answers) + self.assertTrue('127.0.0.1' in ctx['search'].result_container.answers) # User agent test request = Mock(user_plugins=store.plugins, user_agent='Mock') request.headers.getlist.return_value = [] - ctx = {'search': Mock(answers=set(), - query='user-agent')} + + ctx = get_search_mock(query='user-agent') store.call('post_search', request, ctx) - self.assertTrue('Mock' in ctx['search'].answers) - ctx = {'search': Mock(answers=set(), - query='user agent')} + self.assertTrue('Mock' in ctx['search'].result_container.answers) + + ctx = get_search_mock(query='user-agent') store.call('post_search', request, ctx) - self.assertTrue('Mock' in ctx['search'].answers) - ctx = {'search': Mock(answers=set(), - query='What is my User-Agent?')} + self.assertTrue('Mock' in ctx['search'].result_container.answers) + + ctx = get_search_mock(query='What is my User-Agent?') store.call('post_search', request, ctx) + self.assertTrue('Mock' in ctx['search'].result_container.answers)