aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorcodl <[email protected]>2017-11-27 02:25:33 +0100
committercodl <[email protected]>2017-11-27 03:12:02 +0100
commit4b60a0d3cfba50319d2a8a47458db9a89a1a4f12 (patch)
tree0d61d4e79ed28567b8ab63b12d98aaa463927b0f /tests
parent430bebc12481c1ad44592f03ad7d8acbed370eab (diff)
downloadmastodon.py-4b60a0d3cfba50319d2a8a47458db9a89a1a4f12.tar.gz
add tests for json hooks
including a failing test for that thing i fixed earlier which isn't in this branch 😓
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_date_hook.yaml57
-rw-r--r--tests/cassettes/test_id_hook.yaml57
-rw-r--r--tests/cassettes/test_id_hook_in_reply_to.yaml112
-rw-r--r--tests/cassettes/test_id_hook_within_reblog.yaml115
-rw-r--r--tests/fixtures.py25
-rw-r--r--tests/setup_app.sql37
-rw-r--r--tests/test_hooks.py28
7 files changed, 431 insertions, 0 deletions
diff --git a/tests/cassettes/test_date_hook.yaml b/tests/cassettes/test_date_hook.yaml
new file mode 100644
index 0000000..c7ed5b5
--- /dev/null
+++ b/tests/cassettes/test_date_hook.yaml
@@ -0,0 +1,57 @@
1interactions:
2- request:
3 body: visibility=&status=Toot%21
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
8 Connection: [keep-alive]
9 Content-Length: ['26']
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":"99073771458116447","created_at":"2017-11-27T01:23:00.315Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99073771458116447","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@admin/99073771458116447","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":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello
17 :)\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","avatar_static":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":21},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'}
18 headers:
19 Cache-Control: ['max-age=0, private, must-revalidate']
20 Content-Type: [application/json; charset=utf-8]
21 ETag: [W/"4fa954380935e6d530871e25dc7a45c8"]
22 Transfer-Encoding: [chunked]
23 Vary: ['Accept-Encoding, Origin']
24 X-Content-Type-Options: [nosniff]
25 X-Frame-Options: [SAMEORIGIN]
26 X-Request-Id: [5aa7354f-9c8d-4145-99e6-6749e8e2a1d4]
27 X-Runtime: ['0.088013']
28 X-XSS-Protection: [1; mode=block]
29 content-length: ['1216']
30 status: {code: 200, message: OK}
31- request:
32 body: null
33 headers:
34 Accept: ['*/*']
35 Accept-Encoding: ['gzip, deflate']
36 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
37 Connection: [keep-alive]
38 Content-Length: ['0']
39 User-Agent: [python-requests/2.18.4]
40 method: DELETE
41 uri: http://localhost:3000/api/v1/statuses/99073771458116447
42 response:
43 body: {string: '{}'}
44 headers:
45 Cache-Control: ['max-age=0, private, must-revalidate']
46 Content-Type: [application/json; charset=utf-8]
47 ETag: [W/"209d9274b8acc4d2f7265eb56d870053"]
48 Transfer-Encoding: [chunked]
49 Vary: ['Accept-Encoding, Origin']
50 X-Content-Type-Options: [nosniff]
51 X-Frame-Options: [SAMEORIGIN]
52 X-Request-Id: [5ef35962-28e8-4b0c-b5ab-51f3bdf28cce]
53 X-Runtime: ['0.020564']
54 X-XSS-Protection: [1; mode=block]
55 content-length: ['2']
56 status: {code: 200, message: OK}
57version: 1
diff --git a/tests/cassettes/test_id_hook.yaml b/tests/cassettes/test_id_hook.yaml
new file mode 100644
index 0000000..77dc2e1
--- /dev/null
+++ b/tests/cassettes/test_id_hook.yaml
@@ -0,0 +1,57 @@
1interactions:
2- request:
3 body: visibility=&status=Toot%21
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
8 Connection: [keep-alive]
9 Content-Length: ['26']
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":"99073771372606324","created_at":"2017-11-27T01:22:59.008Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99073771372606324","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@admin/99073771372606324","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":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello
17 :)\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","avatar_static":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":20},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'}
18 headers:
19 Cache-Control: ['max-age=0, private, must-revalidate']
20 Content-Type: [application/json; charset=utf-8]
21 ETag: [W/"2c28a9f579b2e3b51139a1081f64c227"]
22 Transfer-Encoding: [chunked]
23 Vary: ['Accept-Encoding, Origin']
24 X-Content-Type-Options: [nosniff]
25 X-Frame-Options: [SAMEORIGIN]
26 X-Request-Id: [c35694b9-ced1-4293-8461-e9480dc409cf]
27 X-Runtime: ['0.082687']
28 X-XSS-Protection: [1; mode=block]
29 content-length: ['1216']
30 status: {code: 200, message: OK}
31- request:
32 body: null
33 headers:
34 Accept: ['*/*']
35 Accept-Encoding: ['gzip, deflate']
36 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
37 Connection: [keep-alive]
38 Content-Length: ['0']
39 User-Agent: [python-requests/2.18.4]
40 method: DELETE
41 uri: http://localhost:3000/api/v1/statuses/99073771372606324
42 response:
43 body: {string: '{}'}
44 headers:
45 Cache-Control: ['max-age=0, private, must-revalidate']
46 Content-Type: [application/json; charset=utf-8]
47 ETag: [W/"352d49aa855575352cbfb0ba819dcde5"]
48 Transfer-Encoding: [chunked]
49 Vary: ['Accept-Encoding, Origin']
50 X-Content-Type-Options: [nosniff]
51 X-Frame-Options: [SAMEORIGIN]
52 X-Request-Id: [d02b01f2-185b-48a7-b338-c305d75fc7e6]
53 X-Runtime: ['0.024066']
54 X-XSS-Protection: [1; mode=block]
55 content-length: ['2']
56 status: {code: 200, message: OK}
57version: 1
diff --git a/tests/cassettes/test_id_hook_in_reply_to.yaml b/tests/cassettes/test_id_hook_in_reply_to.yaml
new file mode 100644
index 0000000..ad73081
--- /dev/null
+++ b/tests/cassettes/test_id_hook_in_reply_to.yaml
@@ -0,0 +1,112 @@
1interactions:
2- request:
3 body: visibility=&status=Toot%21
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
8 Connection: [keep-alive]
9 Content-Length: ['26']
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":"99073771383398048","created_at":"2017-11-27T01:22:59.173Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99073771383398048","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@admin/99073771383398048","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":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello
17 :)\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","avatar_static":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":21},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'}
18 headers:
19 Cache-Control: ['max-age=0, private, must-revalidate']
20 Content-Type: [application/json; charset=utf-8]
21 ETag: [W/"ef586888eb13661bb1965e2a7d5f19c6"]
22 Transfer-Encoding: [chunked]
23 Vary: ['Accept-Encoding, Origin']
24 X-Content-Type-Options: [nosniff]
25 X-Frame-Options: [SAMEORIGIN]
26 X-Request-Id: [1e79a2e1-102f-492a-9dc6-b1e6a335f027]
27 X-Runtime: ['0.080896']
28 X-XSS-Protection: [1; mode=block]
29 content-length: ['1216']
30 status: {code: 200, message: OK}
31- request:
32 body: visibility=&in_reply_to_id=99073771383398048&status=Reply%21
33 headers:
34 Accept: ['*/*']
35 Accept-Encoding: ['gzip, deflate']
36 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
37 Connection: [keep-alive]
38 Content-Length: ['60']
39 Content-Type: [application/x-www-form-urlencoded]
40 User-Agent: [python-requests/2.18.4]
41 method: POST
42 uri: http://localhost:3000/api/v1/statuses
43 response:
44 body: {string: '{"id":"99073771391086384","created_at":"2017-11-27T01:22:59.292Z","in_reply_to_id":"99073771383398048","in_reply_to_account_id":"1","sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99073771391086384","content":"\u003cp\u003eReply!\u003c/p\u003e","url":"http://localhost:3000/@admin/99073771391086384","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py
45 test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello
46 :)\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","avatar_static":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":22},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'}
47 headers:
48 Cache-Control: ['max-age=0, private, must-revalidate']
49 Content-Type: [application/json; charset=utf-8]
50 ETag: [W/"f1b126b867555c13a93a5f6a48fa2912"]
51 Transfer-Encoding: [chunked]
52 Vary: ['Accept-Encoding, Origin']
53 X-Content-Type-Options: [nosniff]
54 X-Frame-Options: [SAMEORIGIN]
55 X-Request-Id: [611432d3-60a5-4416-9028-1120419cd0c6]
56 X-Runtime: ['0.127749']
57 X-XSS-Protection: [1; mode=block]
58 content-length: ['1231']
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_TOKEN]
66 Connection: [keep-alive]
67 Content-Length: ['0']
68 User-Agent: [python-requests/2.18.4]
69 method: DELETE
70 uri: http://localhost:3000/api/v1/statuses/99073771391086384
71 response:
72 body: {string: '{}'}
73 headers:
74 Cache-Control: ['max-age=0, private, must-revalidate']
75 Content-Type: [application/json; charset=utf-8]
76 ETag: [W/"352d49aa855575352cbfb0ba819dcde5"]
77 Transfer-Encoding: [chunked]
78 Vary: ['Accept-Encoding, Origin']
79 X-Content-Type-Options: [nosniff]
80 X-Frame-Options: [SAMEORIGIN]
81 X-Request-Id: [6262e8bc-2a6e-4c03-b4c9-4381f83e3a67]
82 X-Runtime: ['0.030844']
83 X-XSS-Protection: [1; mode=block]
84 content-length: ['2']
85 status: {code: 200, message: OK}
86- request:
87 body: null
88 headers:
89 Accept: ['*/*']
90 Accept-Encoding: ['gzip, deflate']
91 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
92 Connection: [keep-alive]
93 Content-Length: ['0']
94 User-Agent: [python-requests/2.18.4]
95 method: DELETE
96 uri: http://localhost:3000/api/v1/statuses/99073771383398048
97 response:
98 body: {string: '{}'}
99 headers:
100 Cache-Control: ['max-age=0, private, must-revalidate']
101 Content-Type: [application/json; charset=utf-8]
102 ETag: [W/"352d49aa855575352cbfb0ba819dcde5"]
103 Transfer-Encoding: [chunked]
104 Vary: ['Accept-Encoding, Origin']
105 X-Content-Type-Options: [nosniff]
106 X-Frame-Options: [SAMEORIGIN]
107 X-Request-Id: [f362de58-ca39-4c4f-b89c-b2135f25a05f]
108 X-Runtime: ['0.028984']
109 X-XSS-Protection: [1; mode=block]
110 content-length: ['2']
111 status: {code: 200, message: OK}
112version: 1
diff --git a/tests/cassettes/test_id_hook_within_reblog.yaml b/tests/cassettes/test_id_hook_within_reblog.yaml
new file mode 100644
index 0000000..7a4ba93
--- /dev/null
+++ b/tests/cassettes/test_id_hook_within_reblog.yaml
@@ -0,0 +1,115 @@
1interactions:
2- request:
3 body: visibility=&status=Toot%21
4 headers:
5 Accept: ['*/*']
6 Accept-Encoding: ['gzip, deflate']
7 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
8 Connection: [keep-alive]
9 Content-Length: ['26']
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":"99073771410234489","created_at":"2017-11-27T01:22:59.589Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99073771410234489","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@admin/99073771410234489","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":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello
17 :)\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","avatar_static":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":22},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'}
18 headers:
19 Cache-Control: ['max-age=0, private, must-revalidate']
20 Content-Type: [application/json; charset=utf-8]
21 ETag: [W/"a9b6db7410dca5fb876a9b990b4a7e25"]
22 Transfer-Encoding: [chunked]
23 Vary: ['Accept-Encoding, Origin']
24 X-Content-Type-Options: [nosniff]
25 X-Frame-Options: [SAMEORIGIN]
26 X-Request-Id: [300e401e-1f71-4e05-9f30-2ba967927abd]
27 X-Runtime: ['0.114153']
28 X-XSS-Protection: [1; mode=block]
29 content-length: ['1216']
30 status: {code: 200, message: OK}
31- request:
32 body: null
33 headers:
34 Accept: ['*/*']
35 Accept-Encoding: ['gzip, deflate']
36 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
37 Connection: [keep-alive]
38 Content-Length: ['0']
39 User-Agent: [python-requests/2.18.4]
40 method: POST
41 uri: http://localhost:3000/api/v1/statuses/99073771410234489/reblog
42 response:
43 body: {string: '{"id":"99073771420203780","created_at":"2017-11-27T01:22:59.736Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":null,"uri":"http://localhost:3000/users/admin/statuses/99073771420203780/activity","content":"\u003cp\u003eRT
44 \u003cspan class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@admin\"
45 class=\"u-url mention\"\u003e@\u003cspan\u003eadmin\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e
46 Toot!\u003c/p\u003e","url":"http://localhost:3000/@admin/99073771420203780","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":true,"muted":false,"reblog":{"id":"99073771410234489","created_at":"2017-11-27T01:22:59.589Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"en","uri":"http://localhost:3000/users/admin/statuses/99073771410234489","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@admin/99073771410234489","reblogs_count":1,"favourites_count":0,"favourited":false,"reblogged":true,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py
47 test suite","website":null},"account":{"id":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello
48 :)\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","avatar_static":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":22},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]},"application":null,"account":{"id":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello
49 :)\u003c/p\u003e","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","avatar_static":"http://localhost:3000/system/accounts/avatars/000/000/001/original/99b4c443463de195.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":23},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'}
50 headers:
51 Cache-Control: ['max-age=0, private, must-revalidate']
52 Content-Type: [application/json; charset=utf-8]
53 ETag: [W/"85209a7d2c7cb240002817cbb8242376"]
54 Transfer-Encoding: [chunked]
55 Vary: ['Accept-Encoding, Origin']
56 X-Content-Type-Options: [nosniff]
57 X-Frame-Options: [SAMEORIGIN]
58 X-Request-Id: [5350fc29-7570-4f66-b296-9095100e74a7]
59 X-Runtime: ['0.472800']
60 X-XSS-Protection: [1; mode=block]
61 content-length: ['2558']
62 status: {code: 200, message: OK}
63- request:
64 body: null
65 headers:
66 Accept: ['*/*']
67 Accept-Encoding: ['gzip, deflate']
68 Authorization: [Bearer __MASTODON_PY_TEST_TOKEN]
69 Connection: [keep-alive]
70 Content-Length: ['0']
71 User-Agent: [python-requests/2.18.4]
72 method: DELETE
73 uri: http://localhost:3000/api/v1/statuses/99073771420203780
74 response:
75 body: {string: '{}'}
76 headers:
77 Cache-Control: ['max-age=0, private, must-revalidate']
78 Content-Type: [application/json; charset=utf-8]
79 ETag: [W/"209d9274b8acc4d2f7265eb56d870053"]
80 Transfer-Encoding: [chunked]
81 Vary: ['Accept-Encoding, Origin']
82 X-Content-Type-Options: [nosniff]
83 X-Frame-Options: [SAMEORIGIN]
84 X-Request-Id: [c6c39ed1-aa7d-44b8-8a3d-ff4f2c21bb09]
85 X-Runtime: ['0.019955']
86 X-XSS-Protection: [1; mode=block]
87 content-length: ['2']
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_TOKEN]
95 Connection: [keep-alive]
96 Content-Length: ['0']
97 User-Agent: [python-requests/2.18.4]
98 method: DELETE
99 uri: http://localhost:3000/api/v1/statuses/99073771410234489
100 response:
101 body: {string: '{}'}
102 headers:
103 Cache-Control: ['max-age=0, private, must-revalidate']
104 Content-Type: [application/json; charset=utf-8]
105 ETag: [W/"209d9274b8acc4d2f7265eb56d870053"]
106 Transfer-Encoding: [chunked]
107 Vary: ['Accept-Encoding, Origin']
108 X-Content-Type-Options: [nosniff]
109 X-Frame-Options: [SAMEORIGIN]
110 X-Request-Id: [aaef1378-5102-4267-befe-eccdb9198429]
111 X-Runtime: ['0.026212']
112 X-XSS-Protection: [1; mode=block]
113 content-length: ['2']
114 status: {code: 200, message: OK}
115version: 1
diff --git a/tests/fixtures.py b/tests/fixtures.py
new file mode 100644
index 0000000..1b32866
--- /dev/null
+++ b/tests/fixtures.py
@@ -0,0 +1,25 @@
1import pytest
2
3@pytest.fixture
4def mastodon():
5 import mastodon as _mastodon
6 return _mastodon.Mastodon(
7 api_base_url='http://localhost:3000',
8 client_id='__MASTODON_PY_TEST_ID',
9 client_secret='__MASTODON_PY_TEST_SECRET',
10 access_token='__MASTODON_PY_TEST_TOKEN')
11
12
13
14@pytest.fixture()
15def status(mastodon):
16 _status = mastodon.status_post('Toot!')
17 yield _status
18 mastodon.status_delete(_status['id'])
19
20@pytest.fixture()
21def vcr_config():
22 return dict(
23 match_on = ['method', 'path', 'query', 'body'],
24 decode_compressed_response = True
25 )
diff --git a/tests/setup_app.sql b/tests/setup_app.sql
new file mode 100644
index 0000000..b9f3db9
--- /dev/null
+++ b/tests/setup_app.sql
@@ -0,0 +1,37 @@
1WITH new_app AS (
2 INSERT INTO oauth_applications (
3 name,
4 uid,
5 secret,
6 redirect_uri,
7 scopes,
8 owner_type,
9 owner_id,
10 created_at,
11 updated_at
12 ) VALUES (
13 'Mastodon.py test suite',
14 '__MASTODON_PY_TEST_ID',
15 '__MASTODON_PY_TEST_SECRET',
16 'urn:itef:wg:oauth:2.0:oob',
17 'read write follow',
18 'User',
19 1,
20 now(),
21 now()
22 )
23 RETURNING id
24)
25INSERT INTO oauth_access_tokens (
26 token,
27 scopes,
28 application_id,
29 resource_owner_id,
30 created_at
31) SELECT
32 '__MASTODON_PY_TEST_TOKEN',
33 'read write follow',
34 new_app.id,
35 1,
36 now()
37FROM new_app;
diff --git a/tests/test_hooks.py b/tests/test_hooks.py
new file mode 100644
index 0000000..fe242a6
--- /dev/null
+++ b/tests/test_hooks.py
@@ -0,0 +1,28 @@
1from .fixtures import *
2from datetime import datetime
3
4@pytest.mark.vcr()
5def test_id_hook(status):
6 assert isinstance(status['id'], int)
7
8@pytest.mark.vcr()
9def test_id_hook_in_reply_to(mastodon, status):
10 reply = mastodon.status_post('Reply!', in_reply_to_id=status['id'])
11 try:
12 assert isinstance(reply['in_reply_to_id'], int)
13 assert isinstance(reply['in_reply_to_account_id'], int)
14 finally:
15 mastodon.status_delete(reply['id'])
16
17@pytest.mark.vcr()
18def test_id_hook_within_reblog(mastodon, status):
19 reblog = mastodon.status_reblog(status['id'])
20 try:
21 assert isinstance(reblog['reblog']['id'], int)
22 finally:
23 mastodon.status_delete(reblog['id'])
24
25
26@pytest.mark.vcr()
27def test_date_hook(status):
28 assert isinstance(status['created_at'], datetime)
Powered by cgit v1.2.3 (git 2.41.0)