From 362767f91146271e17f7f10bd976940a1544bd5a Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Mon, 4 Jun 2018 20:55:44 +0200 Subject: Pinning tests --- tests/cassettes/test_account_pinned.yaml | 231 +++++++++++++++++++++++++++++ tests/cassettes/test_status_pin_unpin.yaml | 116 +++++++++++++++ tests/conftest.py | 6 +- tests/test_account.py | 10 ++ tests/test_constructor.py | 4 +- tests/test_instance.py | 2 +- tests/test_status.py | 8 + 7 files changed, 374 insertions(+), 3 deletions(-) create mode 100644 tests/cassettes/test_account_pinned.yaml create mode 100644 tests/cassettes/test_status_pin_unpin.yaml (limited to 'tests') diff --git a/tests/cassettes/test_account_pinned.yaml b/tests/cassettes/test_account_pinned.yaml new file mode 100644 index 0000000..a803ef6 --- /dev/null +++ b/tests/cassettes/test_account_pinned.yaml @@ -0,0 +1,231 @@ +interactions: +- request: + body: status=Toot%21 + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['14'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/statuses + response: + body: {string: '{"id":"100148083981231904","created_at":"2018-06-04T18:54:48.491Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost:3000/users/mastodonpy_test/statuses/100148083981231904","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/100148083981231904","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"created_at":"2018-05-07T00:38:05.405Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":5},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"27b169f2c3a47c34c96e80742d4d4f53"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [94dacd68-7f37-4329-a801-3f598e70d14a] + X-Runtime: ['0.210785'] + X-XSS-Protection: [1; mode=block] + content-length: ['1399'] + status: {code: 200, message: OK} +- request: + body: status=Toot%2C+too%21 + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['21'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/statuses + response: + body: {string: '{"id":"100148083999835817","created_at":"2018-06-04T18:54:48.795Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"mi","uri":"http://localhost:3000/users/mastodonpy_test/statuses/100148083999835817","content":"\u003cp\u003eToot, + too!\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/100148083999835817","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"created_at":"2018-05-07T00:38:05.405Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":6},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"f8eb615a2b076b4d31bb7c96fd907bd7"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [5d5d8954-754c-4410-a964-75ad0c2ca3f1] + X-Runtime: ['0.296913'] + X-XSS-Protection: [1; mode=block] + content-length: ['1404'] + 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.9.1] + method: POST + uri: http://localhost:3000/api/v1/statuses/100148083981231904/pin + response: + body: {string: '{"id":"100148083981231904","created_at":"2018-06-04T18:54:48.491Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost:3000/users/mastodonpy_test/statuses/100148083981231904","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/100148083981231904","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":true,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"created_at":"2018-05-07T00:38:05.405Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":6},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"3069d241974170b0fdf5638f101c1d14"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [91f5a2ce-5896-4879-80c6-a5fc318d8957] + X-Runtime: ['0.128018'] + X-XSS-Protection: [1; mode=block] + content-length: ['1398'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/accounts/verify_credentials + response: + body: {string: '{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"created_at":"2018-05-07T00:38:05.405Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":6,"source":{"privacy":"public","sensitive":false,"note":"I + walk funny"}}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"0426e9ed5782090a9f08f3fe041e73e5"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [19835760-298b-4cda-8b00-321025061f97] + X-Runtime: ['0.028631'] + X-XSS-Protection: [1; mode=block] + content-length: ['833'] + status: {code: 200, message: OK} +- request: + body: null + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + User-Agent: [python-requests/2.9.1] + method: GET + uri: http://localhost:3000/api/v1/accounts/1234567890123456/statuses?pinned=True + response: + body: {string: '[{"id":"100148083981231904","created_at":"2018-06-04T18:54:48.491Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost:3000/users/mastodonpy_test/statuses/100148083981231904","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/100148083981231904","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":true,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"created_at":"2018-05-07T00:38:05.405Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":6},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}]'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"164c9bc09aa3b6f2851768a66047b329"] + Link: ['; + rel="prev"'] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [222b6664-b99e-48e0-8f20-5aad2764e032] + X-Runtime: ['0.055145'] + X-XSS-Protection: [1; mode=block] + content-length: ['1400'] + 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.9.1] + method: POST + uri: http://localhost:3000/api/v1/statuses/100148083981231904/unpin + response: + body: {string: '{"id":"100148083981231904","created_at":"2018-06-04T18:54:48.491Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost:3000/users/mastodonpy_test/statuses/100148083981231904","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/100148083981231904","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"created_at":"2018-05-07T00:38:05.405Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":6},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"271e3f2fb752c467b8e7670a490f8c89"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [d8e811f8-f682-4c21-a414-394f31b90886] + X-Runtime: ['0.074775'] + X-XSS-Protection: [1; mode=block] + content-length: ['1399'] + 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.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/statuses/100148083999835817 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"5448afda8ed9c69797f461b0b52bef34"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [a950980c-ebcf-4b43-8f9d-489068a0b006] + X-Runtime: ['0.034879'] + 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] + Connection: [keep-alive] + Content-Length: ['0'] + User-Agent: [python-requests/2.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/statuses/100148083981231904 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"5448afda8ed9c69797f461b0b52bef34"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [b8a1de16-05df-4caa-8dd9-414d3d0a36d4] + X-Runtime: ['0.094459'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/cassettes/test_status_pin_unpin.yaml b/tests/cassettes/test_status_pin_unpin.yaml new file mode 100644 index 0000000..116681b --- /dev/null +++ b/tests/cassettes/test_status_pin_unpin.yaml @@ -0,0 +1,116 @@ +interactions: +- request: + body: status=Toot%21 + headers: + Accept: ['*/*'] + Accept-Encoding: ['gzip, deflate'] + Authorization: [Bearer __MASTODON_PY_TEST_ACCESS_TOKEN] + Connection: [keep-alive] + Content-Length: ['14'] + Content-Type: [application/x-www-form-urlencoded] + User-Agent: [python-requests/2.9.1] + method: POST + uri: http://localhost:3000/api/v1/statuses + response: + body: {string: '{"id":"100148044136641620","created_at":"2018-06-04T18:44:40.693Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost:3000/users/mastodonpy_test/statuses/100148044136641620","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/100148044136641620","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"created_at":"2018-05-07T00:38:05.405Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":5},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"de530492b63d03f8014765dfefb58aec"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [fb394353-7fd5-4df4-9325-cd8b848b1d41] + X-Runtime: ['0.644297'] + X-XSS-Protection: [1; mode=block] + content-length: ['1399'] + 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.9.1] + method: POST + uri: http://localhost:3000/api/v1/statuses/100148044136641620/pin + response: + body: {string: '{"id":"100148044136641620","created_at":"2018-06-04T18:44:40.693Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost:3000/users/mastodonpy_test/statuses/100148044136641620","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/100148044136641620","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":true,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"created_at":"2018-05-07T00:38:05.405Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":5},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"5fd67eeb141fb09e42623a6165d262d4"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [b022a70b-3902-4b7a-aa46-6536cda62141] + X-Runtime: ['0.523419'] + X-XSS-Protection: [1; mode=block] + content-length: ['1398'] + 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.9.1] + method: POST + uri: http://localhost:3000/api/v1/statuses/100148044136641620/unpin + response: + body: {string: '{"id":"100148044136641620","created_at":"2018-06-04T18:44:40.693Z","in_reply_to_id":null,"in_reply_to_account_id":null,"sensitive":false,"spoiler_text":"","visibility":"public","language":"ja","uri":"http://localhost:3000/users/mastodonpy_test/statuses/100148044136641620","content":"\u003cp\u003eToot!\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test/100148044136641620","reblogs_count":0,"favourites_count":0,"favourited":false,"reblogged":false,"muted":false,"pinned":false,"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"1234567890123456","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"created_at":"2018-05-07T00:38:05.405Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","avatar_static":"http://localhost:3000/system/accounts/avatars/123/456/789/012/345/original/mastodonpyupload_.jpe","header":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","header_static":"http://localhost:3000/system/accounts/headers/123/456/789/012/345/original/mastodonpyupload_.jpe","followers_count":0,"following_count":0,"statuses_count":5},"media_attachments":[],"mentions":[],"tags":[],"emojis":[]}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"de530492b63d03f8014765dfefb58aec"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [e25b5197-5dbc-4081-af76-613189ee5ce2] + X-Runtime: ['0.197095'] + X-XSS-Protection: [1; mode=block] + content-length: ['1399'] + 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.9.1] + method: DELETE + uri: http://localhost:3000/api/v1/statuses/100148044136641620 + response: + body: {string: '{}'} + headers: + Cache-Control: ['max-age=0, private, must-revalidate'] + Content-Type: [application/json; charset=utf-8] + ETag: [W/"8a3f21770b7f7baf86839a319201f71c"] + Transfer-Encoding: [chunked] + Vary: ['Accept-Encoding, Origin'] + X-Content-Type-Options: [nosniff] + X-Frame-Options: [SAMEORIGIN] + X-Request-Id: [829c8268-0b7f-4495-a9bc-6326c73399b3] + X-Runtime: ['0.134719'] + X-XSS-Protection: [1; mode=block] + content-length: ['2'] + status: {code: 200, message: OK} +version: 1 diff --git a/tests/conftest.py b/tests/conftest.py index a1dc161..b472eed 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,7 +23,6 @@ def api_low_version(): def api2(): return _api(access_token='__MASTODON_PY_TEST_ACCESS_TOKEN_2') - @pytest.fixture def api_anonymous(): return _api(access_token=None) @@ -34,6 +33,11 @@ def status(api): yield _status api.status_delete(_status['id']) +@pytest.fixture() +def status2(api): + _status = api.status_post('Toot, too!') + yield _status + api.status_delete(_status['id']) @pytest.fixture() def vcr_config(): diff --git a/tests/test_account.py b/tests/test_account.py index 2716ad1..3befdd5 100644 --- a/tests/test_account.py +++ b/tests/test_account.py @@ -112,3 +112,13 @@ def test_account_update_credentials_no_avatar(api): header = image, header_mime_type = "image/jpeg") assert account + +@pytest.mark.vcr() +def test_account_pinned(status, status2, api): + try: + status = api.status_pin(status['id']) + pinned = api.account_statuses(api.account_verify_credentials(), pinned = True) + assert status in pinned + assert not status2 in pinned + finally: + api.status_unpin(status['id']) \ No newline at end of file diff --git a/tests/test_constructor.py b/tests/test_constructor.py index 950845a..1512939 100644 --- a/tests/test_constructor.py +++ b/tests/test_constructor.py @@ -38,4 +38,6 @@ def test_verify_version(api): assert api.verify_minimum_version("2.4.3") == False assert api.verify_minimum_version("3.3.3") == False assert api.verify_minimum_version("1.0.0") == True - \ No newline at end of file + +def test_supported_version(api): + assert Mastodon.get_supported_version() \ No newline at end of file diff --git a/tests/test_instance.py b/tests/test_instance.py index 199e654..0eebc57 100644 --- a/tests/test_instance.py +++ b/tests/test_instance.py @@ -31,4 +31,4 @@ def test_low_version(api_low_version): @pytest.mark.vcr() def test_emoji(api): - assert len(api.custom_emojis()) == 0 \ No newline at end of file + assert len(api.custom_emojis()) == 0 diff --git a/tests/test_status.py b/tests/test_status.py index 95390b3..d36c000 100644 --- a/tests/test_status.py +++ b/tests/test_status.py @@ -104,3 +104,11 @@ def test_status_mute_unmute(status, api): status = api.status_unmute(status['id']) assert not status['muted'] + +@pytest.mark.vcr() +def test_status_pin_unpin(status, api): + status = api.status_pin(status['id']) + assert status['pinned'] + + status = api.status_unpin(status['id']) + assert not status['pinned'] -- cgit v1.2.3