summaryrefslogtreecommitdiff
path: root/tests/unit/test_plugins.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-09-13 19:37:51 +0200
committerAlexandre Flament <alex@al-f.net>2021-10-06 19:18:19 +0200
commit2b4fef71186be1e4a9ce160ddfa6707e2f138a3e (patch)
treef1e3037e04a533849bcd1834e35b2b4af93f87da /tests/unit/test_plugins.py
parentadeb084cf4ffc59f1e49b47d049e7541be6dd5dd (diff)
downloadsearxng-2b4fef71186be1e4a9ce160ddfa6707e2f138a3e.tar.gz
searxng-2b4fef71186be1e4a9ce160ddfa6707e2f138a3e.zip
plugins: refactor initialization
add a new function "init" call when the app starts. The function can: * return False to disable the plugin. * modify the Flask app.
Diffstat (limited to 'tests/unit/test_plugins.py')
-rw-r--r--tests/unit/test_plugins.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/unit/test_plugins.py b/tests/unit/test_plugins.py
index 245a7566b..5bad4e5c4 100644
--- a/tests/unit/test_plugins.py
+++ b/tests/unit/test_plugins.py
@@ -10,6 +10,12 @@ def get_search_mock(query, **kwargs):
result_container=Mock(answers=dict()))
+class PluginMock():
+ default_on = False
+ name = 'Default plugin'
+ description = 'Default plugin description'
+
+
class PluginStoreTest(SearxTestCase):
def test_PluginStore_init(self):
@@ -18,14 +24,14 @@ class PluginStoreTest(SearxTestCase):
def test_PluginStore_register(self):
store = plugins.PluginStore()
- testplugin = plugins.Plugin()
+ testplugin = PluginMock()
store.register(testplugin)
self.assertTrue(len(store.plugins) == 1)
def test_PluginStore_call(self):
store = plugins.PluginStore()
- testplugin = plugins.Plugin()
+ testplugin = PluginMock()
store.register(testplugin)
setattr(testplugin, 'asdf', Mock())
request = Mock()
@@ -40,8 +46,9 @@ class PluginStoreTest(SearxTestCase):
class SelfIPTest(SearxTestCase):
def test_PluginStore_init(self):
+ plugin = plugins.load_and_initialize_plugin('searx.plugins.self_info', False, (None, {}))
store = plugins.PluginStore()
- store.register(plugins.self_info)
+ store.register(plugin)
self.assertTrue(len(store.plugins) == 1)
@@ -89,7 +96,8 @@ class HashPluginTest(SearxTestCase):
def test_PluginStore_init(self):
store = plugins.PluginStore()
- store.register(plugins.hash_plugin)
+ plugin = plugins.load_and_initialize_plugin('searx.plugins.hash_plugin', False, (None, {}))
+ store.register(plugin)
self.assertTrue(len(store.plugins) == 1)