| 1 |
from http import HTTPStatus |
| 2 |
|
| 3 |
from django.test import TestCase |
| 4 |
|
| 5 |
from allauth.socialaccount.providers.vk.provider import VKProvider |
| 6 |
from tests.apps.socialaccount.base import OAuth2TestsMixin |
| 7 |
from tests.mocking import MockedResponse |
| 8 |
|
| 9 |
|
| 10 |
class VKTests(OAuth2TestsMixin, TestCase): |
| 11 |
provider_id = VKProvider.id |
| 12 |
|
| 13 |
def get_mocked_response(self, verified_email=True): |
| 14 |
return MockedResponse( |
| 15 |
HTTPStatus.OK, |
| 16 |
""" |
| 17 |
{ |
| 18 |
"user": { |
| 19 |
"user_id": "1234567890", |
| 20 |
"first_name": "Ivan", |
| 21 |
"last_name": "I.", |
| 22 |
"phone": "79991234567", |
| 23 |
"avatar": "http://avatar.com/12345678", |
| 24 |
"email": "[email protected]", |
| 25 |
"sex": 2, |
| 26 |
"verified": false, |
| 27 |
"birthday": "01.01.2000" |
| 28 |
} |
| 29 |
} |
| 30 |
""", |
| 31 |
) |
| 32 |
|
| 33 |
def get_expected_to_str(self): |
| 34 |
return "[email protected]" |
| 35 |
|
| 36 |
def get_login_response_json(self, with_refresh_token=True): |
| 37 |
return """ |
| 38 |
{ |
| 39 |
"access_token": "testac", |
| 40 |
"refresh_token": "XXXXX", |
| 41 |
"expires_in": 0, |
| 42 |
"user_id": 1234567890, |
| 43 |
"state": "XXX", |
| 44 |
"scope": "email phone" |
| 45 |
} |
| 46 |
""" |