| 1 |
from http import HTTPStatus |
| 2 |
|
| 3 |
from django.test import TestCase |
| 4 |
|
| 5 |
from allauth.socialaccount.providers.stripe.provider import StripeProvider |
| 6 |
from tests.apps.socialaccount.base import OAuth2TestsMixin |
| 7 |
from tests.mocking import MockedResponse |
| 8 |
|
| 9 |
|
| 10 |
class StripeTests(OAuth2TestsMixin, TestCase): |
| 11 |
provider_id = StripeProvider.id |
| 12 |
|
| 13 |
def get_mocked_response(self): |
| 14 |
return MockedResponse( |
| 15 |
HTTPStatus.OK, |
| 16 |
"""{ |
| 17 |
"id": "acct_sometestid", |
| 18 |
"object": "account", |
| 19 |
"business_logo": null, |
| 20 |
"business_name": null, |
| 21 |
"business_url": "example.com", |
| 22 |
"charges_enabled": true, |
| 23 |
"country": "SE", |
| 24 |
"currencies_supported": [ |
| 25 |
"usd", |
| 26 |
"eur", |
| 27 |
"sek" |
| 28 |
], |
| 29 |
"default_currency": "eur", |
| 30 |
"details_submitted": true, |
| 31 |
"display_name": "Test", |
| 32 |
"email": "[email protected]", |
| 33 |
"managed": false, |
| 34 |
"metadata": {}, |
| 35 |
"statement_descriptor": "TEST.COM", |
| 36 |
"support_phone": "+460123456789", |
| 37 |
"timezone": "Europe/Stockholm", |
| 38 |
"transfers_enabled": true |
| 39 |
}""", |
| 40 |
) |
| 41 |
|
| 42 |
def get_expected_to_str(self): |
| 43 |
return "[email protected]" |
| 44 |
|
| 45 |
def get_login_response_json(self, with_refresh_token=True): |
| 46 |
rt = "" |
| 47 |
if with_refresh_token: |
| 48 |
rt = ',"refresh_token": "testrf"' |
| 49 |
return ( |
| 50 |
"""{ |
| 51 |
"uid":"weibo", |
| 52 |
"access_token":"testac", |
| 53 |
"livemode": false, |
| 54 |
"token_type": "bearer", |
| 55 |
"stripe_publishable_key": "pk_test_someteskey", |
| 56 |
"stripe_user_id": "acct_sometestid", |
| 57 |
"scope": "read_write" |
| 58 |
%s }""" |
| 59 |
% rt |
| 60 |
) |