aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-04-28 19:36:12 +0200
committerLorenz Diener <[email protected]>2019-04-28 19:36:12 +0200
commit1cbf923494ef5e3457460534f386fd2bf5b648fc (patch)
treeb548aa1b371f7e3d445e00d216b4285622c2e6d2 /tests
parentd7f5b4d66d47baa12d9e986c39385618adef0e71 (diff)
downloadmastodon.py-1cbf923494ef5e3457460534f386fd2bf5b648fc.tar.gz
Add scheduled status test
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_scheduled_status.yaml180
-rw-r--r--tests/test_status.py23
2 files changed, 203 insertions, 0 deletions
diff --git a/tests/cassettes/test_scheduled_status.yaml b/tests/cassettes/test_scheduled_status.yaml
new file mode 100644
index 0000000..9f15214
--- /dev/null
+++ b/tests/cassettes/test_scheduled_status.yaml
@@ -0,0 +1,180 @@
1interactions:
2- request:
3 body: scheduled_at=2019-04-28T17%3A55%3A56.132387%2B00%3A00&status=please+ensure+adequate+headroom
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
8 Connection: [keep-alive]
9 Content-Length: ['92']
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":"15","scheduled_at":"2019-04-28T17:55:56.132Z","params":{"text":"please
16 ensure adequate headroom","media_ids":null,"sensitive":null,"spoiler_text":null,"visibility":null,"scheduled_at":null,"poll":null,"idempotency":null,"in_reply_to_id":null,"application_id":1234567890123456},"media_attachments":[]}'}
17 headers:
18 Cache-Control: ['max-age=0, private, must-revalidate']
19 Content-Type: [application/json; charset=utf-8]
20 ETag: [W/"d9085bd3f4bda89b707e0d17e0c25606"]
21 Referrer-Policy: [strict-origin-when-cross-origin]
22 Transfer-Encoding: [chunked]
23 Vary: ['Accept-Encoding, Origin']
24 X-Content-Type-Options: [nosniff]
25 X-Download-Options: [noopen]
26 X-Frame-Options: [SAMEORIGIN]
27 X-Permitted-Cross-Domain-Policies: [none]
28 X-Request-Id: [e3c02c5e-8bd8-4e7e-a85e-20729f54fe3a]
29 X-Runtime: ['0.045715']
30 X-XSS-Protection: [1; mode=block]
31 content-length: ['307']
32 status: {code: 200, message: OK}
33- request:
34 body: scheduled_at=2019-04-28T17%3A45%3A56.195854%2B00%3A00
35 headers:
36 Accept: ['*/*']
37 Accept-Encoding: ['gzip, deflate']
38 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
39 Connection: [keep-alive]
40 Content-Length: ['53']
41 Content-Type: [application/x-www-form-urlencoded]
42 User-Agent: [python-requests/2.18.4]
43 method: PUT
44 uri: http://localhost:3000/api/v1/scheduled_statuses/15
45 response:
46 body: {string: '{"id":"15","scheduled_at":"2019-04-28T17:45:56.195Z","params":{"poll":null,"text":"please
47 ensure adequate headroom","media_ids":null,"sensitive":null,"visibility":null,"idempotency":null,"scheduled_at":null,"spoiler_text":null,"application_id":1234567890123456,"in_reply_to_id":null},"media_attachments":[]}'}
48 headers:
49 Cache-Control: ['max-age=0, private, must-revalidate']
50 Content-Type: [application/json; charset=utf-8]
51 ETag: [W/"d21355711617bb379ce78df652b0db2f"]
52 Referrer-Policy: [strict-origin-when-cross-origin]
53 Transfer-Encoding: [chunked]
54 Vary: ['Accept-Encoding, Origin']
55 X-Content-Type-Options: [nosniff]
56 X-Download-Options: [noopen]
57 X-Frame-Options: [SAMEORIGIN]
58 X-Permitted-Cross-Domain-Policies: [none]
59 X-Request-Id: [209c6297-c6b8-4c24-909a-9fec28b3b84a]
60 X-Runtime: ['0.023350']
61 X-XSS-Protection: [1; mode=block]
62 content-length: ['307']
63 status: {code: 200, message: OK}
64- request:
65 body: null
66 headers:
67 Accept: ['*/*']
68 Accept-Encoding: ['gzip, deflate']
69 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
70 Connection: [keep-alive]
71 User-Agent: [python-requests/2.18.4]
72 method: GET
73 uri: http://localhost:3000/api/v1/scheduled_statuses
74 response:
75 body: {string: '[{"id":"15","scheduled_at":"2019-04-28T17:45:56.195Z","params":{"poll":null,"text":"please
76 ensure adequate headroom","media_ids":null,"sensitive":null,"visibility":null,"idempotency":null,"scheduled_at":null,"spoiler_text":null,"application_id":1234567890123456,"in_reply_to_id":null},"media_attachments":[]}]'}
77 headers:
78 Cache-Control: ['max-age=0, private, must-revalidate']
79 Content-Type: [application/json; charset=utf-8]
80 ETag: [W/"138781baa8c10ef9dbbc79f4b0de8fde"]
81 Link: ['<http://localhost:3000/api/v1/scheduled_statuses?min_id=15>; rel="prev"']
82 Referrer-Policy: [strict-origin-when-cross-origin]
83 Transfer-Encoding: [chunked]
84 Vary: ['Accept-Encoding, Origin']
85 X-Content-Type-Options: [nosniff]
86 X-Download-Options: [noopen]
87 X-Frame-Options: [SAMEORIGIN]
88 X-Permitted-Cross-Domain-Policies: [none]
89 X-Request-Id: [0a077bac-40fc-450f-8c55-3a611f587dcf]
90 X-Runtime: ['0.018360']
91 X-XSS-Protection: [1; mode=block]
92 content-length: ['309']
93 status: {code: 200, message: OK}
94- request:
95 body: null
96 headers:
97 Accept: ['*/*']
98 Accept-Encoding: ['gzip, deflate']
99 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
100 Connection: [keep-alive]
101 User-Agent: [python-requests/2.18.4]
102 method: GET
103 uri: http://localhost:3000/api/v1/scheduled_statuses/15
104 response:
105 body: {string: '{"id":"15","scheduled_at":"2019-04-28T17:45:56.195Z","params":{"poll":null,"text":"please
106 ensure adequate headroom","media_ids":null,"sensitive":null,"visibility":null,"idempotency":null,"scheduled_at":null,"spoiler_text":null,"application_id":1234567890123456,"in_reply_to_id":null},"media_attachments":[]}'}
107 headers:
108 Cache-Control: ['max-age=0, private, must-revalidate']
109 Content-Type: [application/json; charset=utf-8]
110 ETag: [W/"d21355711617bb379ce78df652b0db2f"]
111 Referrer-Policy: [strict-origin-when-cross-origin]
112 Transfer-Encoding: [chunked]
113 Vary: ['Accept-Encoding, Origin']
114 X-Content-Type-Options: [nosniff]
115 X-Download-Options: [noopen]
116 X-Frame-Options: [SAMEORIGIN]
117 X-Permitted-Cross-Domain-Policies: [none]
118 X-Request-Id: [b4114f7e-4da9-4e0b-ae67-3a4f74f2ef98]
119 X-Runtime: ['0.017521']
120 X-XSS-Protection: [1; mode=block]
121 content-length: ['307']
122 status: {code: 200, message: OK}
123- request:
124 body: null
125 headers:
126 Accept: ['*/*']
127 Accept-Encoding: ['gzip, deflate']
128 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
129 Connection: [keep-alive]
130 Content-Length: ['0']
131 User-Agent: [python-requests/2.18.4]
132 method: DELETE
133 uri: http://localhost:3000/api/v1/scheduled_statuses/15
134 response:
135 body: {string: '{}'}
136 headers:
137 Cache-Control: ['max-age=0, private, must-revalidate']
138 Content-Type: [application/json; charset=utf-8]
139 ETag: [W/"827009f7d29340dc4283f20343805141"]
140 Referrer-Policy: [strict-origin-when-cross-origin]
141 Transfer-Encoding: [chunked]
142 Vary: ['Accept-Encoding, Origin']
143 X-Content-Type-Options: [nosniff]
144 X-Download-Options: [noopen]
145 X-Frame-Options: [SAMEORIGIN]
146 X-Permitted-Cross-Domain-Policies: [none]
147 X-Request-Id: [59ee7082-f753-4527-b2f8-ce856067fee6]
148 X-Runtime: ['0.026622']
149 X-XSS-Protection: [1; mode=block]
150 content-length: ['2']
151 status: {code: 200, message: OK}
152- request:
153 body: null
154 headers:
155 Accept: ['*/*']
156 Accept-Encoding: ['gzip, deflate']
157 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
158 Connection: [keep-alive]
159 User-Agent: [python-requests/2.18.4]
160 method: GET
161 uri: http://localhost:3000/api/v1/scheduled_statuses
162 response:
163 body: {string: '[]'}
164 headers:
165 Cache-Control: ['max-age=0, private, must-revalidate']
166 Content-Type: [application/json; charset=utf-8]
167 ETag: [W/"432588bf7e5e8b3c9a1fa09d4823b9e1"]
168 Referrer-Policy: [strict-origin-when-cross-origin]
169 Transfer-Encoding: [chunked]
170 Vary: ['Accept-Encoding, Origin']
171 X-Content-Type-Options: [nosniff]
172 X-Download-Options: [noopen]
173 X-Frame-Options: [SAMEORIGIN]
174 X-Permitted-Cross-Domain-Policies: [none]
175 X-Request-Id: [b35d8cb9-37b9-493f-9f27-03607a0f9b6e]
176 X-Runtime: ['0.015168']
177 X-XSS-Protection: [1; mode=block]
178 content-length: ['2']
179 status: {code: 200, message: OK}
180version: 1
diff --git a/tests/test_status.py b/tests/test_status.py
index ad861ea..c34db0d 100644
--- a/tests/test_status.py
+++ b/tests/test_status.py
@@ -1,5 +1,6 @@
1import pytest 1import pytest
2from mastodon.Mastodon import MastodonAPIError, MastodonNotFoundError 2from mastodon.Mastodon import MastodonAPIError, MastodonNotFoundError
3import datetime
3 4
4@pytest.mark.vcr() 5@pytest.mark.vcr()
5def test_status(status, api): 6def test_status(status, api):
@@ -121,3 +122,25 @@ def test_status_pin_unpin(status, api):
121 122
122 status = api.status_unpin(status['id']) 123 status = api.status_unpin(status['id'])
123 assert not status['pinned'] 124 assert not status['pinned']
125
126@pytest.mark.vcr()
127def test_scheduled_status(api):
128 the_future = datetime.datetime.now() + datetime.timedelta(minutes=20)
129 scheduled_toot = api.status_post("please ensure adequate headroom", scheduled_at=the_future)
130 assert scheduled_toot
131
132 the_immediate_future = datetime.datetime.now() + datetime.timedelta(minutes=10)
133 scheduled_toot_2 = api.scheduled_status_update(scheduled_toot, the_immediate_future)
134 assert scheduled_toot_2
135 assert scheduled_toot_2.id == scheduled_toot.id
136 assert scheduled_toot_2.scheduled_at < scheduled_toot.scheduled_at
137
138 scheduled_toot_list = api.scheduled_statuses()
139 assert scheduled_toot_2.id in map(lambda x: x.id, scheduled_toot_list)
140
141 scheduled_toot_3 = api.scheduled_status(scheduled_toot.id)
142 assert scheduled_toot_2.id == scheduled_toot_3.id
143
144 api.scheduled_status_delete(scheduled_toot_2)
145 scheduled_toot_list_2 = api.scheduled_statuses()
146 assert not scheduled_toot_2.id in map(lambda x: x.id, scheduled_toot_list_2)
Powered by cgit v1.2.3 (git 2.41.0)