diff options
author | Alexandre Flament <alex@al-f.net> | 2022-12-16 20:28:57 +0000 |
---|---|---|
committer | Alexandre Flament <alex@al-f.net> | 2023-02-17 15:17:36 +0000 |
commit | 6748e8e2d5eff3c2202b2a714afb5534b1573101 (patch) | |
tree | 57f6fcf3d5b9bb5ee3b4a03aaf8aac2a53ee7106 /tests | |
parent | 54389a29feb3feea5a868f7b3b83c9718fb71014 (diff) | |
download | searxng-6748e8e2d5eff3c2202b2a714afb5534b1573101.tar.gz searxng-6748e8e2d5eff3c2202b2a714afb5534b1573101.zip |
Add "Auto-detected" as a language.
When the user choose "Auto-detected", the choice remains on the following queries.
The detected language is displayed.
For example "Auto-detected (en)":
* the next query language is going to be auto detected
* for the current query, the detected language is English.
This replace the autodetect_search_language plugin.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/test_query.py | 11 | ||||
-rw-r--r-- | tests/unit/test_search.py | 7 |
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit/test_query.py b/tests/unit/test_query.py index db25da8f3..7274a8da5 100644 --- a/tests/unit/test_query.py +++ b/tests/unit/test_query.py @@ -91,6 +91,17 @@ class TestLanguageParser(SearxTestCase): self.assertIn('all', query.languages) self.assertFalse(query.specific) + def test_auto_language_code(self): + language = 'auto' + query_text = 'una consulta' + full_query = ':' + language + ' ' + query_text + query = RawTextQuery(full_query, []) + + self.assertEqual(query.getFullQuery(), full_query) + self.assertEqual(len(query.query_parts), 1) + self.assertIn('auto', query.languages) + self.assertFalse(query.specific) + def test_invalid_language_code(self): language = 'not_a_language' query_text = 'the query' diff --git a/tests/unit/test_search.py b/tests/unit/test_search.py index fa16947be..33bf90840 100644 --- a/tests/unit/test_search.py +++ b/tests/unit/test_search.py @@ -1,5 +1,7 @@ # -*- coding: utf-8 -*- +from copy import copy + import searx.search from searx.search import SearchQuery, EngineRef from searx import settings @@ -34,6 +36,11 @@ class SearchQueryTestCase(SearxTestCase): self.assertEqual(s, s) self.assertNotEqual(s, t) + def test_copy(self): + s = SearchQuery('test', [EngineRef('bing', 'general')], 'all', 0, 1, None, None, None) + t = copy(s) + self.assertEqual(s, t) + class SearchTestCase(SearxTestCase): @classmethod |