summaryrefslogtreecommitdiff
path: root/tests/unit/test_query.py
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2017-07-20 15:47:20 -0500
committerMarc Abonce Seguin <marc-abonce@mailbox.org>2017-12-06 01:20:15 -0600
commit4d1770398a6af8902e75c0bd885781584d39e796 (patch)
tree1ad30e59206eca081c93a2ad37928ce059f7d114 /tests/unit/test_query.py
parent46fb0d860e35a45658969c4e2ac306a1072bc331 (diff)
downloadsearxng-4d1770398a6af8902e75c0bd885781584d39e796.tar.gz
searxng-4d1770398a6af8902e75c0bd885781584d39e796.zip
remove 'all' option from search languages
Diffstat (limited to 'tests/unit/test_query.py')
-rw-r--r--tests/unit/test_query.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py
new file mode 100644
index 000000000..49ccb608f
--- /dev/null
+++ b/tests/unit/test_query.py
@@ -0,0 +1,64 @@
+from searx.query import RawTextQuery
+from searx.testing import SearxTestCase
+
+
+class TestQuery(SearxTestCase):
+
+ def test_simple_query(self):
+ query_text = 'the query'
+ query = RawTextQuery(query_text, [])
+ query.parse_query()
+
+ self.assertEquals(query.getFullQuery(), query_text)
+ self.assertEquals(len(query.query_parts), 1)
+ self.assertEquals(len(query.languages), 0)
+ self.assertFalse(query.specific)
+
+ def test_language_code(self):
+ language = 'es-ES'
+ query_text = 'the query'
+ full_query = ':' + language + ' ' + query_text
+ query = RawTextQuery(full_query, [])
+ query.parse_query()
+
+ self.assertEquals(query.getFullQuery(), full_query)
+ self.assertEquals(len(query.query_parts), 3)
+ self.assertEquals(len(query.languages), 1)
+ self.assertIn(language, query.languages)
+ self.assertFalse(query.specific)
+
+ def test_language_name(self):
+ language = 'english'
+ query_text = 'the query'
+ full_query = ':' + language + ' ' + query_text
+ query = RawTextQuery(full_query, [])
+ query.parse_query()
+
+ self.assertEquals(query.getFullQuery(), full_query)
+ self.assertEquals(len(query.query_parts), 3)
+ self.assertIn('en', query.languages)
+ self.assertFalse(query.specific)
+
+ def test_unlisted_language_code(self):
+ language = 'all'
+ query_text = 'the query'
+ full_query = ':' + language + ' ' + query_text
+ query = RawTextQuery(full_query, [])
+ query.parse_query()
+
+ self.assertEquals(query.getFullQuery(), full_query)
+ self.assertEquals(len(query.query_parts), 3)
+ self.assertIn('all', query.languages)
+ self.assertFalse(query.specific)
+
+ def test_invalid_language_code(self):
+ language = 'not_a_language'
+ query_text = 'the query'
+ full_query = ':' + language + ' ' + query_text
+ query = RawTextQuery(full_query, [])
+ query.parse_query()
+
+ self.assertEquals(query.getFullQuery(), full_query)
+ self.assertEquals(len(query.query_parts), 1)
+ self.assertEquals(len(query.languages), 0)
+ self.assertFalse(query.specific)