Fix playlist add items (#559)

* fixed uri issue in playlist_add_items

All uris were being converted to track uris
making it impossible to add episodes to playlists.

* Added tests for episode adds

also fixed creep uri so those tests no longer fail

* Fixed creep_url to match creep_uri

* revert pip version, added FIX to changelog

Co-authored-by: Paul Lamere <paull@spotify.com>
This commit is contained in:
Paul LamereandPaul Lamere authored and GitHub committed 2020-08-25 19:37:53 +01:00
1 parent 3d48d77615
commit 651080e3da
4 files changed
+40 -4

No files matched your search

+3 -3
View File
@@ -36,9 +36,9 @@ class AuthTestSpotipy(unittest.TestCase):
bad_id = 'BAD_ID'
creep_urn = 'spotify:track:3HfB5hBU0dmBt8T0iCmH42'
creep_id = '3HfB5hBU0dmBt8T0iCmH42'
creep_url = 'http://open.spotify.com/track/3HfB5hBU0dmBt8T0iCmH42'
creep_urn = 'spotify:track:6b2oQwSGFkzsMtQruIWm2p'
creep_id = '6b2oQwSGFkzsMtQruIWm2p'
creep_url = 'http://open.spotify.com/track/6b2oQwSGFkzsMtQruIWm2p'
el_scorcho_urn = 'spotify:track:0Svkvt5I79wficMFgaqEQJ'
el_scorcho_bad_urn = 'spotify:track:0Svkvt5I79wficMFgaqEQK'
pinkerton_urn = 'spotify:album:04xe676vyiTeYNXw15o9jT'
+27
View File
@@ -25,6 +25,17 @@ class SpotipyPlaylistApiTest(unittest.TestCase):
"spotify:track:1PB7gRWcvefzu7t3LJLUlf"]
cls.username = os.getenv(CCEV['client_username'])
# be wary here, episodes sometimes go away forever
# which could cause tests that rely on four_episodes
# to fail
cls.four_episodes = [
"spotify:episode:7f9e73vfXKRqR6uCggK2Xy",
"spotify:episode:4wA1RLFNOWCJ8iprngXmM0",
"spotify:episode:32vhLjJjT7m3f9DFCJUCVZ",
"spotify:episode:7cRcsGYYRUFo1OF3RgRzdx",
]
scope = (
'playlist-modify-public '
'user-library-read '
@@ -125,6 +136,22 @@ class SpotipyPlaylistApiTest(unittest.TestCase):
playlist = self.spotify.playlist_items(self.new_playlist['id'])
self.assertEqual(playlist["total"], 0)
def test_playlist_add_episodes(self):
# add episodes to playlist
self.spotify.playlist_add_items(
self.new_playlist['id'], self.four_episodes)
playlist = self.spotify.playlist_items(self.new_playlist['id'])
self.assertEqual(playlist['total'], 4)
self.assertEqual(len(playlist['items']), 4)
pl = self.spotify.playlist_items(self.new_playlist['id'], limit=2)
self.assertEqual(len(pl["items"]), 2)
self.spotify.playlist_remove_all_occurrences_of_items(
self.new_playlist['id'], self.four_episodes)
playlist = self.spotify.playlist_items(self.new_playlist['id'])
self.assertEqual(playlist["total"], 0)
def test_playlist_cover_image(self):
# Upload random dog image
r = requests.get('https://dog.ceo/api/breeds/image/random')