From 82bd4887137157f5c3e44e656083fc975bdfa630 Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Sat, 17 Jan 2026 09:10:21 +0100 Subject: [PATCH] importsource: Test listeners based on config --- test/plugins/test_importsource.py | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/plugins/test_importsource.py b/test/plugins/test_importsource.py index a4f498181..20de3b6dd 100644 --- a/test/plugins/test_importsource.py +++ b/test/plugins/test_importsource.py @@ -144,3 +144,35 @@ class ImportSourceTest(PluginMixin, AutotagImportTestCase): plugin = plugins._instances[0] mock_task = MockTask() plugin.prevent_suggest_removal(None, mock_task) + + +class ImportSourceTestListenerRegistration(PluginMixin, AutotagImportTestCase): + """Test listener registration based on config.""" + + plugin = "importsource" + preload_plugin = False + + def setUp(self): + preserve_plugin_listeners() + super().setUp() + + def test_listeners_not_registered_when_disabled(self): + """Test that listeners are not registered when suggest_removal is False.""" + self.config[self.plugin]["suggest_removal"] = False + self.load_plugins() + + plugin = plugins._instances[0] + assert not hasattr(plugin, "stop_suggestions_for_albums") + assert "item_removed" not in plugin._raw_listeners + assert "import_task_choice" not in plugin._raw_listeners + + def test_listeners_registered_when_enabled(self): + """Test that listeners are registered when suggest_removal is True.""" + self.config[self.plugin]["suggest_removal"] = True + self.load_plugins() + + plugin = plugins._instances[0] + assert hasattr(plugin, "stop_suggestions_for_albums") + assert isinstance(plugin.stop_suggestions_for_albums, set) + assert "item_removed" in plugin._raw_listeners + assert "import_task_choice" in plugin._raw_listeners