from searx.search import initialize from searx.query import RawTextQuery from searx.testing import SearxTestCase TEST_ENGINES = [ { 'name': 'dummy engine', 'engine': 'dummy', 'categories': 'general', 'shortcut': 'du', 'timeout': 3.0, 'tokens': [], }, ] class TestQuery(SearxTestCase): 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"