mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
Update tests - make client credentials env. vars list a commonly accessible dictionary in spotipy/util.py
This commit is contained in:
parent
e5ccb9f355
commit
2ce270554a
@ -5,6 +5,7 @@
|
||||
from __future__ import print_function
|
||||
|
||||
__all__ = [
|
||||
'CLIENT_CREDS_ENV_VARS',
|
||||
'prompt_for_user_token'
|
||||
]
|
||||
|
||||
@ -14,6 +15,13 @@ from . import oauth2
|
||||
|
||||
import spotipy
|
||||
|
||||
CLIENT_CREDS_ENV_VARS = {
|
||||
'client_id': 'SPOTIPY_CLIENT_ID',
|
||||
'client_secret': 'SPOTIPY_CLIENT_SECRET',
|
||||
'client_username': 'SPOTIPY_CLIENT_USERNAME',
|
||||
'redirect_uri': 'SPOTIPY_REDIRECT_URI'
|
||||
}
|
||||
|
||||
def prompt_for_user_token(username, scope=None, client_id = None,
|
||||
client_secret = None, redirect_uri = None, cache_path = None):
|
||||
''' prompts the user to login if necessary and returns
|
||||
|
||||
@ -24,6 +24,7 @@ import simplejson as json
|
||||
sys.path.insert(0, os.path.abspath(os.pardir))
|
||||
|
||||
from spotipy import (
|
||||
CLIENT_CREDS_ENV_VARS as CCEV,
|
||||
prompt_for_user_token,
|
||||
Spotify,
|
||||
SpotifyException,
|
||||
@ -60,13 +61,13 @@ class AuthTestSpotipy(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
client_cred_env_vars = ['SPOTIPY_CLIENT_USERNAME', 'SPOTIPY_CLIENT_ID', 'SPOTIPY_CLIENT_SECRET', 'SPOTIPY_REDIRECT_URI']
|
||||
missing = filter(lambda var: not os.getenv(var), client_cred_env_vars)
|
||||
|
||||
missing = filter(lambda var: not os.getenv(CCEV[var]), CCEV)
|
||||
|
||||
if missing:
|
||||
raise Exception('Please set the client credetials for the test application using the following environment variables: {}'.format(client_cred_env_vars))
|
||||
raise Exception('Please set the client credentials for the test application using the following environment variables: {}'.format(CCEV.values()))
|
||||
|
||||
self.username = os.getenv('SPOTIPY_CLIENT_USERNAME')
|
||||
self.username = os.getenv(CCEV['client_username'])
|
||||
|
||||
self.scope = (
|
||||
'playlist-modify-public '
|
||||
|
||||
@ -10,6 +10,7 @@ import requests
|
||||
sys.path.insert(0, os.path.abspath(os.pardir))
|
||||
|
||||
from spotipy import (
|
||||
CLIENT_CREDS_ENV_VARS as CCEV,
|
||||
prompt_for_user_token,
|
||||
Spotify,
|
||||
SpotifyException,
|
||||
@ -46,13 +47,12 @@ class TestSpotipy(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(self):
|
||||
client_cred_env_vars = ['SPOTIPY_CLIENT_USERNAME', 'SPOTIPY_CLIENT_ID', 'SPOTIPY_CLIENT_SECRET', 'SPOTIPY_REDIRECT_URI']
|
||||
missing = filter(lambda var: not os.getenv(var), client_cred_env_vars)
|
||||
missing = filter(lambda var: not os.getenv(CCEV[var]), CCEV)
|
||||
|
||||
if missing:
|
||||
raise Exception('Please set the client credetials for the test application using the following environment variables: {}'.format(client_cred_env_vars))
|
||||
raise Exception('Please set the client credentials for the test application using the following environment variables: {}'.format(CCEV.values()))
|
||||
|
||||
self.username = os.getenv('SPOTIPY_CLIENT_USERNAME')
|
||||
self.username = os.getenv(CCEV['client_username'])
|
||||
|
||||
self.scope = 'user-library-read'
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user