Refactor SpotifyOauthError class

- add error and error description to SpotifyOauthError to reflect the data returned by web api when error happens
- unit test to SpotifyClientCredentials.get_access_token is added for invalid client
This commit is contained in:
Yasser Sinjab committed 2020-05-27 23:26:47 +03:00
1 parent 5c981a1d62
commit 901b2031a2
2 files changed
+23 -3

No files matched your search

+7
View File
@@ -6,6 +6,7 @@ import unittest
import six.moves.urllib.parse as urllibparse
from spotipy import SpotifyOAuth
from spotipy.oauth2 import SpotifyClientCredentials, SpotifyOauthError
try:
import unittest.mock as mock
@@ -166,3 +167,9 @@ class TestSpotifyOAuth(unittest.TestCase):
parsed_url = urllibparse.urlparse(url)
parsed_qs = urllibparse.parse_qs(parsed_url.query)
self.assertTrue(parsed_qs['show_dialog'])
def test_spotify_client_credentials_get_access_token(self):
oauth = SpotifyClientCredentials(client_id='ID', client_secret='SECRET')
with self.assertRaises(SpotifyOauthError) as error:
oauth.get_access_token()
self.assertEqual(error.exception.error, 'invalid_client')