@@ -889,55 +889,36 @@ def test_ignorelist_config_format_errors(
889889
890890
891891def test_ignorelist_multivalued_album_artist_fallback (config ):
892- """Verify ignorelist filtering for multi-valued album artist fallbacks.
893-
894- Genres already filtered for individual artists should not be dropped
895- due to a secondary (incorrect) check against the combined group artist.
896- """
897- # Setup config: ignore 'Metal' for 'Artist A' and 'Artist Group'.
892+ """`stage_artist=None` fallback must not re-drop per-artist results."""
898893 config ["lastgenre" ]["ignorelist" ] = {
899894 "Artist A" : ["Metal" ],
900895 "Artist Group" : ["Metal" ],
901896 }
902- # No whitelist and larger count to keep it simple.
903897 config ["lastgenre" ]["whitelist" ] = False
904898 config ["lastgenre" ]["count" ] = 10
905899
906900 plugin = lastgenre .LastGenrePlugin ()
907901 plugin .setup ()
908902
909- # Mock album object.
910903 obj = MagicMock (spec = Album )
911904 obj .albumartist = "Artist Group"
912905 obj .album = "Album Title"
913906 obj .albumartists = ["Artist A" , "Artist B" ]
914- obj .get .return_value = [] # no existing genres
907+ obj .get .return_value = []
915908
916- # Mock client and its artist lookups.
917- # We must ensure it doesn't resolve at track or album stage.
918909 plugin .client = MagicMock ()
919910 plugin .client .fetch_track_genre .return_value = []
920911 plugin .client .fetch_album_genre .return_value = []
921912
922- # Artist lookup side effect:
923- # Artist A: Returns 'Metal' and 'Rock'.
924- # (Note: Client should have filtered 'Metal' already, so we simulate that by
925- # returning only 'Rock').
926- # Artist B: Returns 'Metal' and 'Jazz'.
927- # Artist Group: Returns nothing (triggers fallback).
928- def mock_fetch_artist (artist ):
929- if artist == "Artist A" :
930- return ["Rock" ]
931- if artist == "Artist B" :
932- return ["Metal" , "Jazz" ]
933- return []
934-
935- plugin .client .fetch_artist_genre .side_effect = mock_fetch_artist
936-
937- # Note: manually triggering the logic in _get_genre.
913+ artist_genres = {
914+ "Artist A" : ["Rock" ],
915+ "Artist B" : ["Metal" , "Jazz" ],
916+ }
917+ plugin .client .fetch_artist_genre .side_effect = lambda artist : (
918+ artist_genres .get (artist , [])
919+ )
920+
938921 genres , label = plugin ._get_genre (obj )
939922
940923 assert "multi-valued album artist" in label
941- assert "Rock" in genres
942- assert "Metal" in genres # MUST survive because Artist B allowed it
943- assert "Jazz" in genres
924+ assert "Metal" in genres
0 commit comments