aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/cassettes/test_bookmarks.yaml175
-rw-r--r--tests/conftest.py2
-rw-r--r--tests/test_bookmarks.py21
3 files changed, 197 insertions, 1 deletions
diff --git a/tests/cassettes/test_bookmarks.yaml b/tests/cassettes/test_bookmarks.yaml
new file mode 100644
index 0000000..c2bee19
--- /dev/null
+++ b/tests/cassettes/test_bookmarks.yaml
@@ -0,0 +1,175 @@
1interactions:
2- request:
3 body: status=Toot%21
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
8 Connection: [keep-alive]
9 Content-Length: ['14']
10 Content-Type: [application/x-www-form-urlencoded]
11 User-Agent: [python-requests/2.18.4]
12 method: POST
13 uri: http://localhost:3000/api/v1/statuses
14 response:
15 body: {string: '{"id":"103704183225122470","created_at":"2020-02-22T19:37:36.738Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/103704183225122470","url":"http://localhost/@mastodonpy_test/103704183225122470","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"bookmarked":false,"pinned":false,"content":"\u003cp\u003eToot!\u003c/p\u003e","reblog":null,"application":{"name":"Mastodon.py
16 test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"discoverable":false,"group":false,"created_at":"2020-02-22T20:26:54.402Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","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":3,"last_status_at":"2020-02-22","emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'}
17 headers:
18 Cache-Control: ['no-cache, no-store']
19 Content-Type: [application/json; charset=utf-8]
20 Referrer-Policy: [strict-origin-when-cross-origin]
21 Transfer-Encoding: [chunked]
22 Vary: ['Accept-Encoding, Origin']
23 X-Content-Type-Options: [nosniff]
24 X-Download-Options: [noopen]
25 X-Frame-Options: [SAMEORIGIN]
26 X-Permitted-Cross-Domain-Policies: [none]
27 X-Request-Id: [4c259279-4810-4065-bda7-44fdd2e5e769]
28 X-Runtime: ['0.160125']
29 X-XSS-Protection: [1; mode=block]
30 content-length: ['1320']
31 status: {code: 200, message: OK}
32- request:
33 body: null
34 headers:
35 Accept: ['*/*']
36 Accept-Encoding: ['gzip, deflate']
37 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
38 Connection: [keep-alive]
39 Content-Length: ['0']
40 User-Agent: [python-requests/2.18.4]
41 method: POST
42 uri: http://localhost:3000/api/v1/statuses/103704183225122470/bookmark
43 response:
44 body: {string: '{"id":"103704183225122470","created_at":"2020-02-22T19:37:36.738Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/103704183225122470","url":"http://localhost/@mastodonpy_test/103704183225122470","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"bookmarked":true,"pinned":false,"content":"\u003cp\u003eToot!\u003c/p\u003e","reblog":null,"application":{"name":"Mastodon.py
45 test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"discoverable":false,"group":false,"created_at":"2020-02-22T20:26:54.402Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","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":3,"last_status_at":"2020-02-22","emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'}
46 headers:
47 Cache-Control: ['no-cache, no-store']
48 Content-Type: [application/json; charset=utf-8]
49 Referrer-Policy: [strict-origin-when-cross-origin]
50 Transfer-Encoding: [chunked]
51 Vary: ['Accept-Encoding, Origin']
52 X-Content-Type-Options: [nosniff]
53 X-Download-Options: [noopen]
54 X-Frame-Options: [SAMEORIGIN]
55 X-Permitted-Cross-Domain-Policies: [none]
56 X-Request-Id: [a0ef24c0-bc8d-45ef-80af-0737f40f4191]
57 X-Runtime: ['0.157864']
58 X-XSS-Protection: [1; mode=block]
59 content-length: ['1319']
60 status: {code: 200, message: OK}
61- request:
62 body: null
63 headers:
64 Accept: ['*/*']
65 Accept-Encoding: ['gzip, deflate']
66 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
67 Connection: [keep-alive]
68 User-Agent: [python-requests/2.18.4]
69 method: GET
70 uri: http://localhost:3000/api/v1/bookmarks
71 response:
72 body: {string: '[{"id":"103704183225122470","created_at":"2020-02-22T19:37:36.738Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/103704183225122470","url":"http://localhost/@mastodonpy_test/103704183225122470","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"bookmarked":true,"pinned":false,"content":"\u003cp\u003eToot!\u003c/p\u003e","reblog":null,"application":{"name":"Mastodon.py
73 test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"discoverable":false,"group":false,"created_at":"2020-02-22T20:26:54.402Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","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":3,"last_status_at":"2020-02-22","emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}]'}
74 headers:
75 Cache-Control: ['no-cache, no-store']
76 Content-Type: [application/json; charset=utf-8]
77 Link: ['<http://localhost:3000/api/v1/bookmarks?min_id=2>; rel="prev"']
78 Referrer-Policy: [strict-origin-when-cross-origin]
79 Transfer-Encoding: [chunked]
80 Vary: ['Accept-Encoding, Origin']
81 X-Content-Type-Options: [nosniff]
82 X-Download-Options: [noopen]
83 X-Frame-Options: [SAMEORIGIN]
84 X-Permitted-Cross-Domain-Policies: [none]
85 X-Request-Id: [e6548f1e-3d17-46be-aca7-f310783119a8]
86 X-Runtime: ['0.075518']
87 X-XSS-Protection: [1; mode=block]
88 content-length: ['1321']
89 status: {code: 200, message: OK}
90- request:
91 body: null
92 headers:
93 Accept: ['*/*']
94 Accept-Encoding: ['gzip, deflate']
95 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
96 Connection: [keep-alive]
97 Content-Length: ['0']
98 User-Agent: [python-requests/2.18.4]
99 method: POST
100 uri: http://localhost:3000/api/v1/statuses/103704183225122470/unbookmark
101 response:
102 body: {string: '{"id":"103704183225122470","created_at":"2020-02-22T19:37:36.738Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/103704183225122470","url":"http://localhost/@mastodonpy_test/103704183225122470","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"bookmarked":false,"pinned":false,"content":"\u003cp\u003eToot!\u003c/p\u003e","reblog":null,"application":{"name":"Mastodon.py
103 test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"discoverable":false,"group":false,"created_at":"2020-02-22T20:26:54.402Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","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":3,"last_status_at":"2020-02-22","emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'}
104 headers:
105 Cache-Control: ['no-cache, no-store']
106 Content-Type: [application/json; charset=utf-8]
107 Referrer-Policy: [strict-origin-when-cross-origin]
108 Transfer-Encoding: [chunked]
109 Vary: ['Accept-Encoding, Origin']
110 X-Content-Type-Options: [nosniff]
111 X-Download-Options: [noopen]
112 X-Frame-Options: [SAMEORIGIN]
113 X-Permitted-Cross-Domain-Policies: [none]
114 X-Request-Id: [d9792c38-ab1e-46de-9737-704433ad8f94]
115 X-Runtime: ['0.095876']
116 X-XSS-Protection: [1; mode=block]
117 content-length: ['1320']
118 status: {code: 200, message: OK}
119- request:
120 body: null
121 headers:
122 Accept: ['*/*']
123 Accept-Encoding: ['gzip, deflate']
124 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
125 Connection: [keep-alive]
126 User-Agent: [python-requests/2.18.4]
127 method: GET
128 uri: http://localhost:3000/api/v1/bookmarks
129 response:
130 body: {string: '[]'}
131 headers:
132 Cache-Control: ['no-cache, no-store']
133 Content-Type: [application/json; charset=utf-8]
134 Referrer-Policy: [strict-origin-when-cross-origin]
135 Transfer-Encoding: [chunked]
136 Vary: ['Accept-Encoding, Origin']
137 X-Content-Type-Options: [nosniff]
138 X-Download-Options: [noopen]
139 X-Frame-Options: [SAMEORIGIN]
140 X-Permitted-Cross-Domain-Policies: [none]
141 X-Request-Id: [8454c5ef-5f23-43b9-89d8-dc1b1605f7ac]
142 X-Runtime: ['0.035375']
143 X-XSS-Protection: [1; mode=block]
144 content-length: ['2']
145 status: {code: 200, message: OK}
146- request:
147 body: null
148 headers:
149 Accept: ['*/*']
150 Accept-Encoding: ['gzip, deflate']
151 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
152 Connection: [keep-alive]
153 Content-Length: ['0']
154 User-Agent: [python-requests/2.18.4]
155 method: DELETE
156 uri: http://localhost:3000/api/v1/statuses/103704183225122470
157 response:
158 body: {string: '{"id":"103704183225122470","created_at":"2020-02-22T19:37:36.738Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost/users/mastodonpy_test/statuses/103704183225122470","url":"http://localhost/@mastodonpy_test/103704183225122470","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"bookmarked":false,"pinned":false,"text":"Toot!","reblog":null,"application":{"name":"Mastodon.py
159 test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"discoverable":false,"group":false,"created_at":"2020-02-22T20:26:54.402Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost/@mastodonpy_test","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":3,"last_status_at":"2020-02-22","emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'}
160 headers:
161 Cache-Control: ['no-cache, no-store']
162 Content-Type: [application/json; charset=utf-8]
163 Referrer-Policy: [strict-origin-when-cross-origin]
164 Transfer-Encoding: [chunked]
165 Vary: ['Accept-Encoding, Origin']
166 X-Content-Type-Options: [nosniff]
167 X-Download-Options: [noopen]
168 X-Frame-Options: [SAMEORIGIN]
169 X-Permitted-Cross-Domain-Policies: [none]
170 X-Request-Id: [c222a2ef-6671-4d1c-97be-0a4e2b2f6a14]
171 X-Runtime: ['0.122283']
172 X-XSS-Protection: [1; mode=block]
173 content-length: ['1290']
174 status: {code: 200, message: OK}
175version: 1
diff --git a/tests/conftest.py b/tests/conftest.py
index db314bc..22a4b75 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="3.0.1", version_check_mode="created"): 3def _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN', version="3.1.1", 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_bookmarks.py b/tests/test_bookmarks.py
new file mode 100644
index 0000000..a90a43e
--- /dev/null
+++ b/tests/test_bookmarks.py
@@ -0,0 +1,21 @@
1import pytest
2
3@pytest.mark.vcr()
4def test_bookmarks(api, status):
5 status_bookmarked = api.status_bookmark(status)
6 assert status_bookmarked
7 assert status_bookmarked.bookmarked == True
8
9 bookmarked_statuses = api.bookmarks()
10 assert bookmarked_statuses
11 assert len(bookmarked_statuses) > 0
12 assert status_bookmarked == bookmarked_statuses[0]
13
14 status_unbookmarked = api.status_unbookmark(status_bookmarked)
15 assert status_unbookmarked
16 assert status_unbookmarked.bookmarked == False
17
18 bookmarked_statuses_2 = api.bookmarks()
19 assert not bookmarked_statuses_2 is None
20 assert len(bookmarked_statuses_2) == len(bookmarked_statuses) - 1
21
Powered by cgit v1.2.3 (git 2.41.0)