From 26da02284b07c0234b6c3e053dc489e69f3abe05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0ar=C5=ABnas=20Nejus?= Date: Sat, 15 Nov 2025 14:30:00 +0000 Subject: [PATCH] autotag: add a test for overwrite_null configuration --- test/test_autotag.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/test_autotag.py b/test/test_autotag.py index 48ae09ccb..edfbfca03 100644 --- a/test/test_autotag.py +++ b/test/test_autotag.py @@ -444,6 +444,38 @@ class ApplyCompilationTest(BeetsTestCase, ApplyTestUtil): assert self.items[1].comp +@pytest.mark.parametrize( + "overwrite_fields,expected_item_artist", + [ + pytest.param(["artist"], "", id="overwrite artist"), + pytest.param([], "artist", id="do not overwrite artist"), + ], +) +class TestOverwriteNull(ConfigMixin): + @pytest.fixture(autouse=True) + def _setup_config(self, overwrite_fields): + self.config["overwrite_null"]["album"] = overwrite_fields + self.config["overwrite_null"]["track"] = overwrite_fields + + @pytest.fixture + def item(self): + return Item(artist="artist") + + @pytest.fixture + def track_info(self): + return TrackInfo(artist=None) + + def test_album(self, item, track_info, expected_item_artist): + autotag.apply_metadata(AlbumInfo([track_info]), [(item, track_info)]) + + assert item.artist == expected_item_artist + + def test_singleton(self, item, track_info, expected_item_artist): + autotag.apply_item_metadata(item, track_info) + + assert item.artist == expected_item_artist + + @pytest.mark.parametrize( "single_field,list_field", [