diff options
author | Alexandre Flament <alex@al-f.net> | 2020-11-14 13:23:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-14 13:23:44 +0100 |
commit | 46b454277f70cb504a1276286e07048b8a5651bf (patch) | |
tree | 0d4d536500e98c818e3f6ee010b613faf7ce0554 /tests | |
parent | ebed1461bc4b635b6dde5d99e53dada6711a6d7a (diff) | |
parent | 8fc74d0d7b51014a24c9d2dc9442434d91c4e711 (diff) | |
download | searxng-46b454277f70cb504a1276286e07048b8a5651bf.tar.gz searxng-46b454277f70cb504a1276286e07048b8a5651bf.zip |
Merge pull request #2309 from dalf/mod_search_repr
[mod] searx.search: EngineRef, SearchQuery: add __repr__ and __eq__ methods
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_search.py | 14 | ||||
-rw-r--r-- | tests/unit/test_standalone_searx.py | 3 |
2 files changed, 16 insertions, 1 deletions
diff --git a/tests/unit/test_search.py b/tests/unit/test_search.py index 36135913c..464a9b37d 100644 --- a/tests/unit/test_search.py +++ b/tests/unit/test_search.py @@ -21,6 +21,20 @@ TEST_ENGINES = [ ] +class SearchQueryTestCase(SearxTestCase): + + def test_repr(self): + s = SearchQuery('test', [EngineRef('bing', 'general', False)], ['general'], 'all', 0, 1, '1', 5.0, 'g') + self.assertEqual(repr(s), + "SearchQuery('test', [EngineRef('bing', 'general', False)], ['general'], 'all', 0, 1, '1', 5.0, 'g')") # noqa + + def test_eq(self): + s = SearchQuery('test', [EngineRef('bing', 'general', False)], ['general'], 'all', 0, 1, None, None, None) + t = SearchQuery('test', [EngineRef('google', 'general', False)], ['general'], 'all', 0, 1, None, None, None) + self.assertEqual(s, s) + self.assertNotEqual(s, t) + + class SearchTestCase(SearxTestCase): @classmethod diff --git a/tests/unit/test_standalone_searx.py b/tests/unit/test_standalone_searx.py index cd1a14f46..c00f033b6 100644 --- a/tests/unit/test_standalone_searx.py +++ b/tests/unit/test_standalone_searx.py @@ -7,6 +7,7 @@ import sys from mock import Mock, patch from nose2.tools import params +from searx.search import SearchQuery from searx.testing import SearxTestCase @@ -91,7 +92,7 @@ class StandaloneSearx(SearxTestCase): args = sas.parse_argument(['rain', ]) search_q = sas.get_search_query(args) self.assertTrue(search_q) - self.assertEqual(str(search_q), 'rain;[]') + self.assertEqual(search_q, SearchQuery('rain', [], ['general'], 'all', 0, 1, None, None, None)) def test_no_parsed_url(self): """test no_parsed_url func""" |