move spotify test json to json files

This commit is contained in:
Johnny Robeson 2016-06-14 21:48:41 -04:00
parent ba2cfcd329
commit a1314b7bda
3 changed files with 114 additions and 111 deletions

View file

@ -0,0 +1,11 @@
{
"tracks" : {
"href" : "https://api.spotify.com/v1/search?query=duifhjslkef+album%3Alkajsdflakjsd+artist%3A&offset=0&limit=20&type=track",
"items" : [ ],
"limit" : 20,
"next" : null,
"offset" : 0,
"previous" : null,
"total" : 0
}
}

View file

@ -0,0 +1,89 @@
{
"tracks":{
"href":"https://api.spotify.com/v1/search?query=Happy+album%3ADespicable+Me+2+artist%3APharrell+Williams&offset=0&limit=20&type=track",
"items":[
{
"album":{
"album_type":"compilation",
"available_markets":[
"AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA",
"CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO",
"EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK",
"HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV",
"MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA",
"PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI",
"SK", "SV", "TR", "TW", "US", "UY"
],
"external_urls":{
"spotify":"https://open.spotify.com/album/5l3zEmMrOhOzG8d8s83GOL"
},
"href":"https://api.spotify.com/v1/albums/5l3zEmMrOhOzG8d8s83GOL",
"id":"5l3zEmMrOhOzG8d8s83GOL",
"images":[
{
"height":640,
"width":640,
"url":"https://i.scdn.co/image/cb7905340c132365bbaee3f17498f062858382e8"
},
{
"height":300,
"width":300,
"url":"https://i.scdn.co/image/af369120f0b20099d6784ab31c88256113f10ffb"
},
{
"height":64,
"width":64,
"url":"https://i.scdn.co/image/9dad385ddf2e7db0bef20cec1fcbdb08689d9ae8"
}
],
"name":"Despicable Me 2 (Original Motion Picture Soundtrack)",
"type":"album",
"uri":"spotify:album:5l3zEmMrOhOzG8d8s83GOL"
},
"artists":[
{
"external_urls":{
"spotify":"https://open.spotify.com/artist/2RdwBSPQiwcmiDo9kixcl8"
},
"href":"https://api.spotify.com/v1/artists/2RdwBSPQiwcmiDo9kixcl8",
"id":"2RdwBSPQiwcmiDo9kixcl8",
"name":"Pharrell Williams",
"type":"artist",
"uri":"spotify:artist:2RdwBSPQiwcmiDo9kixcl8"
}
],
"available_markets":[
"AD", "AR", "AT", "AU", "BE", "BG", "BO", "BR", "CA",
"CH", "CL", "CO", "CR", "CY", "CZ", "DE", "DK", "DO",
"EC", "EE", "ES", "FI", "FR", "GB", "GR", "GT", "HK",
"HN", "HU", "IE", "IS", "IT", "LI", "LT", "LU", "LV",
"MC", "MT", "MX", "MY", "NI", "NL", "NO", "NZ", "PA",
"PE", "PH", "PL", "PT", "PY", "RO", "SE", "SG", "SI",
"SK", "SV", "TR", "TW", "US", "UY"
],
"disc_number":1,
"duration_ms":233305,
"explicit":false,
"external_ids":{
"isrc":"USQ4E1300686"
},
"external_urls":{
"spotify":"https://open.spotify.com/track/6NPVjNh8Jhru9xOmyQigds"
},
"href":"https://api.spotify.com/v1/tracks/6NPVjNh8Jhru9xOmyQigds",
"id":"6NPVjNh8Jhru9xOmyQigds",
"name":"Happy",
"popularity":89,
"preview_url":"https://p.scdn.co/mp3-preview/6b00000be293e6b25f61c33e206a0c522b5cbc87",
"track_number":4,
"type":"track",
"uri":"spotify:track:6NPVjNh8Jhru9xOmyQigds"
}
],
"limit":20,
"next":null,
"offset":0,
"previous":null,
"total":1
}
}

View file

@ -4,8 +4,10 @@
from __future__ import division, absolute_import, print_function
from test import _common
import os
import responses
from test import _common
from test._common import unittest
from beets import config
from beets.library import Item
@ -49,20 +51,11 @@ class SpotifyPluginTest(_common.TestCase, TestHelper):
@responses.activate
def test_missing_request(self):
response_body = bytes(
'{'
'"tracks" : {'
'"href" : "https://api.spotify.com/v1/search?query=duifhjslkef'
'+album%3Alkajsdflakjsd+artist%3A&offset=0&limit=20&type=track",'
'"items" : [ ],'
'"limit" : 20,'
'"next" : null,'
'"offset" : 0,'
'"previous" : null,'
'"total" : 0'
'}'
'}'
)
json_file = os.path.join(_common.RSRC, b'spotify',
b'missing_request.json')
with open(json_file, 'rb') as f:
response_body = f.read()
responses.add(responses.GET, 'https://api.spotify.com/v1/search',
body=response_body, status=200,
content_type='application/json')
@ -85,102 +78,12 @@ class SpotifyPluginTest(_common.TestCase, TestHelper):
@responses.activate
def test_track_request(self):
response_body = bytes(
'{'
'"tracks" : {'
'"href" : "https://api.spotify.com/v1/search?query=Happy+album%3A'
'Despicable+Me+2+artist%3APharrell+Williams&offset=0&limit=20'
'&type=track",'
'"items" : [ {'
'"album" : {'
'"album_type" : "compilation",'
'"available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG",'
'"BO", "BR", "CA", "CH", "CL", "CO",'
'"CR", "CY", "CZ", "DE", "DK", "DO",'
'"EC", "EE", "ES", "FI", "FR", "GB",'
'"GR", "GT", "HK", "HN", "HU", "IE",'
'"IS", "IT", "LI", "LT", "LU", "LV",'
'"MC", "MT", "MX", "MY", "NI", "NL",'
'"NO", "NZ", "PA", "PE", "PH", "PL",'
'"PT", "PY", "RO", "SE", "SG", "SI",'
'"SK", "SV", "TR", "TW", "US", "UY" ],'
'"external_urls" : {'
'"spotify" : "https://open.spotify.com/album/'
'5l3zEmMrOhOzG8d8s83GOL"'
'},'
'"href" : "https://api.spotify.com/v1/albums/'
'5l3zEmMrOhOzG8d8s83GOL",'
'"id" : "5l3zEmMrOhOzG8d8s83GOL",'
'"images" : [ {'
'"height" : 640,'
'"url" : "https://i.scdn.co/image/cb7905340c132365bb'
'aee3f17498f062858382e8",'
'"width" : 640'
'}, {'
'"height" : 300,'
'"url" : "https://i.scdn.co/image/af369120f0b20099'
'd6784ab31c88256113f10ffb",'
'"width" : 300'
'}, {'
'"height" : 64,'
'"url" : "https://i.scdn.co/image/'
'9dad385ddf2e7db0bef20cec1fcbdb08689d9ae8",'
'"width" : 64'
'} ],'
'"name" : "Despicable Me 2 (Original Motion Picture Soundtrack)",'
'"type" : "album",'
'"uri" : "spotify:album:5l3zEmMrOhOzG8d8s83GOL"'
'},'
'"artists" : [ {'
'"external_urls" : {'
'"spotify" : "https://open.spotify.com/artist/'
'2RdwBSPQiwcmiDo9kixcl8"'
'},'
'"href" : "https://api.spotify.com/v1/artists/'
'2RdwBSPQiwcmiDo9kixcl8",'
'"id" : "2RdwBSPQiwcmiDo9kixcl8",'
'"name" : "Pharrell Williams",'
'"type" : "artist",'
'"uri" : "spotify:artist:2RdwBSPQiwcmiDo9kixcl8"'
'} ],'
'"available_markets" : [ "AD", "AR", "AT", "AU", "BE", "BG", "BO",'
'"BR", "CA", "CH", "CL", "CO", "CR", "CY",'
'"CZ", "DE", "DK", "DO", "EC", "EE", "ES",'
'"FI", "FR", "GB", "GR", "GT", "HK", "HN",'
'"HU", "IE", "IS", "IT", "LI", "LT", "LU",'
'"LV", "MC", "MT", "MX", "MY", "NI", "NL",'
'"NO", "NZ", "PA", "PE", "PH", "PL", "PT",'
'"PY", "RO", "SE", "SG", "SI", "SK", "SV",'
'"TR", "TW", "US", "UY" ],'
'"disc_number" : 1,'
'"duration_ms" : 233305,'
'"explicit" : false,'
'"external_ids" : {'
'"isrc" : "USQ4E1300686"'
'},'
'"external_urls" : {'
'"spotify" : "https://open.spotify.com/track/'
'6NPVjNh8Jhru9xOmyQigds"'
'},'
'"href" : "https://api.spotify.com/v1/tracks/'
'6NPVjNh8Jhru9xOmyQigds",'
'"id" : "6NPVjNh8Jhru9xOmyQigds",'
'"name" : "Happy",'
'"popularity" : 89,'
'"preview_url" : "https://p.scdn.co/mp3-preview/'
'6b00000be293e6b25f61c33e206a0c522b5cbc87",'
'"track_number" : 4,'
'"type" : "track",'
'"uri" : "spotify:track:6NPVjNh8Jhru9xOmyQigds"'
'} ],'
'"limit" : 20,'
'"next" : null,'
'"offset" : 0,'
'"previous" : null,'
'"total" : 1'
'}'
'}'
)
json_file = os.path.join(_common.RSRC, b'spotify',
b'track_request.json')
with open(json_file, 'rb') as f:
response_body = f.read()
responses.add(responses.GET, 'https://api.spotify.com/v1/search',
body=response_body, status=200,
content_type='application/json')