2017-12-24 18:15:21 +00:00
|
|
|
import json
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
|
|
from funkwhale_api.musicbrainz import api
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
def test_can_search_recording_in_musicbrainz_api(
|
|
|
|
recordings, db, mocker, logged_in_api_client):
|
2017-12-24 18:15:21 +00:00
|
|
|
mocker.patch(
|
|
|
|
'funkwhale_api.musicbrainz.api.recordings.search',
|
2018-03-25 20:27:38 +00:00
|
|
|
return_value=recordings['search']['brontide matador'])
|
2017-12-24 18:15:21 +00:00
|
|
|
query = 'brontide matador'
|
|
|
|
url = reverse('api:v1:providers:musicbrainz:search-recordings')
|
2018-03-25 20:27:38 +00:00
|
|
|
expected = recordings['search']['brontide matador']
|
|
|
|
response = logged_in_api_client.get(url, data={'query': query})
|
2017-12-24 18:15:21 +00:00
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
assert expected == response.data
|
2017-12-24 18:15:21 +00:00
|
|
|
|
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
def test_can_search_release_in_musicbrainz_api(releases, db, mocker, logged_in_api_client):
|
2017-12-24 18:15:21 +00:00
|
|
|
mocker.patch(
|
|
|
|
'funkwhale_api.musicbrainz.api.releases.search',
|
2018-03-25 20:27:38 +00:00
|
|
|
return_value=releases['search']['brontide matador'])
|
2017-12-24 18:15:21 +00:00
|
|
|
query = 'brontide matador'
|
|
|
|
url = reverse('api:v1:providers:musicbrainz:search-releases')
|
2018-03-25 20:27:38 +00:00
|
|
|
expected = releases['search']['brontide matador']
|
|
|
|
response = logged_in_api_client.get(url, data={'query': query})
|
2017-12-24 18:15:21 +00:00
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
assert expected == response.data
|
2017-12-24 18:15:21 +00:00
|
|
|
|
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
def test_can_search_artists_in_musicbrainz_api(artists, db, mocker, logged_in_api_client):
|
2017-12-24 18:15:21 +00:00
|
|
|
mocker.patch(
|
|
|
|
'funkwhale_api.musicbrainz.api.artists.search',
|
2018-03-25 20:27:38 +00:00
|
|
|
return_value=artists['search']['lost fingers'])
|
2017-12-24 18:15:21 +00:00
|
|
|
query = 'lost fingers'
|
|
|
|
url = reverse('api:v1:providers:musicbrainz:search-artists')
|
2018-03-25 20:27:38 +00:00
|
|
|
expected = artists['search']['lost fingers']
|
|
|
|
response = logged_in_api_client.get(url, data={'query': query})
|
2017-12-24 18:15:21 +00:00
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
assert expected == response.data
|
2017-12-24 18:15:21 +00:00
|
|
|
|
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
def test_can_get_artist_in_musicbrainz_api(artists, db, mocker, logged_in_api_client):
|
2017-12-24 18:15:21 +00:00
|
|
|
mocker.patch(
|
|
|
|
'funkwhale_api.musicbrainz.api.artists.get',
|
2018-03-25 20:27:38 +00:00
|
|
|
return_value=artists['get']['lost fingers'])
|
2017-12-24 18:15:21 +00:00
|
|
|
uuid = 'ac16bbc0-aded-4477-a3c3-1d81693d58c9'
|
|
|
|
url = reverse('api:v1:providers:musicbrainz:artist-detail', kwargs={
|
|
|
|
'uuid': uuid,
|
|
|
|
})
|
2018-03-25 20:27:38 +00:00
|
|
|
response = logged_in_api_client.get(url)
|
|
|
|
expected = artists['get']['lost fingers']
|
2017-12-24 18:15:21 +00:00
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
assert expected == response.data
|
2017-12-24 18:15:21 +00:00
|
|
|
|
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
def test_can_broswe_release_group_using_musicbrainz_api(
|
|
|
|
release_groups, db, mocker, logged_in_api_client):
|
2017-12-24 18:15:21 +00:00
|
|
|
mocker.patch(
|
|
|
|
'funkwhale_api.musicbrainz.api.release_groups.browse',
|
2018-03-25 20:27:38 +00:00
|
|
|
return_value=release_groups['browse']['lost fingers'])
|
2017-12-24 18:15:21 +00:00
|
|
|
uuid = 'ac16bbc0-aded-4477-a3c3-1d81693d58c9'
|
|
|
|
url = reverse(
|
|
|
|
'api:v1:providers:musicbrainz:release-group-browse',
|
|
|
|
kwargs={
|
|
|
|
'artist_uuid': uuid,
|
|
|
|
}
|
|
|
|
)
|
2018-03-25 20:27:38 +00:00
|
|
|
response = logged_in_api_client.get(url)
|
|
|
|
expected = release_groups['browse']['lost fingers']
|
2017-12-24 18:15:21 +00:00
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
assert expected == response.data
|
2017-12-24 18:15:21 +00:00
|
|
|
|
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
def test_can_broswe_releases_using_musicbrainz_api(
|
|
|
|
releases, db, mocker, logged_in_api_client):
|
2017-12-24 18:15:21 +00:00
|
|
|
mocker.patch(
|
|
|
|
'funkwhale_api.musicbrainz.api.releases.browse',
|
2018-03-25 20:27:38 +00:00
|
|
|
return_value=releases['browse']['Lost in the 80s'])
|
2017-12-24 18:15:21 +00:00
|
|
|
uuid = 'f04ed607-11b7-3843-957e-503ecdd485d1'
|
|
|
|
url = reverse(
|
|
|
|
'api:v1:providers:musicbrainz:release-browse',
|
|
|
|
kwargs={
|
|
|
|
'release_group_uuid': uuid,
|
|
|
|
}
|
|
|
|
)
|
2018-03-25 20:27:38 +00:00
|
|
|
response = logged_in_api_client.get(url)
|
|
|
|
expected = releases['browse']['Lost in the 80s']
|
2017-12-24 18:15:21 +00:00
|
|
|
|
2018-03-25 20:27:38 +00:00
|
|
|
assert expected == response.data
|