diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cassettes/test_markers.yaml | 117 | ||||
-rw-r--r-- | tests/test_markers.py | 17 |
2 files changed, 134 insertions, 0 deletions
diff --git a/tests/cassettes/test_markers.yaml b/tests/cassettes/test_markers.yaml new file mode 100644 index 0000000..eceda6d --- /dev/null +++ b/tests/cassettes/test_markers.yaml | |||
@@ -0,0 +1,117 @@ | |||
1 | interactions: | ||
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":"102951400589982753","created_at":"2019-10-12T20:55:05.296Z","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/102951400589982753","url":"http://localhost/@mastodonpy_test/102951400589982753","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":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,"created_at":"2019-06-22T23:11:52.441Z","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":1,"statuses_count":3,"last_status_at":"2019-10-12T20:55:05.311Z","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: [d6e097f3-e4e8-4d83-8c30-c4fe5ed88a87] | ||
28 | X-Runtime: ['0.151706'] | ||
29 | X-XSS-Protection: [1; mode=block] | ||
30 | content-length: ['1280'] | ||
31 | status: {code: 200, message: OK} | ||
32 | - request: | ||
33 | body: '{"home": {"last_read_id": 102951400589982753}}' | ||
34 | headers: | ||
35 | Accept: ['*/*'] | ||
36 | Accept-Encoding: ['gzip, deflate'] | ||
37 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
38 | Connection: [keep-alive] | ||
39 | Content-Length: ['46'] | ||
40 | Content-Type: [application/json] | ||
41 | User-Agent: [python-requests/2.18.4] | ||
42 | method: POST | ||
43 | uri: http://localhost:3000/api/v1/markers | ||
44 | response: | ||
45 | body: {string: '{"home":{"last_read_id":"102951400589982753","version":2,"updated_at":"2019-10-12T20:55:05.457Z"}}'} | ||
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: [2e3c3ede-edf6-43c9-9477-fddca87ffed3] | ||
57 | X-Runtime: ['0.036295'] | ||
58 | X-XSS-Protection: [1; mode=block] | ||
59 | content-length: ['98'] | ||
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/markers?timeline%5B%5D=home | ||
71 | response: | ||
72 | body: {string: '{"home":{"last_read_id":"102951400589982753","version":2,"updated_at":"2019-10-12T20:55:05.457Z"}}'} | ||
73 | headers: | ||
74 | Cache-Control: ['no-cache, no-store'] | ||
75 | Content-Type: [application/json; charset=utf-8] | ||
76 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
77 | Transfer-Encoding: [chunked] | ||
78 | Vary: ['Accept-Encoding, Origin'] | ||
79 | X-Content-Type-Options: [nosniff] | ||
80 | X-Download-Options: [noopen] | ||
81 | X-Frame-Options: [SAMEORIGIN] | ||
82 | X-Permitted-Cross-Domain-Policies: [none] | ||
83 | X-Request-Id: [2d3ddb8a-b93c-48e2-bdda-c4e0edf29adf] | ||
84 | X-Runtime: ['0.022064'] | ||
85 | X-XSS-Protection: [1; mode=block] | ||
86 | content-length: ['98'] | ||
87 | status: {code: 200, message: OK} | ||
88 | - request: | ||
89 | body: null | ||
90 | headers: | ||
91 | Accept: ['*/*'] | ||
92 | Accept-Encoding: ['gzip, deflate'] | ||
93 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
94 | Connection: [keep-alive] | ||
95 | Content-Length: ['0'] | ||
96 | User-Agent: [python-requests/2.18.4] | ||
97 | method: DELETE | ||
98 | uri: http://localhost:3000/api/v1/statuses/102951400589982753 | ||
99 | response: | ||
100 | body: {string: '{"id":"102951400589982753","created_at":"2019-10-12T20:55:05.296Z","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/102951400589982753","url":"http://localhost/@mastodonpy_test/102951400589982753","replies_count":0,"reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"text":"Toot!","reblog":null,"application":{"name":"Mastodon.py | ||
101 | test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"","locked":false,"bot":false,"created_at":"2019-06-22T23:11:52.441Z","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":1,"statuses_count":3,"last_status_at":"2019-10-12T20:55:05.311Z","emojis":[],"fields":[]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}'} | ||
102 | headers: | ||
103 | Cache-Control: ['no-cache, no-store'] | ||
104 | Content-Type: [application/json; charset=utf-8] | ||
105 | Referrer-Policy: [strict-origin-when-cross-origin] | ||
106 | Transfer-Encoding: [chunked] | ||
107 | Vary: ['Accept-Encoding, Origin'] | ||
108 | X-Content-Type-Options: [nosniff] | ||
109 | X-Download-Options: [noopen] | ||
110 | X-Frame-Options: [SAMEORIGIN] | ||
111 | X-Permitted-Cross-Domain-Policies: [none] | ||
112 | X-Request-Id: [526d76d7-5428-45d2-9a84-4f520b09524c] | ||
113 | X-Runtime: ['0.121781'] | ||
114 | X-XSS-Protection: [1; mode=block] | ||
115 | content-length: ['1250'] | ||
116 | status: {code: 200, message: OK} | ||
117 | version: 1 | ||
diff --git a/tests/test_markers.py b/tests/test_markers.py new file mode 100644 index 0000000..a35c56c --- /dev/null +++ b/tests/test_markers.py | |||
@@ -0,0 +1,17 @@ | |||
1 | import pytest | ||
2 | |||
3 | @pytest.mark.vcr() | ||
4 | def test_markers(api, status): | ||
5 | marker_a = api.markers_set("home", status) | ||
6 | assert marker_a | ||
7 | assert marker_a["home"] | ||
8 | |||
9 | marker_b = api.markers_get("home") | ||
10 | assert marker_b | ||
11 | assert marker_b["home"] | ||
12 | |||
13 | assert marker_a.home.version == marker_b.home.version | ||
14 | assert marker_a.home.last_read_id == status.id | ||
15 | assert marker_b.home.last_read_id == status.id | ||
16 | |||
17 | |||