diff options
Diffstat (limited to 'tests/unit/test_preferences.py')
-rw-r--r-- | tests/unit/test_preferences.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tests/unit/test_preferences.py b/tests/unit/test_preferences.py index 5855c12a6..8bf157a7e 100644 --- a/tests/unit/test_preferences.py +++ b/tests/unit/test_preferences.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: AGPL-3.0-or-later # pylint: disable=missing-module-docstring, invalid-name +from tests import SearxTestCase from searx.locales import locales_initialize from searx.preferences import ( EnumStringSetting, @@ -10,12 +11,12 @@ from searx.preferences import ( PluginsSetting, ValidationException, ) -from tests import SearxTestCase +from searx.plugins import Plugin locales_initialize() -class PluginStub: # pylint: disable=missing-class-docstring, too-few-public-methods +class PluginStub(Plugin): # pylint: disable=missing-class-docstring, too-few-public-methods def __init__(self, plugin_id, default_on): self.id = plugin_id self.default_on = default_on @@ -47,22 +48,22 @@ class TestSettings(SearxTestCase): # pylint: disable=missing-class-docstring def test_enum_setting_invalid_default_value(self): with self.assertRaises(ValidationException): - EnumStringSetting(3, choices=[0, 1, 2]) + EnumStringSetting('3', choices=['0', '1', '2']) def test_enum_setting_invalid_choice(self): - setting = EnumStringSetting(0, choices=[0, 1, 2]) + setting = EnumStringSetting('0', choices=['0', '1', '2']) with self.assertRaises(ValidationException): - setting.parse(3) + setting.parse('3') def test_enum_setting_valid_default(self): - setting = EnumStringSetting(3, choices=[1, 2, 3]) - self.assertEqual(setting.get_value(), 3) + setting = EnumStringSetting('3', choices=['1', '2', '3']) + self.assertEqual(setting.get_value(), '3') def test_enum_setting_valid_choice(self): - setting = EnumStringSetting(3, choices=[1, 2, 3]) - self.assertEqual(setting.get_value(), 3) - setting.parse(2) - self.assertEqual(setting.get_value(), 2) + setting = EnumStringSetting('3', choices=['1', '2', '3']) + self.assertEqual(setting.get_value(), '3') + setting.parse('2') + self.assertEqual(setting.get_value(), '2') # multiple choice settings |