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 From 41fd748cdf7a6bcb14b664ded16f339eb864900c Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 15 Jun 2015 10:22:37 +0200 Subject: Merge self_ip and self_useragent into one plugin --- searx/tests/test_plugins.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'searx/tests/test_plugins.py') diff --git a/searx/tests/test_plugins.py b/searx/tests/test_plugins.py index c12e71e1d..15bcab475 100644 --- a/searx/tests/test_plugins.py +++ b/searx/tests/test_plugins.py @@ -38,10 +38,9 @@ class SelfIPTest(SearxTestCase): def test_PluginStore_init(self): store = plugins.PluginStore() - store.register(plugins.self_ip) - store.register(plugins.self_useragent) + store.register(plugins.self) - self.assertTrue(len(store.plugins) == 2) + self.assertTrue(len(store.plugins) == 1) # IP test request = Mock(user_plugins=store.plugins, @@ -64,3 +63,6 @@ class SelfIPTest(SearxTestCase): 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?')} + store.call('post_search', request, ctx) -- cgit v1.2.3 From 0fe362bacf608f535680a68c0d38784b331a45e3 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Mon, 15 Jun 2015 13:36:38 +0200 Subject: Change self plugin to self_info + change self_info description --- searx/tests/test_plugins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'searx/tests/test_plugins.py') diff --git a/searx/tests/test_plugins.py b/searx/tests/test_plugins.py index 15bcab475..c5171127c 100644 --- a/searx/tests/test_plugins.py +++ b/searx/tests/test_plugins.py @@ -38,7 +38,7 @@ class SelfIPTest(SearxTestCase): def test_PluginStore_init(self): store = plugins.PluginStore() - store.register(plugins.self) + store.register(plugins.self_info) self.assertTrue(len(store.plugins) == 1) -- cgit v1.2.3