aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2018-07-30 21:00:20 +0200
committerLorenz Diener <[email protected]>2018-07-30 21:00:20 +0200
commit5148658d9ae2cbd66985a42f3cf3e90bad51553b (patch)
tree0d504c8d4799555914b66cd6fcf9da5266468c7f /tests
parent2af3fd82f4194c4b089ae06d982525c52e3ae00e (diff)
downloadmastodon.py-5148658d9ae2cbd66985a42f3cf3e90bad51553b.tar.gz
Add test for status_reply
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_status_reply.yaml155
-rw-r--r--tests/test_status.py9
2 files changed, 164 insertions, 0 deletions
diff --git a/tests/cassettes/test_status_reply.yaml b/tests/cassettes/test_status_reply.yaml
new file mode 100644
index 0000000..52592c6
--- /dev/null
+++ b/tests/cassettes/test_status_reply.yaml
@@ -0,0 +1,155 @@
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":"100465157432430306","created_at":"2018-07-30T18:50:45.399Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost:3000/users/mastodonpy_test/statuses/100465157432430306","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/100465157432430306","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py
16 test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John
17 Lennon","locked":true,"bot":false,"created_at":"2018-07-13T23:02:25.260Z","note":"\u003cp\u003eI
18 walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpeg","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpeg","followers_count":0,"following_count":0,"statuses_count":91,"emojis":[],"fields":[{"name":"bread","value":"toasty."},{"name":"lasagna","value":"no!!!"}]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'}
19 headers:
20 Cache-Control: ['max-age=0, private, must-revalidate']
21 Content-Type: [application/json; charset=utf-8]
22 ETag: [W/"1570bf46ed753e1e9bb255d01a1cf40b"]
23 Referrer-Policy: [strict-origin-when-cross-origin]
24 Transfer-Encoding: [chunked]
25 Vary: ['Accept-Encoding, Origin']
26 X-Content-Type-Options: [nosniff]
27 X-Download-Options: [noopen]
28 X-Frame-Options: [SAMEORIGIN]
29 X-Permitted-Cross-Domain-Policies: [none]
30 X-Request-Id: [13fe1446-a1f6-4149-92ed-199374ccfb4b]
31 X-Runtime: ['0.108650']
32 X-XSS-Protection: [1; mode=block]
33 content-length: ['1509']
34 status: {code: 200, message: OK}
35- request:
36 body: null
37 headers:
38 Accept: ['*/*']
39 Accept-Encoding: ['gzip, deflate']
40 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
41 Connection: [keep-alive]
42 User-Agent: [python-requests/2.18.4]
43 method: GET
44 uri: http://localhost:3000/api/v1/accounts/verify_credentials
45 response:
46 body: {string: '{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2018-07-13T19:35:33.303Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","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":68,"source":{"privacy":"public","sensitive":false,"language":null,"note":"","fields":[]},"emojis":[],"fields":[]}'}
47 headers:
48 Cache-Control: ['max-age=0, private, must-revalidate']
49 Content-Type: [application/json; charset=utf-8]
50 ETag: [W/"72353641191d7307875bcab1ace70d94"]
51 Referrer-Policy: [strict-origin-when-cross-origin]
52 Transfer-Encoding: [chunked]
53 Vary: ['Accept-Encoding, Origin']
54 X-Content-Type-Options: [nosniff]
55 X-Download-Options: [noopen]
56 X-Frame-Options: [SAMEORIGIN]
57 X-Permitted-Cross-Domain-Policies: [none]
58 X-Request-Id: [b48ecf88-d134-4501-a66b-d0f71b342ab0]
59 X-Runtime: ['0.047875']
60 X-XSS-Protection: [1; mode=block]
61 content-length: ['635']
62 status: {code: 200, message: OK}
63- request:
64 body: spoiler_text=&visibility=public&in_reply_to_id=100465157432430306&status=%40mastodonpy_test+same%21
65 headers:
66 Accept: ['*/*']
67 Accept-Encoding: ['gzip, deflate']
68 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
69 Connection: [keep-alive]
70 Content-Length: ['99']
71 Content-Type: [application/x-www-form-urlencoded]
72 User-Agent: [python-requests/2.18.4]
73 method: POST
74 uri: http://localhost:3000/api/v1/statuses
75 response:
76 body: {string: '{"id":"100465157444820731","created_at":"2018-07-30T18:50:45.593Z","in_reply_to_id":"100465157432430306","in_reply_to_account_id":"1234567890123456","sensitive":false,"spoiler_text":"","visibility":"public","language":null,"uri":"http://localhost:3000/users/admin/statuses/100465157444820731","content":"\u003cp\u003e\u003cspan
77 class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\"
78 class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
79 same!\u003c/p\u003e","url":"http://localhost:3000/@admin/100465157444820731","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py
80 test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"created_at":"2018-07-13T19:35:33.303Z","note":"\u003cp\u003e\u003c/p\u003e","url":"http://localhost:3000/@admin","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":69,"emojis":[],"fields":[]},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}'}
81 headers:
82 Cache-Control: ['max-age=0, private, must-revalidate']
83 Content-Type: [application/json; charset=utf-8]
84 ETag: [W/"9e8f4486ac9a69d29df0aa9768acbf70"]
85 Referrer-Policy: [strict-origin-when-cross-origin]
86 Transfer-Encoding: [chunked]
87 Vary: ['Accept-Encoding, Origin']
88 X-Content-Type-Options: [nosniff]
89 X-Download-Options: [noopen]
90 X-Frame-Options: [SAMEORIGIN]
91 X-Permitted-Cross-Domain-Policies: [none]
92 X-Request-Id: [02fc8da4-fd42-4759-916a-fcc39f6769ef]
93 X-Runtime: ['0.212302']
94 X-XSS-Protection: [1; mode=block]
95 content-length: ['1520']
96 status: {code: 200, message: OK}
97- request:
98 body: null
99 headers:
100 Accept: ['*/*']
101 Accept-Encoding: ['gzip, deflate']
102 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2]
103 Connection: [keep-alive]
104 Content-Length: ['0']
105 User-Agent: [python-requests/2.18.4]
106 method: DELETE
107 uri: http://localhost:3000/api/v1/statuses/100465157444820731
108 response:
109 body: {string: '{}'}
110 headers:
111 Cache-Control: ['max-age=0, private, must-revalidate']
112 Content-Type: [application/json; charset=utf-8]
113 ETag: [W/"a37e07397123f3af7df5c25887ddf5c0"]
114 Referrer-Policy: [strict-origin-when-cross-origin]
115 Transfer-Encoding: [chunked]
116 Vary: ['Accept-Encoding, Origin']
117 X-Content-Type-Options: [nosniff]
118 X-Download-Options: [noopen]
119 X-Frame-Options: [SAMEORIGIN]
120 X-Permitted-Cross-Domain-Policies: [none]
121 X-Request-Id: [e4c238eb-10b8-4673-9758-a4010b3e6606]
122 X-Runtime: ['0.042563']
123 X-XSS-Protection: [1; mode=block]
124 content-length: ['2']
125 status: {code: 200, message: OK}
126- request:
127 body: null
128 headers:
129 Accept: ['*/*']
130 Accept-Encoding: ['gzip, deflate']
131 Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN]
132 Connection: [keep-alive]
133 Content-Length: ['0']
134 User-Agent: [python-requests/2.18.4]
135 method: DELETE
136 uri: http://localhost:3000/api/v1/statuses/100465157432430306
137 response:
138 body: {string: '{}'}
139 headers:
140 Cache-Control: ['max-age=0, private, must-revalidate']
141 Content-Type: [application/json; charset=utf-8]
142 ETag: [W/"a37e07397123f3af7df5c25887ddf5c0"]
143 Referrer-Policy: [strict-origin-when-cross-origin]
144 Transfer-Encoding: [chunked]
145 Vary: ['Accept-Encoding, Origin']
146 X-Content-Type-Options: [nosniff]
147 X-Download-Options: [noopen]
148 X-Frame-Options: [SAMEORIGIN]
149 X-Permitted-Cross-Domain-Policies: [none]
150 X-Request-Id: [20adf9f8-6636-4bdc-94cc-be0df2f0bf92]
151 X-Runtime: ['0.046848']
152 X-XSS-Protection: [1; mode=block]
153 content-length: ['2']
154 status: {code: 200, message: OK}
155version: 1
diff --git a/tests/test_status.py b/tests/test_status.py
index d36c000..ad861ea 100644
--- a/tests/test_status.py
+++ b/tests/test_status.py
@@ -7,6 +7,15 @@ def test_status(status, api):
7 assert status2 7 assert status2
8 8
9@pytest.mark.vcr() 9@pytest.mark.vcr()
10def test_status_reply(status, api2):
11 status2 = api2.status_reply(status, "same!")
12 try:
13 assert status2
14 assert status2.mentions[0].id == status.account.id
15 finally:
16 api2.status_delete(status2['id'])
17
18@pytest.mark.vcr()
10def test_status_empty(api): 19def test_status_empty(api):
11 with pytest.raises(MastodonAPIError): 20 with pytest.raises(MastodonAPIError):
12 api.status_post('') 21 api.status_post('')
Powered by cgit v1.2.3 (git 2.41.0)