Skip to content

Commit 5202219

Browse files
committed
Test URL extraction against other sources
1 parent a8e33a2 commit 5202219

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/util/test_id_extractors.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import NamedTuple
2+
13
import pytest
24

35
from beets.util.id_extractors import extract_release_id
@@ -32,3 +34,28 @@
3234
) # fmt: skip
3335
def test_extract_release_id(source, id_string, expected):
3436
assert extract_release_id(source, id_string) == expected
37+
38+
39+
class SourceWithURL(NamedTuple):
40+
source: str
41+
url: str
42+
43+
44+
source_with_urls = [
45+
SourceWithURL("spotify", "https://open.spotify.com/album/39WqpoPgZxygo6YQjehLJJ"),
46+
SourceWithURL("deezer", "https://www.deezer.com/album/176356382"),
47+
SourceWithURL("beatport", "https://www.beatport.com/release/album-name/3089651"),
48+
SourceWithURL("discogs", "http://www.discogs.com/G%C3%BCnther-Lause-Meru-Ep/release/4354798"),
49+
SourceWithURL("musicbrainz", "https://musicbrainz.org/entity/28e32c71-1450-463e-92bf-e0a46446fc11"),
50+
] # fmt: skip
51+
52+
53+
@pytest.mark.parametrize("source", [s.source for s in source_with_urls])
54+
@pytest.mark.parametrize("source_with_url", source_with_urls)
55+
def test_match_source_url(source, source_with_url):
56+
if source == source_with_url.source:
57+
assert extract_release_id(source, source_with_url.url)
58+
else:
59+
assert not extract_release_id(source, source_with_url.url), (
60+
f"Source {source} pattern should not match {source_with_url.source} URL"
61+
)

0 commit comments

Comments
 (0)