Skip to content

Commit

Permalink
Merge pull request #47 from metabrainz/general-cleanup
Browse files Browse the repository at this point in the history
General cleanup
  • Loading branch information
mayhem committed Apr 11, 2022
2 parents 77d1048 + dc1b7f9 commit 4879eb1
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 353 deletions.
Empty file removed troi/acousticbrainz/__init__.py
Empty file.
72 changes: 0 additions & 72 deletions troi/acousticbrainz/annoy.py

This file was deleted.

70 changes: 0 additions & 70 deletions troi/acousticbrainz/bpm_lookup.py

This file was deleted.

70 changes: 0 additions & 70 deletions troi/acousticbrainz/mood_lookup.py

This file was deleted.

74 changes: 0 additions & 74 deletions troi/acousticbrainz/tests/test_annoy.py

This file was deleted.

3 changes: 3 additions & 0 deletions troi/internal/README.md
@@ -0,0 +1,3 @@
This directory contains patches that we use to create the Year in Music reviews at the end of the year.
Given the limited use, they've been moved away from the other patches in order to not confuse the normal
flow of the other patches
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions troi/musicbrainz/mbid_mapping.py
Expand Up @@ -48,6 +48,7 @@ def read(self, inputs):
r.add_note("recording mbid %s overwritten by mbid_lookup" % (r.mbid))
r.mbid = row['recording_mbid']
r.name = row['recording_name']
r.year = row['year']

if r.artist.artist_credit_id:
r.artist.add_note("artist_credit_id %d overwritten by mbid_lookup" % (r.artist.artist_credit_id))
Expand Down
27 changes: 21 additions & 6 deletions troi/musicbrainz/tests/test_mbid_mapping.py
Expand Up @@ -15,19 +15,33 @@
"recording_mbid": "97e69767-5d34-4c97-b36a-f3b2b1ef9dae",
"recording_name": "Trigger Hippie",
"release_mbid": "9db51cd6-38f6-3b42-8ad5-559963d68f35",
"release_name": "Who Can You Trust?"
"release_name": "Who Can You Trust?",
"year": 1996
}
]


def mocked_requests_post(*args, **kwargs):
class MockResponse:
def __init__(self, json_data, status_code):
self.json_data = json_data
self.status_code = status_code

def json(self):
return self.json_data

e = troi.musicbrainz.mbid_mapping.MBIDMappingLookupElement()
if args[0] == e.SERVER_URL:
return MockResponse(return_data, 200)

return MockResponse(None, 404)


class TestMBIDMapping(unittest.TestCase):

@unittest.mock.patch('requests.post')
@unittest.mock.patch('requests.post', side_effect=mocked_requests_post)
def test_read(self, req):

mock = unittest.mock.MagicMock()
mock.status_code = 200
mock.text = json.dumps(return_data)
req.return_value = mock
e = troi.musicbrainz.mbid_mapping.MBIDMappingLookupElement()

r = [ troi.Recording("trigger hippie", artist=troi.Artist("morcheeba")) ]
Expand All @@ -41,6 +55,7 @@ def test_read(self, req):
assert entities[0].release.name == "Who Can You Trust?"
assert entities[0].mbid == "97e69767-5d34-4c97-b36a-f3b2b1ef9dae"
assert entities[0].name == "Trigger Hippie"
assert entities[0].year == 1996


@unittest.mock.patch('requests.post')
Expand Down

0 comments on commit 4879eb1

Please sign in to comment.