Debian Codegraph @

tests/apps/socialaccount/providers/pinterest/tests.py

raw
1 from http import HTTPStatus
2
3 from django.test import TestCase
4 from django.test.utils import override_settings
5
6 from allauth.socialaccount.providers.pinterest.provider import PinterestProvider
7 from tests.apps.socialaccount.base import OAuth2TestsMixin
8 from tests.mocking import MockedResponse
9
10
11 class PinterestTests(OAuth2TestsMixin, TestCase):
12 provider_id = PinterestProvider.id
13
14 def get_mocked_response(self):
15 return MockedResponse(
16 HTTPStatus.OK,
17 """
18 {
19 "data": {
20 "url": "https://www.pinterest.com/muravskiyyarosl/",
21 "first_name": "Jane",
22 "last_name": "Doe",
23 "id": "351247977031674143"
24 }
25 }
26 """,
27 )
28
29 def get_expected_to_str(self):
30 return "Jane Doe"
31
32 @override_settings(
33 SOCIALACCOUNT_AUTO_SIGNUP=False,
34 SOCIALACCOUNT_PROVIDERS={
35 "pinterest": {
36 "API_VERSION": "v5",
37 }
38 },
39 )
40 def test_login_v5(self):
41 self.provider_id = PinterestProvider.id
42 resp = self.login(
43 MockedResponse(
44 HTTPStatus.OK,
45 """
46 {
47 "account_type": "BUSINESS",
48 "profile_image": "https://i.pinimg.com/280x280_RS/5c/88/2f/5c882f4b02468fcd6cda2ce569c2c166.jpg",
49 "website_url": "https://sns-sdks.github.io/",
50 "username": "enjoylifebot"
51 }
52 """,
53 ),
54 )
55 assert resp.status_code == HTTPStatus.FOUND