[refactor] refactor SwitchableSetting

The previous implementation used two hash sets and a list.
... that's not necessary ... a single hash map suffices.

And it's also less error prone ... because the previous data structure
allowed a setting to be enabled and disabled at the same time.
This commit is contained in:
Martin Fischer 2022-01-06 18:45:50 +01:00
parent 56fbf22108
commit 180d4d068b
2 changed files with 33 additions and 51 deletions

View file

@ -105,14 +105,14 @@ class TestSettings(SearxTestCase):
plugin1 = PluginStub('plugin1', True)
plugin2 = PluginStub('plugin2', True)
setting = PluginsSetting(['3'], plugins=[plugin1, plugin2])
self.assertEqual(setting.get_enabled(), set(['plugin1', 'plugin2']))
self.assertEqual(set(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', plugins=[plugin1, plugin2, plugin3])
self.assertEqual(setting.get_enabled(), set(['plugin1', 'plugin3']))
self.assertEqual(set(setting.get_enabled()), set(['plugin1', 'plugin3']))
class TestPreferences(SearxTestCase):