diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cassettes/test_follow_request_authorize.yaml | 80 | ||||
-rw-r--r-- | tests/cassettes/test_follow_request_reject.yaml | 54 | ||||
-rw-r--r-- | tests/cassettes/test_follow_requests.yaml | 27 | ||||
-rw-r--r-- | tests/setup.sql | 2 | ||||
-rw-r--r-- | tests/test_follow_requests.py | 24 |
5 files changed, 187 insertions, 0 deletions
diff --git a/tests/cassettes/test_follow_request_authorize.yaml b/tests/cassettes/test_follow_request_authorize.yaml new file mode 100644 index 0000000..0cb8487 --- /dev/null +++ b/tests/cassettes/test_follow_request_authorize.yaml | |||
@@ -0,0 +1,80 @@ | |||
1 | interactions: | ||
2 | - request: | ||
3 | body: null | ||
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: ['0'] | ||
10 | User-Agent: [python-requests/2.18.4] | ||
11 | method: POST | ||
12 | uri: http://localhost:3000/api/v1/accounts/1234567890123456/follow | ||
13 | response: | ||
14 | body: {string: '{"id":"1234567890123456","following":false,"followed_by":false,"blocking":false,"muting":false,"requested":true,"domain_blocking":false}'} | ||
15 | headers: | ||
16 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
17 | Content-Type: [application/json; charset=utf-8] | ||
18 | ETag: [W/"39b04ee179b7c6820c81f24224090155"] | ||
19 | Transfer-Encoding: [chunked] | ||
20 | Vary: ['Accept-Encoding, Origin'] | ||
21 | X-Content-Type-Options: [nosniff] | ||
22 | X-Frame-Options: [SAMEORIGIN] | ||
23 | X-Request-Id: [ff6e83a7-8f9e-4e71-91fe-ab3d12a7b379] | ||
24 | X-Runtime: ['0.073482'] | ||
25 | X-XSS-Protection: [1; mode=block] | ||
26 | content-length: ['136'] | ||
27 | status: {code: 200, message: OK} | ||
28 | - request: | ||
29 | body: null | ||
30 | headers: | ||
31 | Accept: ['*/*'] | ||
32 | Accept-Encoding: ['gzip, deflate'] | ||
33 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
34 | Connection: [keep-alive] | ||
35 | Content-Length: ['0'] | ||
36 | User-Agent: [python-requests/2.18.4] | ||
37 | method: POST | ||
38 | uri: http://localhost:3000/api/v1/follow_requests/1/authorize | ||
39 | response: | ||
40 | body: {string: '{}'} | ||
41 | headers: | ||
42 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
43 | Content-Type: [application/json; charset=utf-8] | ||
44 | ETag: [W/"25cc8a12b4a7526df56e78049197b9fc"] | ||
45 | Transfer-Encoding: [chunked] | ||
46 | Vary: ['Accept-Encoding, Origin'] | ||
47 | X-Content-Type-Options: [nosniff] | ||
48 | X-Frame-Options: [SAMEORIGIN] | ||
49 | X-Request-Id: [e7e70867-7816-42f7-bdfa-994f6bd2dbbc] | ||
50 | X-Runtime: ['0.040458'] | ||
51 | X-XSS-Protection: [1; mode=block] | ||
52 | content-length: ['2'] | ||
53 | status: {code: 200, message: OK} | ||
54 | - request: | ||
55 | body: null | ||
56 | headers: | ||
57 | Accept: ['*/*'] | ||
58 | Accept-Encoding: ['gzip, deflate'] | ||
59 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] | ||
60 | Connection: [keep-alive] | ||
61 | Content-Length: ['0'] | ||
62 | User-Agent: [python-requests/2.18.4] | ||
63 | method: POST | ||
64 | uri: http://localhost:3000/api/v1/accounts/1234567890123456/unfollow | ||
65 | response: | ||
66 | body: {string: '{"id":"1234567890123456","following":false,"followed_by":false,"blocking":false,"muting":false,"requested":false,"domain_blocking":false}'} | ||
67 | headers: | ||
68 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
69 | Content-Type: [application/json; charset=utf-8] | ||
70 | ETag: [W/"fc9790ae7d4aa4b12007bc0900ea9c72"] | ||
71 | Transfer-Encoding: [chunked] | ||
72 | Vary: ['Accept-Encoding, Origin'] | ||
73 | X-Content-Type-Options: [nosniff] | ||
74 | X-Frame-Options: [SAMEORIGIN] | ||
75 | X-Request-Id: [a651ddce-80d0-484b-a2f2-6c5fb6377d06] | ||
76 | X-Runtime: ['0.040597'] | ||
77 | X-XSS-Protection: [1; mode=block] | ||
78 | content-length: ['137'] | ||
79 | status: {code: 200, message: OK} | ||
80 | version: 1 | ||
diff --git a/tests/cassettes/test_follow_request_reject.yaml b/tests/cassettes/test_follow_request_reject.yaml new file mode 100644 index 0000000..737ff1c --- /dev/null +++ b/tests/cassettes/test_follow_request_reject.yaml | |||
@@ -0,0 +1,54 @@ | |||
1 | interactions: | ||
2 | - request: | ||
3 | body: null | ||
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: ['0'] | ||
10 | User-Agent: [python-requests/2.18.4] | ||
11 | method: POST | ||
12 | uri: http://localhost:3000/api/v1/accounts/1234567890123456/follow | ||
13 | response: | ||
14 | body: {string: '{"id":"1234567890123456","following":false,"followed_by":false,"blocking":false,"muting":false,"requested":true,"domain_blocking":false}'} | ||
15 | headers: | ||
16 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
17 | Content-Type: [application/json; charset=utf-8] | ||
18 | ETag: [W/"5f0d561506d1323c3e160a377c23d7ea"] | ||
19 | Transfer-Encoding: [chunked] | ||
20 | Vary: ['Accept-Encoding, Origin'] | ||
21 | X-Content-Type-Options: [nosniff] | ||
22 | X-Frame-Options: [SAMEORIGIN] | ||
23 | X-Request-Id: [7154cf2f-ace8-4c77-9dd8-f7de88d6dfbf] | ||
24 | X-Runtime: ['0.069936'] | ||
25 | X-XSS-Protection: [1; mode=block] | ||
26 | content-length: ['136'] | ||
27 | status: {code: 200, message: OK} | ||
28 | - request: | ||
29 | body: null | ||
30 | headers: | ||
31 | Accept: ['*/*'] | ||
32 | Accept-Encoding: ['gzip, deflate'] | ||
33 | Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] | ||
34 | Connection: [keep-alive] | ||
35 | Content-Length: ['0'] | ||
36 | User-Agent: [python-requests/2.18.4] | ||
37 | method: POST | ||
38 | uri: http://localhost:3000/api/v1/follow_requests/1/reject | ||
39 | response: | ||
40 | body: {string: '{}'} | ||
41 | headers: | ||
42 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
43 | Content-Type: [application/json; charset=utf-8] | ||
44 | ETag: [W/"025d3164863931d5961fd059d0b0e4ee"] | ||
45 | Transfer-Encoding: [chunked] | ||
46 | Vary: ['Accept-Encoding, Origin'] | ||
47 | X-Content-Type-Options: [nosniff] | ||
48 | X-Frame-Options: [SAMEORIGIN] | ||
49 | X-Request-Id: [941e921d-b13d-4ae9-b755-7bd5c9e7f911] | ||
50 | X-Runtime: ['0.032675'] | ||
51 | X-XSS-Protection: [1; mode=block] | ||
52 | content-length: ['2'] | ||
53 | status: {code: 200, message: OK} | ||
54 | version: 1 | ||
diff --git a/tests/cassettes/test_follow_requests.yaml b/tests/cassettes/test_follow_requests.yaml new file mode 100644 index 0000000..2fdc788 --- /dev/null +++ b/tests/cassettes/test_follow_requests.yaml | |||
@@ -0,0 +1,27 @@ | |||
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 | User-Agent: [python-requests/2.18.4] | ||
10 | method: GET | ||
11 | uri: http://localhost:3000/api/v1/follow_requests | ||
12 | response: | ||
13 | body: {string: '[]'} | ||
14 | headers: | ||
15 | Cache-Control: ['max-age=0, private, must-revalidate'] | ||
16 | Content-Type: [application/json; charset=utf-8] | ||
17 | ETag: [W/"7f1d3431d40cc617f6f01b30e477e673"] | ||
18 | Transfer-Encoding: [chunked] | ||
19 | Vary: ['Accept-Encoding, Origin'] | ||
20 | X-Content-Type-Options: [nosniff] | ||
21 | X-Frame-Options: [SAMEORIGIN] | ||
22 | X-Request-Id: [a8b8606f-2fe9-4f6d-a236-6db318021be1] | ||
23 | X-Runtime: ['0.028856'] | ||
24 | X-XSS-Protection: [1; mode=block] | ||
25 | content-length: ['2'] | ||
26 | status: {code: 200, message: OK} | ||
27 | version: 1 | ||
diff --git a/tests/setup.sql b/tests/setup.sql index 81f1e18..d65e503 100644 --- a/tests/setup.sql +++ b/tests/setup.sql | |||
@@ -7,11 +7,13 @@ DELETE FROM accounts WHERE id = 1234567890123456; | |||
7 | INSERT INTO accounts ( | 7 | INSERT INTO accounts ( |
8 | id, | 8 | id, |
9 | username, | 9 | username, |
10 | locked, | ||
10 | created_at, | 11 | created_at, |
11 | updated_at | 12 | updated_at |
12 | ) VALUES ( | 13 | ) VALUES ( |
13 | 1234567890123456, | 14 | 1234567890123456, |
14 | 'mastodonpy_test', | 15 | 'mastodonpy_test', |
16 | 't', | ||
15 | now(), | 17 | now(), |
16 | now() | 18 | now() |
17 | ); | 19 | ); |
diff --git a/tests/test_follow_requests.py b/tests/test_follow_requests.py new file mode 100644 index 0000000..67626f7 --- /dev/null +++ b/tests/test_follow_requests.py | |||
@@ -0,0 +1,24 @@ | |||
1 | import pytest | ||
2 | |||
3 | @pytest.mark.vcr() | ||
4 | def test_follow_requests(api): | ||
5 | reqs = api.follow_requests() | ||
6 | assert isinstance(reqs, list) | ||
7 | |||
8 | |||
9 | # warning: these two send emails, which open in letter opener by default | ||
10 | # so if you are re-recording a cassette for either of these mastodon will | ||
11 | # probably open a browser window for you, which you can safely close | ||
12 | @pytest.mark.vcr() | ||
13 | def test_follow_request_authorize(api, api2): | ||
14 | api2.account_follow(1234567890123456) | ||
15 | api.follow_request_authorize(1) | ||
16 | api2.account_unfollow(1234567890123456) | ||
17 | |||
18 | |||
19 | @pytest.mark.vcr() | ||
20 | def test_follow_request_reject(api, api2): | ||
21 | api2.account_follow(1234567890123456) | ||
22 | api.follow_request_reject(1) | ||
23 | |||
24 | |||