| 1 |
from http import HTTPStatus |
| 2 |
|
| 3 |
from django.test import TestCase |
| 4 |
|
| 5 |
from allauth.socialaccount.models import SocialAccount |
| 6 |
from allauth.socialaccount.providers.discogs.provider import DiscogsProvider |
| 7 |
from tests.apps.socialaccount.base import OAuthTestsMixin |
| 8 |
from tests.mocking import MockedResponse |
| 9 |
|
| 10 |
|
| 11 |
class DiscogsTests(OAuthTestsMixin, TestCase): |
| 12 |
provider_id = DiscogsProvider.id |
| 13 |
|
| 14 |
def get_mocked_response(self): |
| 15 |
return [ |
| 16 |
MockedResponse( |
| 17 |
HTTPStatus.OK, |
| 18 |
r'{"id": 5788917, "username": "veljkoj", ' |
| 19 |
r'"resource_url": "https://api.discogs.com/users/veljkoj", ' |
| 20 |
r'"consumer_name": "myapp"}', |
| 21 |
) |
| 22 |
] |
| 23 |
|
| 24 |
def get_expected_to_str(self): |
| 25 |
return "veljkoj" |
| 26 |
|
| 27 |
def test_login(self): |
| 28 |
super().test_login() |
| 29 |
account = SocialAccount.objects.get(uid="5788917") |
| 30 |
discogs_account = account.get_provider_account() |
| 31 |
|
| 32 |
self.assertEqual(discogs_account.get_username(), "veljkoj") |
| 33 |
self.assertEqual( |
| 34 |
discogs_account.get_profile_url(), |
| 35 |
r"https://api.discogs.com/users/veljkoj", |
| 36 |
) |
| 37 |
self.assertEqual(discogs_account.to_str(), "veljkoj") |