summaryrefslogtreecommitdiff
path: root/tests/unit/test_search.py
diff options
context:
space:
mode:
authorMarkus Heiser <markus.heiser@darmarit.de>2021-12-27 09:26:22 +0100
committerMarkus Heiser <markus.heiser@darmarit.de>2021-12-27 09:26:22 +0100
commit3d96a9839a12649874b6d4cf9466bd3616b0a03c (patch)
treee7d54d1e345b1e792d538ddc250f4827bb2fd9b9 /tests/unit/test_search.py
parentfcdc2c2cd26e24c2aa3f064d93cee3e29dc2a30c (diff)
downloadsearxng-3d96a9839a12649874b6d4cf9466bd3616b0a03c.tar.gz
searxng-3d96a9839a12649874b6d4cf9466bd3616b0a03c.zip
[format.python] initial formatting of the python code
This patch was generated by black [1]:: make format.python [1] https://github.com/psf/black Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'tests/unit/test_search.py')
-rw-r--r--tests/unit/test_search.py58
1 files changed, 37 insertions, 21 deletions
diff --git a/tests/unit/test_search.py b/tests/unit/test_search.py
index c7f15a681..fa16947be 100644
--- a/tests/unit/test_search.py
+++ b/tests/unit/test_search.py
@@ -22,11 +22,11 @@ TEST_ENGINES = [
class SearchQueryTestCase(SearxTestCase):
-
def test_repr(self):
s = SearchQuery('test', [EngineRef('bing', 'general')], 'all', 0, 1, '1', 5.0, 'g')
- self.assertEqual(repr(s),
- "SearchQuery('test', [EngineRef('bing', 'general')], 'all', 0, 1, '1', 5.0, 'g')") # noqa
+ self.assertEqual(
+ repr(s), "SearchQuery('test', [EngineRef('bing', 'general')], 'all', 0, 1, '1', 5.0, 'g')"
+ ) # noqa
def test_eq(self):
s = SearchQuery('test', [EngineRef('bing', 'general')], 'all', 0, 1, None, None, None)
@@ -36,64 +36,80 @@ class SearchQueryTestCase(SearxTestCase):
class SearchTestCase(SearxTestCase):
-
@classmethod
def setUpClass(cls):
searx.search.initialize(TEST_ENGINES)
def test_timeout_simple(self):
settings['outgoing']['max_request_timeout'] = None
- search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
- 'en-US', SAFESEARCH, PAGENO, None, None)
+ search_query = SearchQuery(
+ 'test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')], 'en-US', SAFESEARCH, PAGENO, None, None
+ )
search = searx.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 3.0)
def test_timeout_query_above_default_nomax(self):
settings['outgoing']['max_request_timeout'] = None
- search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
- 'en-US', SAFESEARCH, PAGENO, None, 5.0)
+ search_query = SearchQuery(
+ 'test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')], 'en-US', SAFESEARCH, PAGENO, None, 5.0
+ )
search = searx.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 3.0)
def test_timeout_query_below_default_nomax(self):
settings['outgoing']['max_request_timeout'] = None
- search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
- 'en-US', SAFESEARCH, PAGENO, None, 1.0)
+ search_query = SearchQuery(
+ 'test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')], 'en-US', SAFESEARCH, PAGENO, None, 1.0
+ )
search = searx.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 1.0)
def test_timeout_query_below_max(self):
settings['outgoing']['max_request_timeout'] = 10.0
- search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
- 'en-US', SAFESEARCH, PAGENO, None, 5.0)
+ search_query = SearchQuery(
+ 'test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')], 'en-US', SAFESEARCH, PAGENO, None, 5.0
+ )
search = searx.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 5.0)
def test_timeout_query_above_max(self):
settings['outgoing']['max_request_timeout'] = 10.0
- search_query = SearchQuery('test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
- 'en-US', SAFESEARCH, PAGENO, None, 15.0)
+ search_query = SearchQuery(
+ 'test', [EngineRef(PUBLIC_ENGINE_NAME, 'general')], 'en-US', SAFESEARCH, PAGENO, None, 15.0
+ )
search = searx.search.Search(search_query)
search.search()
self.assertEqual(search.actual_timeout, 10.0)
def test_external_bang(self):
- search_query = SearchQuery('yes yes',
- [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
- 'en-US', SAFESEARCH, PAGENO, None, None,
- external_bang="yt")
+ search_query = SearchQuery(
+ 'yes yes',
+ [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
+ 'en-US',
+ SAFESEARCH,
+ PAGENO,
+ None,
+ None,
+ external_bang="yt",
+ )
search = searx.search.Search(search_query)
results = search.search()
# For checking if the user redirected with the youtube external bang
self.assertTrue(results.redirect_url is not None)
- search_query = SearchQuery('youtube never gonna give you up',
- [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
- 'en-US', SAFESEARCH, PAGENO, None, None)
+ search_query = SearchQuery(
+ 'youtube never gonna give you up',
+ [EngineRef(PUBLIC_ENGINE_NAME, 'general')],
+ 'en-US',
+ SAFESEARCH,
+ PAGENO,
+ None,
+ None,
+ )
search = searx.search.Search(search_query)
results = search.search()