diff options
| author | Luc Didry <luc@didry.org> | 2015-06-13 17:49:33 +0200 |
|---|---|---|
| committer | Luc Didry <luc@didry.org> | 2015-06-14 21:08:38 +0200 |
| commit | 538029dc14ca47afae126e29bf789941d9bffd48 (patch) | |
| tree | 2497ed6d4a430b80210055fb5f83ff40adf81057 /searx/tests/test_plugins.py | |
| parent | 1b77befe1fb1dbf82f99db69f857d21a7f0fdd6e (diff) | |
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.
Diffstat (limited to 'searx/tests/test_plugins.py')
| -rw-r--r-- | searx/tests/test_plugins.py | 17 |
1 files changed, 16 insertions, 1 deletions
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) |