diff options
author | Martin Fischer <martin@push-f.com> | 2022-01-04 11:53:42 +0100 |
---|---|---|
committer | Martin Fischer <martin@push-f.com> | 2022-01-06 14:21:14 +0100 |
commit | bb06758a7b737befcb28b8fe202d2c6da767146d (patch) | |
tree | b0d410e89d838ddd1a1d839a2ba1c5db96fb3f55 /tests/unit/test_preferences.py | |
parent | 93c6829b27d5319ca85af798015f1e11da566f1f (diff) | |
download | searxng-bb06758a7b737befcb28b8fe202d2c6da767146d.tar.gz searxng-bb06758a7b737befcb28b8fe202d2c6da767146d.zip |
[refactor] add type hints & remove Setting._post_init
Previously the Setting classes used a horrible _post_init
hack that prevented proper type checking.
Diffstat (limited to 'tests/unit/test_preferences.py')
-rw-r--r-- | tests/unit/test_preferences.py | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/tests/unit/test_preferences.py b/tests/unit/test_preferences.py index 1ffed5c1a..18323940b 100644 --- a/tests/unit/test_preferences.py +++ b/tests/unit/test_preferences.py @@ -1,7 +1,6 @@ from searx.preferences import ( EnumStringSetting, MapSetting, - MissingArgumentException, SearchLanguageSetting, MultipleChoiceSetting, PluginsSetting, @@ -19,10 +18,6 @@ class PluginStub: class TestSettings(SearxTestCase): # map settings - def test_map_setting_invalid_initialization(self): - with self.assertRaises(MissingArgumentException): - MapSetting(3, wrong_argument={'0': 0}) - def test_map_setting_invalid_default_value(self): with self.assertRaises(ValidationException): MapSetting(3, map={'dog': 1, 'bat': 2}) @@ -43,9 +38,6 @@ class TestSettings(SearxTestCase): self.assertEqual(setting.get_value(), 2) # enum settings - def test_enum_setting_invalid_initialization(self): - with self.assertRaises(MissingArgumentException): - EnumStringSetting('cat', wrong_argument=[0, 1, 2]) def test_enum_setting_invalid_default_value(self): with self.assertRaises(ValidationException): @@ -67,9 +59,6 @@ class TestSettings(SearxTestCase): self.assertEqual(setting.get_value(), 2) # multiple choice settings - def test_multiple_setting_invalid_initialization(self): - with self.assertRaises(MissingArgumentException): - MultipleChoiceSetting(['2'], wrong_argument=['0', '1', '2']) def test_multiple_setting_invalid_default_value(self): with self.assertRaises(ValidationException): @@ -115,14 +104,14 @@ class TestSettings(SearxTestCase): def test_plugins_setting_all_default_enabled(self): plugin1 = PluginStub('plugin1', True) plugin2 = PluginStub('plugin2', True) - setting = PluginsSetting(['3'], choices=[plugin1, plugin2]) + setting = PluginsSetting(['3'], plugins=[plugin1, plugin2]) self.assertEqual(setting.get_enabled(), set(['plugin1', 'plugin2'])) def test_plugins_setting_few_default_enabled(self): plugin1 = PluginStub('plugin1', True) plugin2 = PluginStub('plugin2', False) plugin3 = PluginStub('plugin3', True) - setting = PluginsSetting('name', choices=[plugin1, plugin2, plugin3]) + setting = PluginsSetting('name', plugins=[plugin1, plugin2, plugin3]) self.assertEqual(setting.get_enabled(), set(['plugin1', 'plugin3'])) |