diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cassettes/test_account_lookup.yaml | 232 | ||||
-rw-r--r-- | tests/test_account.py | 11 |
2 files changed, 243 insertions, 0 deletions
diff --git a/tests/cassettes/test_account_lookup.yaml b/tests/cassettes/test_account_lookup.yaml new file mode 100644 index 0000000..01ed5f7 --- /dev/null +++ b/tests/cassettes/test_account_lookup.yaml | |||
@@ -0,0 +1,232 @@ | |||
1 | interactions: | ||
2 | - request: | ||
3 | body: null | ||
4 | headers: | ||
5 | Accept: | ||
6 | - '*/*' | ||
7 | Accept-Encoding: | ||
8 | - gzip, deflate | ||
9 | Authorization: | ||
10 | - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN | ||
11 | Connection: | ||
12 | - keep-alive | ||
13 | User-Agent: | ||
14 | - tests/v311 | ||
15 | method: GET | ||
16 | uri: http://localhost:3000/api/v1/accounts/verify_credentials | ||
17 | response: | ||
18 | body: | ||
19 | string: '{"id":"109366898092282937","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"discoverable":null,"group":false,"created_at":"2022-11-18T00:00:00.000Z","note":"","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":5,"last_status_at":"2022-11-18","noindex":false,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[],"follow_requests_count":0},"emojis":[],"fields":[],"role":{"id":"-99","name":"","permissions":"65536","color":"","highlighted":false}}' | ||
20 | headers: | ||
21 | Cache-Control: | ||
22 | - no-store | ||
23 | Content-Security-Policy: | ||
24 | - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src | ||
25 | ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; | ||
26 | style-src ''self'' http://localhost:3000 ''nonce-3EN7F4MujpHoVrEZ3s8fag==''; | ||
27 | media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' | ||
28 | https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' | ||
29 | data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 | ||
30 | ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' | ||
31 | ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; | ||
32 | worker-src ''self'' blob: http://localhost:3000' | ||
33 | Content-Type: | ||
34 | - application/json; charset=utf-8 | ||
35 | ETag: | ||
36 | - W/"dc5952ea4f0e073dc114984e11e688fe" | ||
37 | Referrer-Policy: | ||
38 | - strict-origin-when-cross-origin | ||
39 | Transfer-Encoding: | ||
40 | - chunked | ||
41 | Vary: | ||
42 | - Accept, Origin | ||
43 | X-Content-Type-Options: | ||
44 | - nosniff | ||
45 | X-Download-Options: | ||
46 | - noopen | ||
47 | X-Frame-Options: | ||
48 | - SAMEORIGIN | ||
49 | X-Permitted-Cross-Domain-Policies: | ||
50 | - none | ||
51 | X-Request-Id: | ||
52 | - b30300c0-b4d2-4d92-a447-90c4343be34f | ||
53 | X-Runtime: | ||
54 | - '0.012757' | ||
55 | X-XSS-Protection: | ||
56 | - 1; mode=block | ||
57 | status: | ||
58 | code: 200 | ||
59 | message: OK | ||
60 | - request: | ||
61 | body: null | ||
62 | headers: | ||
63 | Accept: | ||
64 | - '*/*' | ||
65 | Accept-Encoding: | ||
66 | - gzip, deflate | ||
67 | Authorization: | ||
68 | - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN | ||
69 | Connection: | ||
70 | - keep-alive | ||
71 | User-Agent: | ||
72 | - tests/v311 | ||
73 | method: GET | ||
74 | uri: http://localhost:3000/api/v1/accounts/lookup?acct=kljadklajsdkljlkjlkjlkjasdasd | ||
75 | response: | ||
76 | body: | ||
77 | string: '{"error":"Record not found"}' | ||
78 | headers: | ||
79 | Cache-Control: | ||
80 | - no-store | ||
81 | Content-Security-Policy: | ||
82 | - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src | ||
83 | ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; | ||
84 | style-src ''self'' http://localhost:3000 ''nonce-K3+CoL7Djc57eXE+QOhaqw==''; | ||
85 | media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' | ||
86 | https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' | ||
87 | data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 | ||
88 | ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' | ||
89 | ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; | ||
90 | worker-src ''self'' blob: http://localhost:3000' | ||
91 | Content-Type: | ||
92 | - application/json; charset=utf-8 | ||
93 | Referrer-Policy: | ||
94 | - strict-origin-when-cross-origin | ||
95 | Transfer-Encoding: | ||
96 | - chunked | ||
97 | Vary: | ||
98 | - Accept, Origin | ||
99 | X-Content-Type-Options: | ||
100 | - nosniff | ||
101 | X-Download-Options: | ||
102 | - noopen | ||
103 | X-Frame-Options: | ||
104 | - SAMEORIGIN | ||
105 | X-Permitted-Cross-Domain-Policies: | ||
106 | - none | ||
107 | X-Request-Id: | ||
108 | - ad639c09-6937-494b-8d8e-d07c4e57ae17 | ||
109 | X-Runtime: | ||
110 | - '0.007311' | ||
111 | X-XSS-Protection: | ||
112 | - 1; mode=block | ||
113 | status: | ||
114 | code: 404 | ||
115 | message: Not Found | ||
116 | - request: | ||
117 | body: null | ||
118 | headers: | ||
119 | Accept: | ||
120 | - '*/*' | ||
121 | Accept-Encoding: | ||
122 | - gzip, deflate | ||
123 | Authorization: | ||
124 | - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN | ||
125 | Connection: | ||
126 | - keep-alive | ||
127 | User-Agent: | ||
128 | - tests/v311 | ||
129 | method: GET | ||
130 | uri: http://localhost:3000/api/v1/accounts/lookup?acct=mastodonpy_test | ||
131 | response: | ||
132 | body: | ||
133 | string: '{"id":"109366898092282937","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"discoverable":null,"group":false,"created_at":"2022-11-18T00:00:00.000Z","note":"","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":5,"last_status_at":"2022-11-18","noindex":false,"emojis":[],"fields":[]}' | ||
134 | headers: | ||
135 | Cache-Control: | ||
136 | - no-store | ||
137 | Content-Security-Policy: | ||
138 | - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src | ||
139 | ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; | ||
140 | style-src ''self'' http://localhost:3000 ''nonce-ahGApVKvUFVrZV/lQw3Ckw==''; | ||
141 | media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' | ||
142 | https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' | ||
143 | data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 | ||
144 | ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' | ||
145 | ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; | ||
146 | worker-src ''self'' blob: http://localhost:3000' | ||
147 | Content-Type: | ||
148 | - application/json; charset=utf-8 | ||
149 | ETag: | ||
150 | - W/"38e63cb43c9359834b66f41070c8c079" | ||
151 | Referrer-Policy: | ||
152 | - strict-origin-when-cross-origin | ||
153 | Transfer-Encoding: | ||
154 | - chunked | ||
155 | Vary: | ||
156 | - Accept, Origin | ||
157 | X-Content-Type-Options: | ||
158 | - nosniff | ||
159 | X-Download-Options: | ||
160 | - noopen | ||
161 | X-Frame-Options: | ||
162 | - SAMEORIGIN | ||
163 | X-Permitted-Cross-Domain-Policies: | ||
164 | - none | ||
165 | X-Request-Id: | ||
166 | - 74fa7552-bb6c-4154-8993-aac7ede92f32 | ||
167 | X-Runtime: | ||
168 | - '0.010043' | ||
169 | X-XSS-Protection: | ||
170 | - 1; mode=block | ||
171 | status: | ||
172 | code: 200 | ||
173 | message: OK | ||
174 | - request: | ||
175 | body: null | ||
176 | headers: | ||
177 | Accept: | ||
178 | - '*/*' | ||
179 | Accept-Encoding: | ||
180 | - gzip, deflate | ||
181 | Authorization: | ||
182 | - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN | ||
183 | Connection: | ||
184 | - keep-alive | ||
185 | User-Agent: | ||
186 | - tests/v311 | ||
187 | method: GET | ||
188 | uri: http://localhost:3000/api/v1/accounts/lookup?acct=mastodonpy_test%40localhost%3A3000 | ||
189 | response: | ||
190 | body: | ||
191 | string: '{"id":"109366898092282937","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":true,"bot":false,"discoverable":null,"group":false,"created_at":"2022-11-18T00:00:00.000Z","note":"","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":5,"last_status_at":"2022-11-18","noindex":false,"emojis":[],"fields":[]}' | ||
192 | headers: | ||
193 | Cache-Control: | ||
194 | - no-store | ||
195 | Content-Security-Policy: | ||
196 | - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src | ||
197 | ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; | ||
198 | style-src ''self'' http://localhost:3000 ''nonce-VIxMxXw1sv2+gz5VzvH8xw==''; | ||
199 | media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' | ||
200 | https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' | ||
201 | data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 | ||
202 | ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' | ||
203 | ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; | ||
204 | worker-src ''self'' blob: http://localhost:3000' | ||
205 | Content-Type: | ||
206 | - application/json; charset=utf-8 | ||
207 | ETag: | ||
208 | - W/"38e63cb43c9359834b66f41070c8c079" | ||
209 | Referrer-Policy: | ||
210 | - strict-origin-when-cross-origin | ||
211 | Transfer-Encoding: | ||
212 | - chunked | ||
213 | Vary: | ||
214 | - Accept, Origin | ||
215 | X-Content-Type-Options: | ||
216 | - nosniff | ||
217 | X-Download-Options: | ||
218 | - noopen | ||
219 | X-Frame-Options: | ||
220 | - SAMEORIGIN | ||
221 | X-Permitted-Cross-Domain-Policies: | ||
222 | - none | ||
223 | X-Request-Id: | ||
224 | - 772bdf24-12ae-4d4b-b4a1-ae3cd452e247 | ||
225 | X-Runtime: | ||
226 | - '0.010063' | ||
227 | X-XSS-Protection: | ||
228 | - 1; mode=block | ||
229 | status: | ||
230 | code: 200 | ||
231 | message: OK | ||
232 | version: 1 | ||
diff --git a/tests/test_account.py b/tests/test_account.py index 700433f..6f3b9a5 100644 --- a/tests/test_account.py +++ b/tests/test_account.py | |||
@@ -280,3 +280,14 @@ def test_follow_with_notify_reblog(api, api2, api3): | |||
280 | api.account_unfollow(api2_id) | 280 | api.account_unfollow(api2_id) |
281 | api3.status_delete(status1) | 281 | api3.status_delete(status1) |
282 | api2.status_delete(status2) | 282 | api2.status_delete(status2) |
283 | |||
284 | @pytest.mark.vcr() | ||
285 | def test_account_lookup(api, api3): | ||
286 | id = api.me().id | ||
287 | try: | ||
288 | api.account_lookup("kljadklajsdkljlkjlkjlkjasdasd") | ||
289 | assert False | ||
290 | except: | ||
291 | pass | ||
292 | assert(api.account_lookup("mastodonpy_test").id == id) | ||
293 | assert(api.account_lookup("mastodonpy_test@localhost:3000").id == id) \ No newline at end of file | ||