Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make whipper not break on missing release type #398

Merged
merged 5 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion whipper/common/mbngs.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ def _getMetadata(release, discid, country=None):

discMD = DiscMetadata()

discMD.releaseType = release['release-group']['type']
if 'type' in release['release-group']:
discMD.releaseType = release['release-group']['type']
else:
discMD.releaseType = u''
Freso marked this conversation as resolved.
Show resolved Hide resolved
discCredit = _Credit(release['artist-credit'])

# FIXME: is there a better way to check for VA ?
Expand Down
16 changes: 15 additions & 1 deletion whipper/test/test_common_mbngs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- Mode: Python; test-case-name: whipper.test.test_common_mbngs -*-
# vi:si:et:sw=4:sts=4:ts=4
# vi:si:et:sw=4:sts=4:ts=4:set fileencoding=utf-8
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The encoding is required to be defined due to the “Ö” in the comment to the new test.


import os
import json
Expand Down Expand Up @@ -207,6 +207,20 @@ def testNenaAndKimWildSingle(self):
self.assertEqual(track2.mbidRecording,
u'5f19758e-7421-4c71-a599-9a9575d8e1b0')

def testMissingReleaseGroupType(self):
"""Check that whipper doesn't break if there's no type."""
# Using: Gustafsson, Österberg & Cowle - What's Up? 8 (disc 4)
# https://musicbrainz.org/release/d8e6153a-2c47-4804-9d73-0aac1081c3b1
filename = 'whipper.release.d8e6153a-2c47-4804-9d73-0aac1081c3b1.json'
path = os.path.join(os.path.dirname(__file__), filename)
handle = open(path, "rb")
response = json.loads(handle.read())
handle.close()
discid = "xu338_M8WukSRi0J.KTlDoflB8Y-" # disc 4

metadata = mbngs._getMetadata(response['release'], discid)
self.assertEqual(metadata.releaseType, u'')

def testAllAvailableMetadata(self):
"""Check that all possible metadata gets assigned."""
# Using: David Rovics - The Other Side
Expand Down

Large diffs are not rendered by default.