[Python-modules-commits] [python-social-auth] 24/89: Add unit tests for Spotify backend
Wolfgang Borgert
debacle at moszumanska.debian.org
Sat Dec 24 15:15:43 UTC 2016
This is an automated email from the git hooks/post-receive script.
debacle pushed a commit to tag v0.2.15
in repository python-social-auth.
commit f504a41cdd642751d0ca638c35b5ebdea2cda8cf
Author: khamaileon <khamaileon at free.fr>
Date: Mon Feb 15 17:49:56 2016 +0100
Add unit tests for Spotify backend
---
social/backends/spotify.py | 3 ++-
social/tests/backends/test_spotify.py | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/social/backends/spotify.py b/social/backends/spotify.py
index e8ab88e..f2c64d7 100644
--- a/social/backends/spotify.py
+++ b/social/backends/spotify.py
@@ -9,12 +9,13 @@ from social.backends.oauth import BaseOAuth2
class SpotifyOAuth2(BaseOAuth2):
+ """Spotify OAuth2 authentication backend"""
name = 'spotify'
- SCOPE_SEPARATOR = ' '
ID_KEY = 'id'
AUTHORIZATION_URL = 'https://accounts.spotify.com/authorize'
ACCESS_TOKEN_URL = 'https://accounts.spotify.com/api/token'
ACCESS_TOKEN_METHOD = 'POST'
+ SCOPE_SEPARATOR = ' '
REDIRECT_STATE = False
EXTRA_DATA = [
('refresh_token', 'refresh_token'),
diff --git a/social/tests/backends/test_spotify.py b/social/tests/backends/test_spotify.py
new file mode 100644
index 0000000..73abbc4
--- /dev/null
+++ b/social/tests/backends/test_spotify.py
@@ -0,0 +1,34 @@
+import json
+
+from social.tests.backends.oauth import OAuth2Test
+
+
+class SpotifyOAuth2Test(OAuth2Test):
+ backend_path = 'social.backends.spotify.SpotifyOAuth2'
+ user_data_url = 'https://api.spotify.com/v1/me'
+ expected_username = 'foobar'
+ access_token_body = json.dumps({
+ 'access_token': 'foobar',
+ 'token_type': 'bearer'
+ })
+ user_data_body = json.dumps({
+ 'display_name': None,
+ 'external_urls': {
+ 'spotify': 'https://open.spotify.com/user/foobar'
+ },
+ 'followers': {
+ 'href': None,
+ 'total': 0
+ },
+ 'href': 'https://api.spotify.com/v1/users/foobar',
+ 'id': 'foobar',
+ 'images': [],
+ 'type': 'user',
+ 'uri': 'spotify:user:foobar'
+ })
+
+ def test_login(self):
+ self.do_login()
+
+ def test_partial_pipeline(self):
+ self.do_partial_pipeline()
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-social-auth.git
More information about the Python-modules-commits
mailing list