summaryrefslogtreecommitdiff
path: root/tests/unit/test_preferences.py
diff options
context:
space:
mode:
authormarc <a01200356@itesm.mx>2016-12-13 23:51:15 -0600
committermarc <a01200356@itesm.mx>2016-12-13 23:51:15 -0600
commite0c270bd72f7b2a40222e3ed264e25d36cb0fc30 (patch)
tree2a0d67f6d5874350baf0ec6733e1e1241df2ad1f /tests/unit/test_preferences.py
parent1b46ecd21a15cdea4234a568e9ac973bb6b65b8a (diff)
downloadsearxng-e0c270bd72f7b2a40222e3ed264e25d36cb0fc30.tar.gz
searxng-e0c270bd72f7b2a40222e3ed264e25d36cb0fc30.zip
tests for language support in engines
Diffstat (limited to 'tests/unit/test_preferences.py')
-rw-r--r--tests/unit/test_preferences.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/unit/test_preferences.py b/tests/unit/test_preferences.py
index c17350809..885c515e2 100644
--- a/tests/unit/test_preferences.py
+++ b/tests/unit/test_preferences.py
@@ -1,4 +1,4 @@
-from searx.preferences import (EnumStringSetting, MapSetting, MissingArgumentException,
+from searx.preferences import (EnumStringSetting, MapSetting, MissingArgumentException, SearchLanguageSetting,
MultipleChoiceSetting, PluginsSetting, ValidationException)
from searx.testing import SearxTestCase
@@ -88,6 +88,27 @@ class TestSettings(SearxTestCase):
setting.parse('2')
self.assertEquals(setting.get_value(), ['2'])
+ # search language settings
+ def test_lang_setting_valid_choice(self):
+ setting = SearchLanguageSetting('all', choices=['all', 'de', 'en'])
+ setting.parse('de')
+ self.assertEquals(setting.get_value(), 'de')
+
+ def test_lang_setting_invalid_choice(self):
+ setting = SearchLanguageSetting('all', choices=['all', 'de', 'en'])
+ setting.parse('xx')
+ self.assertEquals(setting.get_value(), 'all')
+
+ def test_lang_setting_old_cookie_choice(self):
+ setting = SearchLanguageSetting('all', choices=['all', 'es', 'es-ES'])
+ setting.parse('es_XA')
+ self.assertEquals(setting.get_value(), 'es')
+
+ def test_lang_setting_old_cookie_format(self):
+ setting = SearchLanguageSetting('all', choices=['all', 'es', 'es-ES'])
+ setting.parse('es_ES')
+ self.assertEquals(setting.get_value(), 'es-ES')
+
# plugins settings
def test_plugins_setting_all_default_enabled(self):
plugin1 = PluginStub('plugin1', True)