diff options
author | codl <[email protected]> | 2017-11-30 02:36:43 +0100 |
---|---|---|
committer | codl <[email protected]> | 2017-11-30 02:36:43 +0100 |
commit | d87ada3d73de69ba371acaeca55751e2410c3786 (patch) | |
tree | 4095784a47c6d472377201817331ac93b7773867 | |
parent | 9a9604896c4d586a56b4e53c055a5f762bbaab0d (diff) | |
download | mastodon.py-d87ada3d73de69ba371acaeca55751e2410c3786.tar.gz |
add tests for notification methods
-rw-r--r-- | tests/cassettes/test_notifications.yaml | 130 | ||||
-rw-r--r-- | tests/cassettes/test_notifications_clear.yaml | 28 | ||||
-rw-r--r-- | tests/cassettes/test_notifications_dismiss.yaml | 126 | ||||
-rw-r--r-- | tests/test_notifications.py | 21 |
4 files changed, 305 insertions, 0 deletions
diff --git a/tests/cassettes/test_notifications.yaml b/tests/cassettes/test_notifications.yaml new file mode 100644 index 0000000..c9945cf --- /dev/null +++ b/tests/cassettes/test_notifications.yaml | |||
@@ -0,0 +1,130 @@ | |||
1 | interactions: | ||
2 | - request: | ||
3 | body: visibility=&status=%40mastodonpy_test+hello%21 | ||
4 | headers: | ||
5 | Accept: ['*/*'] | ||
6 | Accept-Encoding: ['gzip, deflate'] | ||
7 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] | ||
8 | Connection: [keep-alive] | ||
9 | Content-Length: ['46'] | ||
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":"99090794695574938","created_at":"2017-11-30T01:32:14.306Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"sr","uri":"http://localhost:3000/users/admin/statuses/99090794695574938","content":"\u003cp\u003e\u003cspan | ||
16 | class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\" | ||
17 | class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e | ||
18 | hello!\u003c/p\u003e","url":"http://localhost:3000/@admin/99090794695574938","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | ||
19 | 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 | ||
20 | :)\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":53},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}'} | ||
21 | headers: | ||
22 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
23 | Content-Type: [application/json; charset=utf-8] | ||
24 | ETag: [W/"7201d05fcb4b437059d9ce1e2174af25"] | ||
25 | Transfer-Encoding: [chunked] | ||
26 | Vary: ['Accept-Encoding, Origin'] | ||
27 | X-Content-Type-Options: [nosniff] | ||
28 | X-Frame-Options: [SAMEORIGIN] | ||
29 | X-Request-Id: [58594a6a-aa68-4f68-86f0-f15a2f22cf73] | ||
30 | X-Runtime: ['0.135719'] | ||
31 | X-XSS-Protection: [1; mode=block] | ||
32 | content-length: ['1542'] | ||
33 | status: {code: 200, message: OK} | ||
34 | - request: | ||
35 | body: null | ||
36 | headers: | ||
37 | Accept: ['*/*'] | ||
38 | Accept-Encoding: ['gzip, deflate'] | ||
39 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
40 | Connection: [keep-alive] | ||
41 | User-Agent: [python-requests/2.18.4] | ||
42 | method: GET | ||
43 | uri: http://localhost:3000/api/v1/notifications | ||
44 | response: | ||
45 | body: {string: '[{"id":"16","type":"mention","created_at":"2017-11-30T01:32:14.351Z","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":53},"status":{"id":"99090794695574938","created_at":"2017-11-30T01:32:14.306Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"sr","uri":"http://localhost:3000/users/admin/statuses/99090794695574938","content":"\u003cp\u003e\u003cspan | ||
47 | class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\" | ||
48 | class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e | ||
49 | hello!\u003c/p\u003e","url":"http://localhost:3000/@admin/99090794695574938","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py | ||
50 | 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 | ||
51 | :)\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":53},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}},{"id":"15","type":"mention","created_at":"2017-11-30T01:31:26.680Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello | ||
52 | :)\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":53},"status":{"id":"99090791570808347","created_at":"2017-11-30T01:31:26.630Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"sr","uri":"http://localhost:3000/users/admin/statuses/99090791570808347","content":"\u003cp\u003e\u003cspan | ||
53 | class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\" | ||
54 | class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e | ||
55 | hello!\u003c/p\u003e","url":"http://localhost:3000/@admin/99090791570808347","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py | ||
56 | 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 | ||
57 | :)\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":53},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}}]'} | ||
58 | headers: | ||
59 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
60 | Content-Type: [application/json; charset=utf-8] | ||
61 | ETag: [W/"fa29e5b94ab138276eb80b2cd108df18"] | ||
62 | Link: ['<http://localhost:3000/api/v1/notifications?max_id=15>; rel="next", | ||
63 | <http://localhost:3000/api/v1/notifications?since_id=16>; rel="prev"'] | ||
64 | Transfer-Encoding: [chunked] | ||
65 | Vary: ['Accept-Encoding, Origin'] | ||
66 | X-Content-Type-Options: [nosniff] | ||
67 | X-Frame-Options: [SAMEORIGIN] | ||
68 | X-Request-Id: [431119a5-b511-4f69-a07c-8b05a2ff8390] | ||
69 | X-Runtime: ['0.102001'] | ||
70 | X-XSS-Protection: [1; mode=block] | ||
71 | content-length: ['4441'] | ||
72 | status: {code: 200, message: OK} | ||
73 | - request: | ||
74 | body: null | ||
75 | headers: | ||
76 | Accept: ['*/*'] | ||
77 | Accept-Encoding: ['gzip, deflate'] | ||
78 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
79 | Connection: [keep-alive] | ||
80 | User-Agent: [python-requests/2.18.4] | ||
81 | method: GET | ||
82 | uri: http://localhost:3000/api/v1/notifications/16 | ||
83 | response: | ||
84 | body: {string: '{"id":"16","type":"mention","created_at":"2017-11-30T01:32:14.351Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello | ||
85 | :)\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":53},"status":{"id":"99090794695574938","created_at":"2017-11-30T01:32:14.306Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"sr","uri":"http://localhost:3000/users/admin/statuses/99090794695574938","content":"\u003cp\u003e\u003cspan | ||
86 | class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\" | ||
87 | class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e | ||
88 | hello!\u003c/p\u003e","url":"http://localhost:3000/@admin/99090794695574938","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py | ||
89 | 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 | ||
90 | :)\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":53},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}}'} | ||
91 | headers: | ||
92 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
93 | Content-Type: [application/json; charset=utf-8] | ||
94 | ETag: [W/"80fb7e9873a9fd89cb5d3be0d5ffd248"] | ||
95 | Transfer-Encoding: [chunked] | ||
96 | Vary: ['Accept-Encoding, Origin'] | ||
97 | X-Content-Type-Options: [nosniff] | ||
98 | X-Frame-Options: [SAMEORIGIN] | ||
99 | X-Request-Id: [68eef56e-6d1b-4a71-8435-014d37d5a5e0] | ||
100 | X-Runtime: ['0.045248'] | ||
101 | X-XSS-Protection: [1; mode=block] | ||
102 | content-length: ['2219'] | ||
103 | status: {code: 200, message: OK} | ||
104 | - request: | ||
105 | body: null | ||
106 | headers: | ||
107 | Accept: ['*/*'] | ||
108 | Accept-Encoding: ['gzip, deflate'] | ||
109 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] | ||
110 | Connection: [keep-alive] | ||
111 | Content-Length: ['0'] | ||
112 | User-Agent: [python-requests/2.18.4] | ||
113 | method: DELETE | ||
114 | uri: http://localhost:3000/api/v1/statuses/99090794695574938 | ||
115 | response: | ||
116 | body: {string: '{}'} | ||
117 | headers: | ||
118 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
119 | Content-Type: [application/json; charset=utf-8] | ||
120 | ETag: [W/"91480b3dc645d962fb3e347248bb79d0"] | ||
121 | Transfer-Encoding: [chunked] | ||
122 | Vary: ['Accept-Encoding, Origin'] | ||
123 | X-Content-Type-Options: [nosniff] | ||
124 | X-Frame-Options: [SAMEORIGIN] | ||
125 | X-Request-Id: [96a5b3a1-51b4-498b-bf0e-6b15a78847e6] | ||
126 | X-Runtime: ['0.015668'] | ||
127 | X-XSS-Protection: [1; mode=block] | ||
128 | content-length: ['2'] | ||
129 | status: {code: 200, message: OK} | ||
130 | version: 1 | ||
diff --git a/tests/cassettes/test_notifications_clear.yaml b/tests/cassettes/test_notifications_clear.yaml new file mode 100644 index 0000000..edf5a35 --- /dev/null +++ b/tests/cassettes/test_notifications_clear.yaml | |||
@@ -0,0 +1,28 @@ | |||
1 | interactions: | ||
2 | - request: | ||
3 | body: null | ||
4 | headers: | ||
5 | Accept: ['*/*'] | ||
6 | Accept-Encoding: ['gzip, deflate'] | ||
7 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
8 | Connection: [keep-alive] | ||
9 | Content-Length: ['0'] | ||
10 | User-Agent: [python-requests/2.18.4] | ||
11 | method: POST | ||
12 | uri: http://localhost:3000/api/v1/notifications/clear | ||
13 | response: | ||
14 | body: {string: '{}'} | ||
15 | headers: | ||
16 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
17 | Content-Type: [application/json; charset=utf-8] | ||
18 | ETag: [W/"35ef2e1d7c4d5273d1cb56508dccd187"] | ||
19 | Transfer-Encoding: [chunked] | ||
20 | Vary: ['Accept-Encoding, Origin'] | ||
21 | X-Content-Type-Options: [nosniff] | ||
22 | X-Frame-Options: [SAMEORIGIN] | ||
23 | X-Request-Id: [08457d1a-6c84-4813-9949-0acfccd0251e] | ||
24 | X-Runtime: ['0.022075'] | ||
25 | X-XSS-Protection: [1; mode=block] | ||
26 | content-length: ['2'] | ||
27 | status: {code: 200, message: OK} | ||
28 | version: 1 | ||
diff --git a/tests/cassettes/test_notifications_dismiss.yaml b/tests/cassettes/test_notifications_dismiss.yaml new file mode 100644 index 0000000..e5f8f34 --- /dev/null +++ b/tests/cassettes/test_notifications_dismiss.yaml | |||
@@ -0,0 +1,126 @@ | |||
1 | interactions: | ||
2 | - request: | ||
3 | body: visibility=&status=%40mastodonpy_test+hello%21 | ||
4 | headers: | ||
5 | Accept: ['*/*'] | ||
6 | Accept-Encoding: ['gzip, deflate'] | ||
7 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] | ||
8 | Connection: [keep-alive] | ||
9 | Content-Length: ['46'] | ||
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":"99090810070829091","created_at":"2017-11-30T01:36:08.913Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"sr","uri":"http://localhost:3000/users/admin/statuses/99090810070829091","content":"\u003cp\u003e\u003cspan | ||
16 | class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\" | ||
17 | class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e | ||
18 | hello!\u003c/p\u003e","url":"http://localhost:3000/@admin/99090810070829091","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py | ||
19 | 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 | ||
20 | :)\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":52},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}'} | ||
21 | headers: | ||
22 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
23 | Content-Type: [application/json; charset=utf-8] | ||
24 | ETag: [W/"1a3ec3316c2518ab5afcc7202dd1497e"] | ||
25 | Transfer-Encoding: [chunked] | ||
26 | Vary: ['Accept-Encoding, Origin'] | ||
27 | X-Content-Type-Options: [nosniff] | ||
28 | X-Frame-Options: [SAMEORIGIN] | ||
29 | X-Request-Id: [a31a0e74-98bd-43b3-9592-2d62286b2ccb] | ||
30 | X-Runtime: ['0.119704'] | ||
31 | X-XSS-Protection: [1; mode=block] | ||
32 | content-length: ['1542'] | ||
33 | status: {code: 200, message: OK} | ||
34 | - request: | ||
35 | body: null | ||
36 | headers: | ||
37 | Accept: ['*/*'] | ||
38 | Accept-Encoding: ['gzip, deflate'] | ||
39 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
40 | Connection: [keep-alive] | ||
41 | User-Agent: [python-requests/2.18.4] | ||
42 | method: GET | ||
43 | uri: http://localhost:3000/api/v1/notifications | ||
44 | response: | ||
45 | body: {string: '[{"id":"17","type":"mention","created_at":"2017-11-30T01:36:08.959Z","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":52},"status":{"id":"99090810070829091","created_at":"2017-11-30T01:36:08.913Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"sr","uri":"http://localhost:3000/users/admin/statuses/99090810070829091","content":"\u003cp\u003e\u003cspan | ||
47 | class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\" | ||
48 | class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e | ||
49 | hello!\u003c/p\u003e","url":"http://localhost:3000/@admin/99090810070829091","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py | ||
50 | 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 | ||
51 | :)\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":52},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}},{"id":"15","type":"mention","created_at":"2017-11-30T01:31:26.680Z","account":{"id":"1","username":"admin","acct":"admin","display_name":"codltest","locked":false,"created_at":"2017-07-01T17:09:15.621Z","note":"\u003cp\u003ehello | ||
52 | :)\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":52},"status":{"id":"99090791570808347","created_at":"2017-11-30T01:31:26.630Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"sr","uri":"http://localhost:3000/users/admin/statuses/99090791570808347","content":"\u003cp\u003e\u003cspan | ||
53 | class=\"h-card\"\u003e\u003ca href=\"http://localhost:3000/@mastodonpy_test\" | ||
54 | class=\"u-url mention\"\u003e@\u003cspan\u003emastodonpy_test\u003c/span\u003e\u003c/a\u003e\u003c/span\u003e | ||
55 | hello!\u003c/p\u003e","url":"http://localhost:3000/@admin/99090791570808347","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"reblog":null,"application":{"name":"Mastodon.py | ||
56 | 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 | ||
57 | :)\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":52},"media_attachments":[],"mentions":[{"id":"1234567890123456","username":"mastodonpy_test","url":"http://localhost:3000/@mastodonpy_test","acct":"mastodonpy_test"}],"tags":[],"emojis":[]}}]'} | ||
58 | headers: | ||
59 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
60 | Content-Type: [application/json; charset=utf-8] | ||
61 | ETag: [W/"064e96244d5856cc227a2fa7d846513e"] | ||
62 | Link: ['<http://localhost:3000/api/v1/notifications?max_id=15>; rel="next", | ||
63 | <http://localhost:3000/api/v1/notifications?since_id=17>; rel="prev"'] | ||
64 | Transfer-Encoding: [chunked] | ||
65 | Vary: ['Accept-Encoding, Origin'] | ||
66 | X-Content-Type-Options: [nosniff] | ||
67 | X-Frame-Options: [SAMEORIGIN] | ||
68 | X-Request-Id: [2347ae7b-0002-4aab-baba-e62a7eb3b716] | ||
69 | X-Runtime: ['0.136302'] | ||
70 | X-XSS-Protection: [1; mode=block] | ||
71 | content-length: ['4441'] | ||
72 | status: {code: 200, message: OK} | ||
73 | - request: | ||
74 | body: id=17 | ||
75 | headers: | ||
76 | Accept: ['*/*'] | ||
77 | Accept-Encoding: ['gzip, deflate'] | ||
78 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
79 | Connection: [keep-alive] | ||
80 | Content-Length: ['5'] | ||
81 | Content-Type: [application/x-www-form-urlencoded] | ||
82 | User-Agent: [python-requests/2.18.4] | ||
83 | method: POST | ||
84 | uri: http://localhost:3000/api/v1/notifications/dismiss | ||
85 | response: | ||
86 | body: {string: '{}'} | ||
87 | headers: | ||
88 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
89 | Content-Type: [application/json; charset=utf-8] | ||
90 | ETag: [W/"35ef2e1d7c4d5273d1cb56508dccd187"] | ||
91 | Transfer-Encoding: [chunked] | ||
92 | Vary: ['Accept-Encoding, Origin'] | ||
93 | X-Content-Type-Options: [nosniff] | ||
94 | X-Frame-Options: [SAMEORIGIN] | ||
95 | X-Request-Id: [24688740-1fd8-4cb3-9def-075a707c5d6c] | ||
96 | X-Runtime: ['0.024190'] | ||
97 | X-XSS-Protection: [1; mode=block] | ||
98 | content-length: ['2'] | ||
99 | status: {code: 200, message: OK} | ||
100 | - request: | ||
101 | body: null | ||
102 | headers: | ||
103 | Accept: ['*/*'] | ||
104 | Accept-Encoding: ['gzip, deflate'] | ||
105 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] | ||
106 | Connection: [keep-alive] | ||
107 | Content-Length: ['0'] | ||
108 | User-Agent: [python-requests/2.18.4] | ||
109 | method: DELETE | ||
110 | uri: http://localhost:3000/api/v1/statuses/99090810070829091 | ||
111 | response: | ||
112 | body: {string: '{}'} | ||
113 | headers: | ||
114 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
115 | Content-Type: [application/json; charset=utf-8] | ||
116 | ETag: [W/"35ef2e1d7c4d5273d1cb56508dccd187"] | ||
117 | Transfer-Encoding: [chunked] | ||
118 | Vary: ['Accept-Encoding, Origin'] | ||
119 | X-Content-Type-Options: [nosniff] | ||
120 | X-Frame-Options: [SAMEORIGIN] | ||
121 | X-Request-Id: [8ae15858-4ac7-49cd-ad68-47567b42a93f] | ||
122 | X-Runtime: ['0.029080'] | ||
123 | X-XSS-Protection: [1; mode=block] | ||
124 | content-length: ['2'] | ||
125 | status: {code: 200, message: OK} | ||
126 | version: 1 | ||
diff --git a/tests/test_notifications.py b/tests/test_notifications.py new file mode 100644 index 0000000..87c898a --- /dev/null +++ b/tests/test_notifications.py | |||
@@ -0,0 +1,21 @@ | |||
1 | import pytest | ||
2 | |||
3 | @pytest.fixture() | ||
4 | def mention(api2): | ||
5 | status = api2.status_post('@mastodonpy_test hello!') | ||
6 | yield status | ||
7 | api2.status_delete(status) | ||
8 | |||
9 | @pytest.mark.vcr() | ||
10 | def test_notifications(api, mention): | ||
11 | notifications = api.notifications() | ||
12 | api.notifications(notifications[0]) | ||
13 | |||
14 | @pytest.mark.vcr() | ||
15 | def test_notifications_dismiss(api, mention): | ||
16 | notifications = api.notifications() | ||
17 | api.notifications_dismiss(notifications[0]) | ||
18 | |||
19 | @pytest.mark.vcr() | ||
20 | def test_notifications_clear(api): | ||
21 | api.notifications_clear() | ||