mirror of
https://github.com/searxng/searxng.git
synced 2024-12-28 20:20:30 +00:00
8c1a65d32f
it prepares the new architecture change, everything about multithreading in moved in the searx.search.* packages previously the call to the "init" function of the engines was done in searx.engines: * the network was not set (request not sent using the defined proxy) * it requires to monkey patch the code to avoid HTTP requests during the tests
44 lines
2 KiB
Python
44 lines
2 KiB
Python
from searx.testing import SearxTestCase
|
|
from searx import settings, engines
|
|
|
|
|
|
class TestEnginesInit(SearxTestCase):
|
|
|
|
@classmethod
|
|
def tearDownClass(cls):
|
|
settings['outgoing']['using_tor_proxy'] = False
|
|
settings['outgoing']['extra_proxy_timeout'] = 0
|
|
|
|
def test_initialize_engines_default(self):
|
|
engine_list = [{'engine': 'dummy', 'name': 'engine1', 'shortcut': 'e1'},
|
|
{'engine': 'dummy', 'name': 'engine2', 'shortcut': 'e2'}]
|
|
|
|
engines.load_engines(engine_list)
|
|
self.assertEqual(len(engines.engines), 2)
|
|
self.assertIn('engine1', engines.engines)
|
|
self.assertIn('engine2', engines.engines)
|
|
|
|
def test_initialize_engines_exclude_onions(self):
|
|
settings['outgoing']['using_tor_proxy'] = False
|
|
engine_list = [{'engine': 'dummy', 'name': 'engine1', 'shortcut': 'e1', 'categories': 'general'},
|
|
{'engine': 'dummy', 'name': 'engine2', 'shortcut': 'e2', 'categories': 'onions'}]
|
|
|
|
engines.load_engines(engine_list)
|
|
self.assertEqual(len(engines.engines), 1)
|
|
self.assertIn('engine1', engines.engines)
|
|
self.assertNotIn('onions', engines.categories)
|
|
|
|
def test_initialize_engines_include_onions(self):
|
|
settings['outgoing']['using_tor_proxy'] = True
|
|
settings['outgoing']['extra_proxy_timeout'] = 100.0
|
|
engine_list = [{'engine': 'dummy', 'name': 'engine1', 'shortcut': 'e1', 'categories': 'general',
|
|
'timeout': 20.0, 'onion_url': 'http://engine1.onion'},
|
|
{'engine': 'dummy', 'name': 'engine2', 'shortcut': 'e2', 'categories': 'onions'}]
|
|
|
|
engines.load_engines(engine_list)
|
|
self.assertEqual(len(engines.engines), 2)
|
|
self.assertIn('engine1', engines.engines)
|
|
self.assertIn('engine2', engines.engines)
|
|
self.assertIn('onions', engines.categories)
|
|
self.assertIn('http://engine1.onion', engines.engines['engine1'].search_url)
|
|
self.assertEqual(engines.engines['engine1'].timeout, 120.0)
|