mirror of
https://github.com/searxng/searxng.git
synced 2025-07-16 01:39:24 +02:00
[mod] multithreading only in searx.search.* packages
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
This commit is contained in:
parent
d36adfa59f
commit
8c1a65d32f
10 changed files with 85 additions and 65 deletions
|
@ -1,11 +1,8 @@
|
|||
from mock import patch
|
||||
|
||||
from searx.search import initialize
|
||||
from searx import settings
|
||||
from searx.engines import load_engines
|
||||
from searx.query import RawTextQuery
|
||||
from searx.testing import SearxTestCase
|
||||
|
||||
import searx.engines
|
||||
|
||||
|
||||
TEST_ENGINES = [
|
||||
{
|
||||
|
@ -241,7 +238,7 @@ class TestBang(SearxTestCase):
|
|||
THE_QUERY = 'the query'
|
||||
|
||||
def test_bang(self):
|
||||
initialize(TEST_ENGINES)
|
||||
load_engines(TEST_ENGINES)
|
||||
|
||||
for bang in TestBang.SPECIFIC_BANGS + TestBang.NOT_SPECIFIC_BANGS:
|
||||
with self.subTest(msg="Check bang", bang=bang):
|
||||
|
@ -267,12 +264,12 @@ class TestBang(SearxTestCase):
|
|||
self.assertFalse(query.specific)
|
||||
|
||||
def test_bang_not_found(self):
|
||||
initialize(TEST_ENGINES)
|
||||
load_engines(TEST_ENGINES)
|
||||
query = RawTextQuery('the query !bang_not_found', [])
|
||||
self.assertEqual(query.getFullQuery(), 'the query !bang_not_found')
|
||||
|
||||
def test_bang_autocomplete(self):
|
||||
initialize(TEST_ENGINES)
|
||||
load_engines(TEST_ENGINES)
|
||||
query = RawTextQuery('the query !dum', [])
|
||||
self.assertEqual(query.autocomplete_list, ['!dummy_engine'])
|
||||
|
||||
|
@ -281,10 +278,9 @@ class TestBang(SearxTestCase):
|
|||
self.assertEqual(query.getQuery(), '!dum the query')
|
||||
|
||||
def test_bang_autocomplete_empty(self):
|
||||
with patch.object(searx.engines, 'initialize_engines', searx.engines.load_engines):
|
||||
initialize()
|
||||
query = RawTextQuery('the query !', [])
|
||||
self.assertEqual(query.autocomplete_list, ['!images', '!wikipedia', '!osm'])
|
||||
load_engines(settings['engines'])
|
||||
query = RawTextQuery('the query !', [])
|
||||
self.assertEqual(query.autocomplete_list, ['!images', '!wikipedia', '!osm'])
|
||||
|
||||
query = RawTextQuery('the query ?', ['osm'])
|
||||
self.assertEqual(query.autocomplete_list, ['?images', '?wikipedia'])
|
||||
query = RawTextQuery('the query ?', ['osm'])
|
||||
self.assertEqual(query.autocomplete_list, ['?images', '?wikipedia'])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue