From de9020055dcbb1994d0578cd4b6e83a0c2439a5a Mon Sep 17 00:00:00 2001 From: J0J0 Todos Date: Wed, 26 Mar 2025 11:43:10 +0100 Subject: [PATCH] lastgenre: Add test ensuring next stage is hit If no album was found the next stage (artist) should be entered, the original genre kicked out (not whitelisted) and artist genre accepted. The log message is slightly misleading since it tried to keep existing genres but they were not whitelisted, thus kicked out. This is expected. --- test/plugins/test_lastgenre.py | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/test/plugins/test_lastgenre.py b/test/plugins/test_lastgenre.py index 565b909e9..ad2dedf5b 100644 --- a/test/plugins/test_lastgenre.py +++ b/test/plugins/test_lastgenre.py @@ -292,24 +292,24 @@ class LastGenrePluginTest(BeetsTestCase): }, ("Unknown Genre, Jazz", "keep + artist, any"), ), - # 7 - fallback to original when nothing found + # 7 - fallback to any original when nothing found and whitelist disabled ( { "force": True, "keep_existing": True, "source": "track", - "whitelist": True, + "whitelist": False, "fallback": "fallback genre", "canonical": False, "prefer_specific": False, }, - "original unknown", + "Jazz", { "track": None, "album": None, "artist": None, }, - ("original unknown", "original fallback"), + ("fallback genre", "fallback"), ), # 8 - fallback to fallback if no original ( @@ -381,6 +381,26 @@ class LastGenrePluginTest(BeetsTestCase): }, ("not ; configured | separator", "keep any, no-force"), ), + # 12 - fallback to next stage (artist) if no allowed original present + # and no album genre were fetched. + ( + { + "force": True, + "keep_existing": True, + "source": "album", + "whitelist": True, + "fallback": "fallback genre", + "canonical": False, + "prefer_specific": False, + }, + "not whitelisted original", + { + "track": None, + "album": None, + "artist": ["Jazz"], + }, + ("Jazz", "keep + artist, whitelist"), + ), ], ) def test_get_genre(config_values, item_genre, mock_genres, expected_result):