Skip to content

Commit

Permalink
fix: musicbrainz error if release does not have a country specified
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpavlock committed Oct 8, 2022
1 parent fe247c8 commit 1c0f844
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion moe/plugins/musicbrainz/mb_core.py
Expand Up @@ -386,7 +386,7 @@ def _create_album(release: dict) -> Album:

album = Album(
artist=_flatten_artist_credit(release["artist-credit"]),
country=release["country"],
country=release.get("country"),
date=_parse_date(release["date"]),
disc_total=int(release["medium-count"]),
label=release["label-info-list"][0]["label"]["name"],
Expand Down
9 changes: 9 additions & 0 deletions tests/plugins/musicbrainz/test_mb_core.py
Expand Up @@ -414,6 +414,15 @@ def test_multi_disc_release(self, mock_mb_by_id, mb_config):
assert any(track.disc == 1 for track in mb_album.tracks)
assert any(track.disc == 2 for track in mb_album.tracks)

def test_no_country(self, mock_mb_by_id, mb_config):
"""Don't error if no country key in the release."""
mb_album_id = "112dec42-65f2-3bde-8d7d-26deddde10b2"
release = copy.deepcopy(mb_rsrc.full_release.release)
release["release"].pop("country")
mock_mb_by_id.return_value = release

moe_mb.get_album_by_id(mb_album_id)


class TestGetTrackByID:
"""Test `get_track_by_id`."""
Expand Down

0 comments on commit 1c0f844

Please sign in to comment.