mirror of
https://github.com/beetbox/beets.git
synced 2026-01-27 10:33:33 +01:00
missing: add tests for --album flag
This commit is contained in:
parent
a33371b6ef
commit
d346daf48e
2 changed files with 61 additions and 1 deletions
|
|
@ -21,7 +21,7 @@ from collections.abc import Iterator
|
|||
import musicbrainzngs
|
||||
from musicbrainzngs.musicbrainz import MusicBrainzError
|
||||
|
||||
from beets import config, metadata_plugins
|
||||
from beets import __version__, config, metadata_plugins
|
||||
from beets.dbcore import types
|
||||
from beets.library import Album, Item, Library
|
||||
from beets.plugins import BeetsPlugin
|
||||
|
|
@ -29,6 +29,8 @@ from beets.ui import Subcommand, print_
|
|||
|
||||
MB_ARTIST_QUERY = r"mb_albumartistid::^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$"
|
||||
|
||||
musicbrainzngs.set_useragent("beets", __version__, "https://beets.io/")
|
||||
|
||||
|
||||
def _missing_count(album):
|
||||
"""Return number of missing items in `album`."""
|
||||
|
|
|
|||
58
test/plugins/test_missing.py
Normal file
58
test/plugins/test_missing.py
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import uuid
|
||||
|
||||
import pytest
|
||||
|
||||
from beets.library import Album
|
||||
from beets.test.helper import PluginMixin, TestHelper
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def helper():
|
||||
helper = TestHelper()
|
||||
helper.setup_beets()
|
||||
|
||||
yield helper
|
||||
|
||||
helper.teardown_beets()
|
||||
|
||||
|
||||
class TestMissingAlbums(PluginMixin):
|
||||
plugin = "missing"
|
||||
album_in_lib = Album(
|
||||
album="Album",
|
||||
albumartist="Artist",
|
||||
mb_albumartistid=str(uuid.uuid4()),
|
||||
mb_albumid="album",
|
||||
)
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"release_from_mb,expected_output",
|
||||
[
|
||||
pytest.param(
|
||||
{"id": "other", "title": "Other Album"},
|
||||
"Artist - Other Album\n",
|
||||
id="missing",
|
||||
),
|
||||
pytest.param(
|
||||
{"id": album_in_lib.mb_albumid, "title": album_in_lib.album},
|
||||
"",
|
||||
marks=pytest.mark.xfail(
|
||||
reason="album in lib should not be reported as missing. Needs fixing."
|
||||
),
|
||||
id="not missing",
|
||||
),
|
||||
],
|
||||
)
|
||||
def test_missing_artist_albums(
|
||||
self, monkeypatch, helper, release_from_mb, expected_output
|
||||
):
|
||||
helper.lib.add(self.album_in_lib)
|
||||
monkeypatch.setattr(
|
||||
"musicbrainzngs.browse_release_groups",
|
||||
lambda **__: {"release-group-list": [release_from_mb]},
|
||||
)
|
||||
|
||||
with self.configure_plugin({}):
|
||||
assert (
|
||||
helper.run_with_output("missing", "--album") == expected_output
|
||||
)
|
||||
Loading…
Reference in a new issue