diff options
author | dalf <alex@al-f.net> | 2016-10-22 14:01:53 +0200 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2016-11-02 14:22:16 +0100 |
commit | fbb080f3588ad43bf896a569257f3a95e1181d7b (patch) | |
tree | 8852a7af03c4e9bafe65885fae89417d47da7685 /tests | |
parent | 67e11c42b973932c8f568d80a0f25bfd7fc150ab (diff) | |
download | searxng-fbb080f3588ad43bf896a569257f3a95e1181d7b.tar.gz searxng-fbb080f3588ad43bf896a569257f3a95e1181d7b.zip |
Change plugin API :
- pre_search(request, search)
- post_search(request, search)
- on_result(request, search, result)
with
- request is the Flask request
- search a searx.Search instance
- result a searx result as usual
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_plugins.py | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/tests/unit/test_plugins.py b/tests/unit/test_plugins.py index 9ba6fcdd2..c9e65dfcb 100644 --- a/tests/unit/test_plugins.py +++ b/tests/unit/test_plugins.py @@ -6,8 +6,8 @@ from mock import Mock def get_search_mock(query, **kwargs): - return {'search': Mock(query=query, **kwargs), - 'result_container': Mock(answers=set())} + return Mock(search_query=Mock(query=query, **kwargs), + result_container=Mock(answers=set())) class PluginStoreTest(SearxTestCase): @@ -51,39 +51,39 @@ class SelfIPTest(SearxTestCase): request = Mock(user_plugins=store.plugins, remote_addr='127.0.0.1') request.headers.getlist.return_value = [] - ctx = get_search_mock(query='ip', pageno=1) - store.call('post_search', request, ctx) - self.assertTrue('127.0.0.1' in ctx['result_container'].answers) + search = get_search_mock(query='ip', pageno=1) + store.call('post_search', request, search) + self.assertTrue('127.0.0.1' in search.result_container.answers) - ctx = get_search_mock(query='ip', pageno=2) - store.call('post_search', request, ctx) - self.assertFalse('127.0.0.1' in ctx['result_container'].answers) + search = get_search_mock(query='ip', pageno=2) + store.call('post_search', request, search) + self.assertFalse('127.0.0.1' in search.result_container.answers) # User agent test request = Mock(user_plugins=store.plugins, user_agent='Mock') request.headers.getlist.return_value = [] - ctx = get_search_mock(query='user-agent', pageno=1) - store.call('post_search', request, ctx) - self.assertTrue('Mock' in ctx['result_container'].answers) + search = get_search_mock(query='user-agent', pageno=1) + store.call('post_search', request, search) + self.assertTrue('Mock' in search.result_container.answers) - ctx = get_search_mock(query='user-agent', pageno=2) - store.call('post_search', request, ctx) - self.assertFalse('Mock' in ctx['result_container'].answers) + search = get_search_mock(query='user-agent', pageno=2) + store.call('post_search', request, search) + self.assertFalse('Mock' in search.result_container.answers) - ctx = get_search_mock(query='user-agent', pageno=1) - store.call('post_search', request, ctx) - self.assertTrue('Mock' in ctx['result_container'].answers) + search = get_search_mock(query='user-agent', pageno=1) + store.call('post_search', request, search) + self.assertTrue('Mock' in search.result_container.answers) - ctx = get_search_mock(query='user-agent', pageno=2) - store.call('post_search', request, ctx) - self.assertFalse('Mock' in ctx['result_container'].answers) + search = get_search_mock(query='user-agent', pageno=2) + store.call('post_search', request, search) + self.assertFalse('Mock' in search.result_container.answers) - ctx = get_search_mock(query='What is my User-Agent?', pageno=1) - store.call('post_search', request, ctx) - self.assertTrue('Mock' in ctx['result_container'].answers) + search = get_search_mock(query='What is my User-Agent?', pageno=1) + store.call('post_search', request, search) + self.assertTrue('Mock' in search.result_container.answers) - ctx = get_search_mock(query='What is my User-Agent?', pageno=2) - store.call('post_search', request, ctx) - self.assertFalse('Mock' in ctx['result_container'].answers) + search = get_search_mock(query='What is my User-Agent?', pageno=2) + store.call('post_search', request, search) + self.assertFalse('Mock' in search.result_container.answers) |