From 538029dc14ca47afae126e29bf789941d9bffd48 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Sat, 13 Jun 2015 17:49:33 +0200 Subject: Add a self user agent plugin Just like with the "ip" query, duckduckgo gives the server's information with the "user agent" query. This corrects this behavior by adding a plugin based on self_ip.py plugin. --- searx/tests/test_plugins.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'searx/tests/test_plugins.py') diff --git a/searx/tests/test_plugins.py b/searx/tests/test_plugins.py index 8dcad1142..c12e71e1d 100644 --- a/searx/tests/test_plugins.py +++ b/searx/tests/test_plugins.py @@ -39,9 +39,11 @@ class SelfIPTest(SearxTestCase): def test_PluginStore_init(self): store = plugins.PluginStore() store.register(plugins.self_ip) + store.register(plugins.self_useragent) - self.assertTrue(len(store.plugins) == 1) + self.assertTrue(len(store.plugins) == 2) + # IP test request = Mock(user_plugins=store.plugins, remote_addr='127.0.0.1') request.headers.getlist.return_value = [] @@ -49,3 +51,16 @@ class SelfIPTest(SearxTestCase): query='ip')} store.call('post_search', request, ctx) self.assertTrue('127.0.0.1' in ctx['search'].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')} + store.call('post_search', request, ctx) + self.assertTrue('Mock' in ctx['search'].answers) + ctx = {'search': Mock(answers=set(), + query='user agent')} + store.call('post_search', request, ctx) + self.assertTrue('Mock' in ctx['search'].answers) -- cgit v1.2.3