aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_app_account_create.yaml116
-rw-r--r--tests/test_create_app.py21
2 files changed, 137 insertions, 0 deletions
diff --git a/tests/cassettes/test_app_account_create.yaml b/tests/cassettes/test_app_account_create.yaml
new file mode 100644
index 0000000..83f7212
--- /dev/null
+++ b/tests/cassettes/test_app_account_create.yaml
@@ -0,0 +1,116 @@
1interactions:
2- request:
3 body: client_name=mastodon.py+generated+test+app&scopes=read+write+follow+push&redirect_uris=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Connection: [keep-alive]
8 Content-Length: ['122']
9 Content-Type: [application/x-www-form-urlencoded]
10 User-Agent: [python-requests/2.18.4]
11 method: POST
12 uri: http://localhost:3000/api/v1/apps
13 response:
14 body: {string: '{"id":"17","name":"mastodon.py generated test app","website":null,"redirect_uri":"urn:ietf:wg:oauth:2.0:oob","client_id":"6b8b07698f3f57d73b0fd779fac2fcc64d6e852d3334425a6b50b53bc32db986","client_secret":"df903d79cc8a27d8d4f9aa8213cf65a9681fea679a56643fcb3e5a3f66c4f9c7","vapid_key":"BCryMB_mKFcSpmXE3kJ1Ri3ZFVdBLjRsX54VYhE21BMyftx8k67qWxFs2OCuQCtj0k1ILESkQhGuOKJcQnodx4g="}'}
15 headers:
16 Cache-Control: ['max-age=0, private, must-revalidate']
17 Content-Type: [application/json; charset=utf-8]
18 ETag: [W/"3a06e1b620ce8b2c3ce4045d1e2c179b"]
19 Referrer-Policy: [strict-origin-when-cross-origin]
20 Transfer-Encoding: [chunked]
21 Vary: ['Accept-Encoding, Origin']
22 X-Content-Type-Options: [nosniff]
23 X-Download-Options: [noopen]
24 X-Frame-Options: [SAMEORIGIN]
25 X-Permitted-Cross-Domain-Policies: [none]
26 X-Request-Id: [258ec6bb-4a82-41c3-b55b-560fdfb5ad13]
27 X-Runtime: ['0.025005']
28 X-XSS-Protection: [1; mode=block]
29 content-length: ['374']
30 status: {code: 200, message: OK}
31- request:
32 body: null
33 headers:
34 Accept: ['*/*']
35 Accept-Encoding: ['gzip, deflate']
36 Connection: [keep-alive]
37 User-Agent: [python-requests/2.18.4]
38 method: GET
39 uri: http://localhost:3000/api/v1/instance/
40 response:
41 body: {string: '{"uri":"localhost","title":"Mastodon","description":"","email":"","version":"2.8.0","urls":{"streaming_api":"ws://localhost:4000"},"stats":{"user_count":2,"status_count":15,"domain_count":0},"thumbnail":"http://localhost/packs/media/images/preview-9a17d32fc48369e8ccd910a75260e67d.jpg","languages":["en"],"registrations":true,"contact_account":null}'}
42 headers:
43 Cache-Control: ['max-age=300, public']
44 Content-Type: [application/json; charset=utf-8]
45 Date: ['Sun, 28 Apr 2019 15:56:05 GMT']
46 ETag: [W/"4ba18203af6a9d9402c05e8ffc21ac45"]
47 Referrer-Policy: [strict-origin-when-cross-origin]
48 Transfer-Encoding: [chunked]
49 Vary: ['Accept-Encoding, Origin']
50 X-Content-Type-Options: [nosniff]
51 X-Download-Options: [noopen]
52 X-Frame-Options: [SAMEORIGIN]
53 X-Permitted-Cross-Domain-Policies: [none]
54 X-Request-Id: [bfb330d1-53c3-4fcc-b79e-30e256a2f845]
55 X-Runtime: ['0.025590']
56 X-XSS-Protection: [1; mode=block]
57 content-length: ['349']
58 status: {code: 200, message: OK}
59- request:
60 body: scope=read+write+follow+push&client_id=6b8b07698f3f57d73b0fd779fac2fcc64d6e852d3334425a6b50b53bc32db986&client_secret=df903d79cc8a27d8d4f9aa8213cf65a9681fea679a56643fcb3e5a3f66c4f9c7&grant_type=client_credentials
61 headers:
62 Accept: ['*/*']
63 Accept-Encoding: ['gzip, deflate']
64 Connection: [keep-alive]
65 Content-Length: ['212']
66 Content-Type: [application/x-www-form-urlencoded]
67 User-Agent: [python-requests/2.18.4]
68 method: POST
69 uri: http://localhost:3000/oauth/token
70 response:
71 body: {string: '{"access_token":"756276912d1d5d74cfbf2e275517a234cee584891ca1f87a3fb2bdbd1fed1ca1","token_type":"Bearer","scope":"read
72 write follow push","created_at":1556466966}'}
73 headers:
74 Cache-Control: ['private, no-store']
75 Content-Type: [application/json; charset=utf-8]
76 ETag: [W/"851cc791f71c2ce9bf821e023e26b361"]
77 Pragma: [no-cache]
78 Transfer-Encoding: [chunked]
79 Vary: ['Accept-Encoding, Origin']
80 X-Request-Id: [0205c26b-9c77-4c32-bb59-a2d69eafde33]
81 X-Runtime: ['0.039194']
82 content-length: ['162']
83 status: {code: 200, message: OK}
84- request:
85 body: locale=en&agreement=1&email=email%40localhost11707&password=swordfish&username=coolguy11707&client_id=6b8b07698f3f57d73b0fd779fac2fcc64d6e852d3334425a6b50b53bc32db986&client_secret=df903d79cc8a27d8d4f9aa8213cf65a9681fea679a56643fcb3e5a3f66c4f9c7
86 headers:
87 Accept: ['*/*']
88 Accept-Encoding: ['gzip, deflate']
89 Authorization: [Bearer 756276912d1d5d74cfbf2e275517a234cee584891ca1f87a3fb2bdbd1fed1ca1]
90 Connection: [keep-alive]
91 Content-Length: ['245']
92 Content-Type: [application/x-www-form-urlencoded]
93 User-Agent: [python-requests/2.18.4]
94 method: POST
95 uri: http://localhost:3000/api/v1/accounts
96 response:
97 body: {string: '{"access_token":"b20f513163b154065d17f5aff37b779f51d13c152fe6e7d1be366d64d2e74e39","token_type":"Bearer","scope":"read
98 write follow push","created_at":1556466966}'}
99 headers:
100 Cache-Control: ['private, no-store']
101 Content-Type: [application/json; charset=utf-8]
102 ETag: [W/"7ba50c22bb330ba5a0936c19bea78093"]
103 Pragma: [no-cache]
104 Referrer-Policy: [strict-origin-when-cross-origin]
105 Transfer-Encoding: [chunked]
106 Vary: ['Accept-Encoding, Origin']
107 X-Content-Type-Options: [nosniff]
108 X-Download-Options: [noopen]
109 X-Frame-Options: [SAMEORIGIN]
110 X-Permitted-Cross-Domain-Policies: [none]
111 X-Request-Id: [51ac5a4c-e850-46be-89c6-681e46f891dd]
112 X-Runtime: ['0.208778']
113 X-XSS-Protection: [1; mode=block]
114 content-length: ['162']
115 status: {code: 200, message: OK}
116version: 1
diff --git a/tests/test_create_app.py b/tests/test_create_app.py
index 67318e9..f1153bc 100644
--- a/tests/test_create_app.py
+++ b/tests/test_create_app.py
@@ -1,6 +1,8 @@
1from mastodon import Mastodon 1from mastodon import Mastodon
2import pytest 2import pytest
3import requests 3import requests
4import time
5
4try: 6try:
5 from mock import Mock 7 from mock import Mock
6except ImportError: 8except ImportError:
@@ -46,3 +48,22 @@ def test_app_verify_credentials(api):
46 app = api.app_verify_credentials() 48 app = api.app_verify_credentials()
47 assert app 49 assert app
48 assert app.name == 'Mastodon.py test suite' 50 assert app.name == 'Mastodon.py test suite'
51
52@pytest.mark.vcr()
53def test_app_account_create():
54 # This leaves behind stuff on the test server, which is unfortunate, but eh.
55 suffix = str(time.time()).replace(".", "")[-5:]
56
57 test_app = test_app = Mastodon.create_app(
58 "mastodon.py generated test app",
59 api_base_url="http://localhost:3000/"
60 )
61
62 test_app_api = Mastodon(
63 test_app[0],
64 test_app[1],
65 api_base_url="http://localhost:3000/"
66 )
67 test_token = test_app_api.create_account("coolguy" + suffix, "swordfish", "email@localhost" + suffix, agreement=True)
68 assert test_token
69
Powered by cgit v1.2.3 (git 2.41.0)