mirror of
https://github.com/beetbox/beets.git
synced 2026-02-16 20:35:23 +01:00
autotag: add a test for overwrite_null configuration
This commit is contained in:
parent
1a899cc92a
commit
ab5b7a528c
1 changed files with 40 additions and 1 deletions
|
|
@ -19,7 +19,7 @@ import pytest
|
|||
from beets import autotag, config
|
||||
from beets.autotag import AlbumInfo, TrackInfo, correct_list_fields, match
|
||||
from beets.library import Item
|
||||
from beets.test.helper import BeetsTestCase
|
||||
from beets.test.helper import BeetsTestCase, ConfigMixin
|
||||
|
||||
|
||||
class TestAssignment:
|
||||
|
|
@ -444,6 +444,45 @@ 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",
|
||||
marks=pytest.mark.xfail(
|
||||
reason="artist gets wrongly always overwritten", strict=True
|
||||
),
|
||||
id="do not overwrite artist",
|
||||
),
|
||||
],
|
||||
)
|
||||
class TestOverwriteNull:
|
||||
@pytest.fixture(autouse=True)
|
||||
def config(self, config, overwrite_fields):
|
||||
config["overwrite_null"]["album"] = overwrite_fields
|
||||
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",
|
||||
[
|
||||
|
|
|
|||
Loading…
Reference in a new issue