aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_account_pin_unpin.yaml233
-rw-r--r--tests/cassettes/test_mutes.yaml6
-rw-r--r--tests/conftest.py2
-rw-r--r--tests/test_account.py31
4 files changed, 268 insertions, 4 deletions
diff --git a/tests/cassettes/test_account_pin_unpin.yaml b/tests/cassettes/test_account_pin_unpin.yaml
new file mode 100644
index 0000000..eaf3563
--- /dev/null
+++ b/tests/cassettes/test_account_pin_unpin.yaml
@@ -0,0 +1,233 @@
1interactions:
2- request:
3 body: null
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
8 Connection: [keep-alive]
9 User-Agent: [python-requests/2.18.4]
10 method: GET
11 uri: http://localhost:3000/api/v1/accounts/verify_credentials
12 response:
13 body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T18:52:42.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'}
14 headers:
15 Cache-Control: ['max-age=0, private, must-revalidate']
16 Content-Type: [application/json; charset=utf-8]
17 ETag: [W/"0f8b38bbae62fe172a62496fe49e206e"]
18 Referrer-Policy: [strict-origin-when-cross-origin]
19 Transfer-Encoding: [chunked]
20 Vary: ['Accept-Encoding, Origin']
21 X-Content-Type-Options: [nosniff]
22 X-Download-Options: [noopen]
23 X-Frame-Options: [SAMEORIGIN]
24 X-Permitted-Cross-Domain-Policies: [none]
25 X-Request-Id: [692fe5c4-e557-4dd5-99f0-44b812f2e9f3]
26 X-Runtime: ['0.019931']
27 X-XSS-Protection: [1; mode=block]
28 content-length: ['609']
29 status: {code: 200, message: OK}
30- request:
31 body: reblogs=1&id=1
32 headers:
33 Accept: ['*/*']
34 Accept-Encoding: ['gzip, deflate']
35 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
36 Connection: [keep-alive]
37 Content-Length: ['14']
38 Content-Type: [application/x-www-form-urlencoded]
39 User-Agent: [python-requests/2.18.4]
40 method: POST
41 uri: http://localhost:3000/api/v1/accounts/1/follow
42 response:
43 body: {string: '{"id":"1","following":true,"showing_reblogs":true,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false}'}
44 headers:
45 Cache-Control: ['max-age=0, private, must-revalidate']
46 Content-Type: [application/json; charset=utf-8]
47 ETag: [W/"1e1fa14c270ff6960152323eda93cc79"]
48 Referrer-Policy: [strict-origin-when-cross-origin]
49 Transfer-Encoding: [chunked]
50 Vary: ['Accept-Encoding, Origin']
51 X-Content-Type-Options: [nosniff]
52 X-Download-Options: [noopen]
53 X-Frame-Options: [SAMEORIGIN]
54 X-Permitted-Cross-Domain-Policies: [none]
55 X-Request-Id: [ad3bfb7e-d816-4b51-8c90-e431d2330775]
56 X-Runtime: ['0.062775']
57 X-XSS-Protection: [1; mode=block]
58 content-length: ['209']
59 status: {code: 200, message: OK}
60- request:
61 body: null
62 headers:
63 Accept: ['*/*']
64 Accept-Encoding: ['gzip, deflate']
65 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
66 Connection: [keep-alive]
67 Content-Length: ['0']
68 User-Agent: [python-requests/2.18.4]
69 method: POST
70 uri: http://localhost:3000/api/v1/accounts/1/unpin
71 response:
72 body: {string: '{"id":"1","following":true,"showing_reblogs":true,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false}'}
73 headers:
74 Cache-Control: ['max-age=0, private, must-revalidate']
75 Content-Type: [application/json; charset=utf-8]
76 ETag: [W/"1e1fa14c270ff6960152323eda93cc79"]
77 Referrer-Policy: [strict-origin-when-cross-origin]
78 Transfer-Encoding: [chunked]
79 Vary: ['Accept-Encoding, Origin']
80 X-Content-Type-Options: [nosniff]
81 X-Download-Options: [noopen]
82 X-Frame-Options: [SAMEORIGIN]
83 X-Permitted-Cross-Domain-Policies: [none]
84 X-Request-Id: [312e2867-4349-4145-8bb0-231e59e3d02c]
85 X-Runtime: ['0.065496']
86 X-XSS-Protection: [1; mode=block]
87 content-length: ['209']
88 status: {code: 200, message: OK}
89- request:
90 body: null
91 headers:
92 Accept: ['*/*']
93 Accept-Encoding: ['gzip, deflate']
94 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
95 Connection: [keep-alive]
96 Content-Length: ['0']
97 User-Agent: [python-requests/2.18.4]
98 method: POST
99 uri: http://localhost:3000/api/v1/accounts/1/pin
100 response:
101 body: {string: '{"id":"1","following":true,"showing_reblogs":true,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":true}'}
102 headers:
103 Cache-Control: ['max-age=0, private, must-revalidate']
104 Content-Type: [application/json; charset=utf-8]
105 ETag: [W/"c6dfb53299bc83b46a9edb08d3930925"]
106 Referrer-Policy: [strict-origin-when-cross-origin]
107 Transfer-Encoding: [chunked]
108 Vary: ['Accept-Encoding, Origin']
109 X-Content-Type-Options: [nosniff]
110 X-Download-Options: [noopen]
111 X-Frame-Options: [SAMEORIGIN]
112 X-Permitted-Cross-Domain-Policies: [none]
113 X-Request-Id: [c9dae17d-d180-447b-bb49-4f6d4ce07f40]
114 X-Runtime: ['0.050245']
115 X-XSS-Protection: [1; mode=block]
116 content-length: ['208']
117 status: {code: 200, message: OK}
118- request:
119 body: null
120 headers:
121 Accept: ['*/*']
122 Accept-Encoding: ['gzip, deflate']
123 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
124 Connection: [keep-alive]
125 User-Agent: [python-requests/2.18.4]
126 method: GET
127 uri: http://localhost:3000/api/v1/endorsements
128 response:
129 body: {string: '[{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2019-04-27T18:52:42.626Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@admin","avatar":"http://localhost/avatars/original/missing.png","avatar_static":"http://localhost/avatars/original/missing.png","header":"http://localhost/headers/original/missing.png","header_static":"http://localhost/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":0,"emojis":[],"fields":[]}]'}
130 headers:
131 Cache-Control: ['max-age=0, private, must-revalidate']
132 Content-Type: [application/json; charset=utf-8]
133 ETag: [W/"ae491d6254719d99832526fc14bfb68b"]
134 Link: ['<http://localhost:3000/api/v1/endorsements?since_id=1>; rel="prev"']
135 Referrer-Policy: [strict-origin-when-cross-origin]
136 Transfer-Encoding: [chunked]
137 Vary: ['Accept-Encoding, Origin']
138 X-Content-Type-Options: [nosniff]
139 X-Download-Options: [noopen]
140 X-Frame-Options: [SAMEORIGIN]
141 X-Permitted-Cross-Domain-Policies: [none]
142 X-Request-Id: [855af719-1d1a-4fe0-93e7-b2ff9293a363]
143 X-Runtime: ['0.018452']
144 X-XSS-Protection: [1; mode=block]
145 content-length: ['525']
146 status: {code: 200, message: OK}
147- request:
148 body: null
149 headers:
150 Accept: ['*/*']
151 Accept-Encoding: ['gzip, deflate']
152 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
153 Connection: [keep-alive]
154 Content-Length: ['0']
155 User-Agent: [python-requests/2.18.4]
156 method: POST
157 uri: http://localhost:3000/api/v1/accounts/1/unpin
158 response:
159 body: {string: '{"id":"1","following":true,"showing_reblogs":true,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false}'}
160 headers:
161 Cache-Control: ['max-age=0, private, must-revalidate']
162 Content-Type: [application/json; charset=utf-8]
163 ETag: [W/"1e1fa14c270ff6960152323eda93cc79"]
164 Referrer-Policy: [strict-origin-when-cross-origin]
165 Transfer-Encoding: [chunked]
166 Vary: ['Accept-Encoding, Origin']
167 X-Content-Type-Options: [nosniff]
168 X-Download-Options: [noopen]
169 X-Frame-Options: [SAMEORIGIN]
170 X-Permitted-Cross-Domain-Policies: [none]
171 X-Request-Id: [e750e8c4-eae0-4ed6-9563-00ac35d85daa]
172 X-Runtime: ['0.025393']
173 X-XSS-Protection: [1; mode=block]
174 content-length: ['209']
175 status: {code: 200, message: OK}
176- request:
177 body: null
178 headers:
179 Accept: ['*/*']
180 Accept-Encoding: ['gzip, deflate']
181 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
182 Connection: [keep-alive]
183 User-Agent: [python-requests/2.18.4]
184 method: GET
185 uri: http://localhost:3000/api/v1/endorsements
186 response:
187 body: {string: '[]'}
188 headers:
189 Cache-Control: ['max-age=0, private, must-revalidate']
190 Content-Type: [application/json; charset=utf-8]
191 ETag: [W/"e2dc74be154e07a1d543fffa1604d2ab"]
192 Referrer-Policy: [strict-origin-when-cross-origin]
193 Transfer-Encoding: [chunked]
194 Vary: ['Accept-Encoding, Origin']
195 X-Content-Type-Options: [nosniff]
196 X-Download-Options: [noopen]
197 X-Frame-Options: [SAMEORIGIN]
198 X-Permitted-Cross-Domain-Policies: [none]
199 X-Request-Id: [15996817-bf63-4f5e-a34d-c6cf7702822c]
200 X-Runtime: ['0.019443']
201 X-XSS-Protection: [1; mode=block]
202 content-length: ['2']
203 status: {code: 200, message: OK}
204- request:
205 body: null
206 headers:
207 Accept: ['*/*']
208 Accept-Encoding: ['gzip, deflate']
209 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
210 Connection: [keep-alive]
211 Content-Length: ['0']
212 User-Agent: [python-requests/2.18.4]
213 method: POST
214 uri: http://localhost:3000/api/v1/accounts/1/unfollow
215 response:
216 body: {string: '{"id":"1","following":false,"showing_reblogs":false,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false}'}
217 headers:
218 Cache-Control: ['max-age=0, private, must-revalidate']
219 Content-Type: [application/json; charset=utf-8]
220 ETag: [W/"714cd19713205feb75ce771b61d4564b"]
221 Referrer-Policy: [strict-origin-when-cross-origin]
222 Transfer-Encoding: [chunked]
223 Vary: ['Accept-Encoding, Origin']
224 X-Content-Type-Options: [nosniff]
225 X-Download-Options: [noopen]
226 X-Frame-Options: [SAMEORIGIN]
227 X-Permitted-Cross-Domain-Policies: [none]
228 X-Request-Id: [7710c7c9-40d9-4cd9-b483-2863d00916ff]
229 X-Runtime: ['0.041778']
230 X-XSS-Protection: [1; mode=block]
231 content-length: ['211']
232 status: {code: 200, message: OK}
233version: 1
diff --git a/tests/cassettes/test_mutes.yaml b/tests/cassettes/test_mutes.yaml
index 73b8df6..aca7b97 100644
--- a/tests/cassettes/test_mutes.yaml
+++ b/tests/cassettes/test_mutes.yaml
@@ -14,7 +14,7 @@ interactions:
14 headers: 14 headers:
15 Cache-Control: ['max-age=0, private, must-revalidate'] 15 Cache-Control: ['max-age=0, private, must-revalidate']
16 Content-Type: [application/json; charset=utf-8] 16 Content-Type: [application/json; charset=utf-8]
17 ETag: [W/"90b6becb2b7152e68f928ca54703d5b5"] 17 ETag: [W/"0c6c8cc3cb75164dfb4ec124c252008f"]
18 Referrer-Policy: [strict-origin-when-cross-origin] 18 Referrer-Policy: [strict-origin-when-cross-origin]
19 Transfer-Encoding: [chunked] 19 Transfer-Encoding: [chunked]
20 Vary: ['Accept-Encoding, Origin'] 20 Vary: ['Accept-Encoding, Origin']
@@ -22,8 +22,8 @@ interactions:
22 X-Download-Options: [noopen] 22 X-Download-Options: [noopen]
23 X-Frame-Options: [SAMEORIGIN] 23 X-Frame-Options: [SAMEORIGIN]
24 X-Permitted-Cross-Domain-Policies: [none] 24 X-Permitted-Cross-Domain-Policies: [none]
25 X-Request-Id: [1ecc4a5b-3fa6-4aab-9f51-62a63df2668c] 25 X-Request-Id: [1bef2ecf-ea12-422d-802a-456ab7096e0b]
26 X-Runtime: ['0.021739'] 26 X-Runtime: ['0.060542']
27 X-XSS-Protection: [1; mode=block] 27 X-XSS-Protection: [1; mode=block]
28 content-length: ['2'] 28 content-length: ['2']
29 status: {code: 200, message: OK} 29 status: {code: 200, message: OK}
diff --git a/tests/conftest.py b/tests/conftest.py
index 3291bbe..66fffdc 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,6 +1,6 @@
1import pytest 1import pytest
2 2
3def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="2.4.3", version_check_mode="created"): 3def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="2.8.0", version_check_mode="created"):
4 import mastodon 4 import mastodon
5 return mastodon.Mastodon( 5 return mastodon.Mastodon(
6 api_base_url='http://localhost:3000', 6 api_base_url='http://localhost:3000',
diff --git a/tests/test_account.py b/tests/test_account.py
index 77a8f48..cd7633d 100644
--- a/tests/test_account.py
+++ b/tests/test_account.py
@@ -175,3 +175,34 @@ def test_follow_suggestions(api2, status):
175 suggestions2 = api2.suggestions() 175 suggestions2 = api2.suggestions()
176 assert(len(suggestions2) < len(suggestions)) 176 assert(len(suggestions2) < len(suggestions))
177 177
178@pytest.mark.vcr()
179def test_account_pin_unpin(api, api2):
180 user = api2.account_verify_credentials()
181
182 # Make sure we are in the correct state
183 try:
184 api.account_follow(user)
185 except:
186 pass
187
188 try:
189 api.account_unpin(user)
190 except:
191 pass
192
193 relationship = api.account_pin(user)
194 endorsed = api.endorsements()
195
196 try:
197 assert relationship
198 assert relationship['endorsed']
199 assert user["id"] in map(lambda x: x["id"], endorsed)
200 finally:
201 relationship = api.account_unpin(user)
202 endorsed2 = api.endorsements()
203 api.account_unfollow(user)
204 assert relationship
205 assert not relationship['endorsed']
206 assert not user["id"] in map(lambda x: x["id"], endorsed2)
207
208
Powered by cgit v1.2.3 (git 2.41.0)