on master help sign in
[fix] fix a test_standalone_searx test case
230a5ecAlexandre Flament
tests/unit/test_standalone_searx.py+12−2
@@ -8,7 +8,8 @@ import sys
8from mock import Mock, patch
8from mock import Mock, patch
9from nose2.tools import params
9from nose2.tools import params
10
10
11−from searx.search import SearchQuery
11+from searx.search import SearchQuery, EngineRef
12+from searx.engines import initialize_engines
12from searx.testing import SearxTestCase
13from searx.testing import SearxTestCase
13
14
14
15
@@ -25,6 +26,13 @@ def get_standalone_searx_module():
25class StandaloneSearx(SearxTestCase):
26class StandaloneSearx(SearxTestCase):
26 """Unit test for standalone_searx."""
27 """Unit test for standalone_searx."""
27
28
29+ @classmethod
30+ def setUpClass(cls):
31+ engine_list = [{'engine': 'dummy', 'name': 'engine1', 'shortcut': 'e1'},
32+ {'engine': 'dummy', 'name': 'engine2', 'shortcut': 'e2'}]
33+
34+ initialize_engines(engine_list)
35+
28 def test_parse_argument_no_args(self):
36 def test_parse_argument_no_args(self):
29 """Test parse argument without args."""
37 """Test parse argument without args."""
30 sas = get_standalone_searx_module()
38 sas = get_standalone_searx_module()
@@ -95,7 +103,9 @@ class StandaloneSearx(SearxTestCase):
95 args = sas.parse_argument(['rain', ])
103 args = sas.parse_argument(['rain', ])
96 search_q = sas.get_search_query(args)
104 search_q = sas.get_search_query(args)
97 self.assertTrue(search_q)
105 self.assertTrue(search_q)
98− self.assertEqual(search_q, SearchQuery('rain', [], ['general'], 'all', 0, 1, None, None, None))
106+ self.assertEqual(search_q, SearchQuery('rain', [EngineRef('engine1', 'general', False),
107+ EngineRef('engine2', 'general', False)],
108+ ['general'], 'all', 0, 1, None, None, None))
99
109
100 def test_no_parsed_url(self):
110 def test_no_parsed_url(self):
101 """test no_parsed_url func"""
111 """test no_parsed_url func"""