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 @@ +interactions: +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.18.4] + method: POST + uri: http://localhost:3000/api/v1/accounts/1234567890123456/follow + response: + body: {string: '{"id":"1234567890123456","following":false,"followed_by":false,"blocking":false,"muting":false,"requested":true,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"39b04ee179b7c6820c81f24224090155"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [ff6e83a7-8f9e-4e71-91fe-ab3d12a7b379] + X-Runtime: ['0.073482'] + X-XSS-Protection: [1; mode=block] + content-length: ['136'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.18.4] + method: POST + uri: http://localhost:3000/api/v1/follow_requests/1/authorize + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"25cc8a12b4a7526df56e78049197b9fc"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [e7e70867-7816-42f7-bdfa-994f6bd2dbbc] + X-Runtime: ['0.040458'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.18.4] + method: POST + uri: http://localhost:3000/api/v1/accounts/1234567890123456/unfollow + response: + body: {string: '{"id":"1234567890123456","following":false,"followed_by":false,"blocking":false,"muting":false,"requested":false,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"fc9790ae7d4aa4b12007bc0900ea9c72"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [a651ddce-80d0-484b-a2f2-6c5fb6377d06] + X-Runtime: ['0.040597'] + X-XSS-Protection: [1; mode=block] + content-length: ['137'] + status: {code: 200, message: OK} +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 @@ +interactions: +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN_2] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.18.4] + method: POST + uri: http://localhost:3000/api/v1/accounts/1234567890123456/follow + response: + body: {string: '{"id":"1234567890123456","following":false,"followed_by":false,"blocking":false,"muting":false,"requested":true,"domain_blocking":false}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"5f0d561506d1323c3e160a377c23d7ea"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [7154cf2f-ace8-4c77-9dd8-f7de88d6dfbf] + X-Runtime: ['0.069936'] + X-XSS-Protection: [1; mode=block] + content-length: ['136'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.18.4] + method: POST + uri: http://localhost:3000/api/v1/follow_requests/1/reject + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"025d3164863931d5961fd059d0b0e4ee"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [941e921d-b13d-4ae9-b755-7bd5c9e7f911] + X-Runtime: ['0.032675'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +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 @@ +interactions: +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.18.4] + method: GET + uri: http://localhost:3000/api/v1/follow_requests + response: + body: {string: '[]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"7f1d3431d40cc617f6f01b30e477e673"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [a8b8606f-2fe9-4f6d-a236-6db318021be1] + X-Runtime: ['0.028856'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +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; INSERT INTO accounts ( id, username, + locked, created_at, updated_at ) VALUES ( 1234567890123456, 'mastodonpy_test', + 't', now(), now() ); 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 @@ +import pytest + +@pytest.mark.vcr() +def test_follow_requests(api): + reqs = api.follow_requests() + assert isinstance(reqs, list) + + +# warning: these two send emails, which open in letter opener by default +# so if you are re-recording a cassette for either of these mastodon will +# probably open a browser window for you, which you can safely close +@pytest.mark.vcr() +def test_follow_request_authorize(api, api2): + api2.account_follow(1234567890123456) + api.follow_request_authorize(1) + api2.account_unfollow(1234567890123456) + + +@pytest.mark.vcr() +def test_follow_request_reject(api, api2): + api2.account_follow(1234567890123456) + api.follow_request_reject(1) + +