| 1 |
from http import HTTPStatus |
| 2 |
|
| 3 |
from django.test import TestCase |
| 4 |
|
| 5 |
from allauth.socialaccount.providers.spotify.provider import SpotifyOAuth2Provider |
| 6 |
from tests.apps.socialaccount.base import OAuth2TestsMixin |
| 7 |
from tests.mocking import MockedResponse |
| 8 |
|
| 9 |
|
| 10 |
class SpotifyOAuth2Tests(OAuth2TestsMixin, TestCase): |
| 11 |
provider_id = SpotifyOAuth2Provider.id |
| 12 |
|
| 13 |
def get_mocked_response(self): |
| 14 |
return MockedResponse( |
| 15 |
HTTPStatus.OK, |
| 16 |
"""{ |
| 17 |
"birthdate": "1937-06-01", |
| 18 |
"country": "SE", |
| 19 |
"display_name": "JM Wizzler", |
| 20 |
"email": "[email protected]", |
| 21 |
"external_urls": { |
| 22 |
"spotify": "https://open.spotify.com/user/wizzler" |
| 23 |
}, |
| 24 |
"followers" : { |
| 25 |
"href" : null, |
| 26 |
"total" : 3829 |
| 27 |
}, |
| 28 |
"href": "https://api.spotify.com/v1/users/wizzler", |
| 29 |
"id": "wizzler", |
| 30 |
"images": [ |
| 31 |
{ |
| 32 |
"height": null, |
| 33 |
"url": |
| 34 |
"https://fbcdn-profile-a.akamaihd.net/hprofile-ak-frc3/t1.0-1/1970403_10152215092574354_1798272330_n.jpg", |
| 35 |
"width": null |
| 36 |
} |
| 37 |
], |
| 38 |
"product": "premium", |
| 39 |
"type": "user", |
| 40 |
"uri": "spotify:user:wizzler" |
| 41 |
}""", |
| 42 |
) # noqa |
| 43 |
|
| 44 |
def get_expected_to_str(self): |
| 45 |
return "[email protected]" |