|
| 1 | +from typing import NamedTuple |
| 2 | + |
1 | 3 | import pytest
|
2 | 4 |
|
3 | 5 | from beets.util.id_extractors import extract_release_id
|
|
32 | 34 | ) # fmt: skip
|
33 | 35 | def test_extract_release_id(source, id_string, expected):
|
34 | 36 | 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