# SPDX-License-Identifier: AGPL-3.0-or-later # pylint: disable=missing-module-docstring from parameterized.parameterized import parameterized import searx.search from searx.query import RawTextQuery from tests import SearxTestCase TEST_ENGINES = [ { 'name': 'dummy engine', 'engine': 'dummy', 'categories': 'general', 'shortcut': 'du', 'timeout': 3.0, 'tokens': [], }, ] class TestQuery(SearxTestCase): # pylint:disable=missing-class-docstring def test_simple_query(self): query_text = 'the query' query = RawTextQuery(query_text, []) self.assertEqual(query.getFullQuery(), query_text) self.assertEqual(len(query.query_parts), 0) self.assertEqual(len(query.user_query_parts), 2) self.assertEqual(len(query.languages), 0) self.assertFalse(query.specific) def test_multiple_spaces_query(self): query_text = '\tthe query' query = RawTextQuery(query_text, []) self.assertEqual(query.getFullQuery(), 'the query') self.assertEqual(len(query.query_parts), 0) self.assertEqual(len(query.user_query_parts), 2) self.assertEqual(len(query.languages), 0) self.assertFalse(query.specific) def test_str_method(self): query_text = '<7 the query' query = RawTextQuery(query_text, []) self.assertEqual(str(query), '<7 the query') def test_repr_method(self): query_text = '<8 the query' query = RawTextQuery(query_text, []) r = repr(query) self.assertTrue(r.startswith(f"