Added playlist tracks method. Updated tests.

This commit is contained in:
Paul Lamere
2014-11-15 07:20:11 -05:00
parent 278b7d3005
commit 8adbfe6f6d
4 changed files with 48 additions and 7 deletions

View File

@@ -19,7 +19,6 @@ class AuthTestSpotipy(unittest.TestCase):
These tests require user authentication
'''
playlist = "spotify:user:plamere:playlist:2oCEWyyAPbZp9xhVSxZavx"
four_tracks = ["spotify:track:6RtPijgfPKROxEzTHNRiDp",
"spotify:track:7IHOIqZUUInxjVkko181PB",
@@ -55,8 +54,6 @@ class AuthTestSpotipy(unittest.TestCase):
user = spotify.me()
self.assertTrue(user['id'] == username)
@unittest.expectedFailure
def test_user_playlists(self):
playlists = spotify.user_playlists(username, limit=5)
self.assertTrue('items' in playlists)
@@ -67,6 +64,24 @@ class AuthTestSpotipy(unittest.TestCase):
self.assertTrue(len(playlists['items']) == 5)
def test_user_playlist_tracks(self):
playlists = spotify.user_playlists(username, limit=5)
self.assertTrue('items' in playlists)
for playlist in playlists['items']:
user = playlist['owner']['id']
pid = playlist['id']
results = spotify.user_playlist_tracks(user, pid)
self.assertTrue(len(results['items']) > 0)
def user_playlist_tracks(self, user, playlist_id = None, fields=None,
limit=100, offset=0):
# known API issue currently causes this test to fail
# the issue is that the API doesn't currently respect the
# limit paramter
self.assertTrue(len(playlists['items']) == 5)
def test_current_user_saved_tracks(self):
tracks = spotify.current_user_saved_tracks()
self.assertTrue(len(tracks['items']) > 0)