@@ -142,3 +142,35 @@ def imported_items(self):
142142 plugin = plugins ._instances [0 ]
143143 mock_task = MockTask ()
144144 plugin .prevent_suggest_removal (None , mock_task )
145+
146+
147+ class ImportSourceTestListenerRegistration (PluginMixin , AutotagImportTestCase ):
148+ """Test listener registration based on config."""
149+
150+ plugin = "importsource"
151+ preload_plugin = False
152+
153+ def setUp (self ):
154+ preserve_plugin_listeners ()
155+ super ().setUp ()
156+
157+ def test_listeners_not_registered_when_disabled (self ):
158+ """Test that listeners are not registered when suggest_removal is False."""
159+ self .config [self .plugin ]["suggest_removal" ] = False
160+ self .load_plugins ()
161+
162+ plugin = plugins ._instances [0 ]
163+ assert not hasattr (plugin , "stop_suggestions_for_albums" )
164+ assert "item_removed" not in plugin ._raw_listeners
165+ assert "import_task_choice" not in plugin ._raw_listeners
166+
167+ def test_listeners_registered_when_enabled (self ):
168+ """Test that listeners are registered when suggest_removal is True."""
169+ self .config [self .plugin ]["suggest_removal" ] = True
170+ self .load_plugins ()
171+
172+ plugin = plugins ._instances [0 ]
173+ assert hasattr (plugin , "stop_suggestions_for_albums" )
174+ assert isinstance (plugin .stop_suggestions_for_albums , set )
175+ assert "item_removed" in plugin ._raw_listeners
176+ assert "import_task_choice" in plugin ._raw_listeners
0 commit comments