Fixed UnboundLocalError / AttributeError #571, #581 (#583)

* Fix plamere/spotipy#571, plamere/spotipy#581

* Add integration test for reaching max retries

* Update tests/integration/test_non_user_endpoints.py

Co-authored-by: Stéphane Bruckert <contact@stephanebruckert.com>

* Update CHANGELOG.md, integration test mock data

Co-authored-by: Stéphane Bruckert <contact@stephanebruckert.com>
This commit is contained in:
CallumandStéphane Bruckert authored and GitHub committed 2020-10-07 09:00:45 +01:00
1 parent 76b640ae1e
commit 4bb42598e1
3 files changed
+27 -5

No files matched your search

@@ -240,6 +240,20 @@ class AuthTestSpotipy(unittest.TestCase):
self.assertRaises((requests.exceptions.Timeout, requests.exceptions.ConnectionError),
lambda: sp.search(q='my*', type='track'))
def test_max_retries_reached(self):
spotify_no_retry = Spotify(
client_credentials_manager=SpotifyClientCredentials(),
retries=0)
i = 0
while i < 100:
try:
spotify_no_retry.search(q='foo')
except spotipy.exceptions.SpotifyException as e:
self.assertIsInstance(e, spotipy.exceptions.SpotifyException)
return
i += 1
self.fail()
def test_album_search(self):
results = self.spotify.search(q='weezer pinkerton', type='album')
self.assertTrue('albums' in results)