Debian Codegraph @

tests/apps/socialaccount/providers/nextcloud/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.nextcloud.provider import NextCloudProvider
7 from tests.apps.socialaccount.base import OAuth2TestsMixin
8 from tests.mocking import MockedResponse
9
10
11 @override_settings(
12 SOCIALACCOUNT_PROVIDERS={"nextcloud": {"SERVER": "https://nextcloud.example.org"}}
13 )
14 class NextCloudTests(OAuth2TestsMixin, TestCase):
15 provider_id = NextCloudProvider.id
16
17 def get_login_response_json(self, with_refresh_token=True):
18 return (
19 super()
20 .get_login_response_json(with_refresh_token=with_refresh_token)
21 .replace("uid", "user_id")
22 )
23
24 def get_mocked_response(self):
25 return MockedResponse(
26 HTTPStatus.OK,
27 """
28 {
29 "ocs": {
30 "meta": {
31 "status": "ok",
32 "statuscode": 100,
33 "message": "OK",
34 "totalitems": "",
35 "itemsperpage": ""
36 },
37 "data": {
38 "enabled": true,
39 "storageLocation": "\\/var\\/www\\/html\\/data\\/pennersr",
40 "id": "pennersr",
41 "lastLogin": 1730973409000,
42 "backend": "Database",
43 "subadmin": [],
44 "quota": {
45 "free": 9159623057408,
46 "used": 1585107741,
47 "total": 9161208165149,
48 "relative": 0.02,
49 "quota": -3
50 },
51 "email": "[email protected]",
52 "displayname": "pennersr",
53 "phone": "",
54 "address": "",
55 "website": "",
56 "twitter": "",
57 "groups": [
58 "admin"
59 ],
60 "language": "nl",
61 "locale": ""
62 }
63 }
64 }
65 """,
66 )
67
68 def get_expected_to_str(self):
69 return "[email protected]"