From 3ed1cf73999ceef24ea3bf8395855bdde3876573 Mon Sep 17 00:00:00 2001 From: halcy Date: Thu, 17 Nov 2022 20:34:10 +0200 Subject: add another test for scheduled statuses --- tests/cassettes/test_scheduled_status.yaml | 263 +++++++++++++++++++++++++---- tests/test_status.py | 9 + 2 files changed, 240 insertions(+), 32 deletions(-) (limited to 'tests') diff --git a/tests/cassettes/test_scheduled_status.yaml b/tests/cassettes/test_scheduled_status.yaml index cc8d9f7..9fbf6f2 100644 --- a/tests/cassettes/test_scheduled_status.yaml +++ b/tests/cassettes/test_scheduled_status.yaml @@ -20,7 +20,7 @@ interactions: uri: http://localhost:3000/api/v1/statuses response: body: - string: '{"id":"1","scheduled_at":"4000-01-01T14:33:14.000Z","params":{"text":"please + string: '{"id":"3","scheduled_at":"4000-01-01T14:33:14.000Z","params":{"text":"please ensure adequate headroom","media_ids":null,"sensitive":null,"spoiler_text":null,"visibility":null,"language":null,"scheduled_at":null,"poll":null,"idempotency":null,"with_rate_limit":false,"in_reply_to_id":null,"application_id":1234567890123456},"media_attachments":[]}' headers: Cache-Control: @@ -28,7 +28,7 @@ interactions: Content-Security-Policy: - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; - style-src ''self'' http://localhost:3000 ''nonce-9Khj7VrlQPWC6+6XGyJtvw==''; + style-src ''self'' http://localhost:3000 ''nonce-8MI0hLsUyrzDc4kIn3QyMg==''; media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 @@ -38,7 +38,7 @@ interactions: Content-Type: - application/json; charset=utf-8 ETag: - - W/"62aba979b85ba000abf937b323f7b03c" + - W/"e650d49830a41555fedcb7fb33b1142c" Referrer-Policy: - strict-origin-when-cross-origin Transfer-Encoding: @@ -56,13 +56,13 @@ interactions: X-RateLimit-Limit: - '300' X-RateLimit-Remaining: - - '199' + - '300' X-RateLimit-Reset: - - '2022-11-13T18:00:00.559425Z' + - '2022-11-17T21:00:00.569037Z' X-Request-Id: - - b438b531-0910-4476-8082-c914ee57f94d + - 1f7204a9-6c93-444a-bc27-87fd8949027e X-Runtime: - - '0.025516' + - '0.229002' X-XSS-Protection: - 1; mode=block status: @@ -86,10 +86,10 @@ interactions: User-Agent: - tests/v311 method: PUT - uri: http://localhost:3000/api/v1/scheduled_statuses/1 + uri: http://localhost:3000/api/v1/scheduled_statuses/3 response: body: - string: '{"id":"1","scheduled_at":"4000-01-01T14:23:14.000Z","params":{"poll":null,"text":"please + string: '{"id":"3","scheduled_at":"4000-01-01T14:23:14.000Z","params":{"poll":null,"text":"please ensure adequate headroom","language":null,"media_ids":null,"sensitive":null,"visibility":null,"idempotency":null,"scheduled_at":null,"spoiler_text":null,"application_id":1234567890123456,"in_reply_to_id":null,"with_rate_limit":false},"media_attachments":[]}' headers: Cache-Control: @@ -97,7 +97,7 @@ interactions: Content-Security-Policy: - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; - style-src ''self'' http://localhost:3000 ''nonce-b1WRhJZBR6xY4fI8JL6Vzw==''; + style-src ''self'' http://localhost:3000 ''nonce-dqsjmaaupc42lzB9CQahdw==''; media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 @@ -107,7 +107,7 @@ interactions: Content-Type: - application/json; charset=utf-8 ETag: - - W/"b266e2e7938c824bcc1ec759216487c1" + - W/"c23cf5fde7455d325c6b924266e2e877" Referrer-Policy: - strict-origin-when-cross-origin Transfer-Encoding: @@ -123,9 +123,9 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - a221f9bf-8fde-46fb-9aae-01b673af75a0 + - 45459a5d-1994-4eeb-8551-f1df97d9530b X-Runtime: - - '0.015826' + - '0.016216' X-XSS-Protection: - 1; mode=block status: @@ -148,7 +148,7 @@ interactions: uri: http://localhost:3000/api/v1/scheduled_statuses response: body: - string: '[{"id":"1","scheduled_at":"4000-01-01T14:23:14.000Z","params":{"poll":null,"text":"please + string: '[{"id":"3","scheduled_at":"4000-01-01T14:23:14.000Z","params":{"poll":null,"text":"please ensure adequate headroom","language":null,"media_ids":null,"sensitive":null,"visibility":null,"idempotency":null,"scheduled_at":null,"spoiler_text":null,"application_id":1234567890123456,"in_reply_to_id":null,"with_rate_limit":false},"media_attachments":[]}]' headers: Cache-Control: @@ -156,7 +156,7 @@ interactions: Content-Security-Policy: - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; - style-src ''self'' http://localhost:3000 ''nonce-3zZn0JxSna76R9OrTIYyXA==''; + style-src ''self'' http://localhost:3000 ''nonce-ogS9JdJ7yVcKGhdGJ4ohvQ==''; media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 @@ -166,9 +166,9 @@ interactions: Content-Type: - application/json; charset=utf-8 ETag: - - W/"eca4f34f345a42498cb5eeee0a07578e" + - W/"4695a11bc3761f561fbe599c1fa67707" Link: - - ; rel="prev" + - ; rel="prev" Referrer-Policy: - strict-origin-when-cross-origin Transfer-Encoding: @@ -184,9 +184,9 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - 5fe0b173-26f6-46ec-817c-ba3378cdaa5a + - 05eec4ca-e7d5-4329-a6e2-d2c55ec462a7 X-Runtime: - - '0.009099' + - '0.009847' X-XSS-Protection: - 1; mode=block status: @@ -206,10 +206,10 @@ interactions: User-Agent: - tests/v311 method: GET - uri: http://localhost:3000/api/v1/scheduled_statuses/1 + uri: http://localhost:3000/api/v1/scheduled_statuses/3 response: body: - string: '{"id":"1","scheduled_at":"4000-01-01T14:23:14.000Z","params":{"poll":null,"text":"please + string: '{"id":"3","scheduled_at":"4000-01-01T14:23:14.000Z","params":{"poll":null,"text":"please ensure adequate headroom","language":null,"media_ids":null,"sensitive":null,"visibility":null,"idempotency":null,"scheduled_at":null,"spoiler_text":null,"application_id":1234567890123456,"in_reply_to_id":null,"with_rate_limit":false},"media_attachments":[]}' headers: Cache-Control: @@ -217,7 +217,7 @@ interactions: Content-Security-Policy: - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; - style-src ''self'' http://localhost:3000 ''nonce-um8Lzyinju91b01d44rNCw==''; + style-src ''self'' http://localhost:3000 ''nonce-101mCoCwPrjnwSQ1RVvVkw==''; media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 @@ -227,7 +227,7 @@ interactions: Content-Type: - application/json; charset=utf-8 ETag: - - W/"b266e2e7938c824bcc1ec759216487c1" + - W/"c23cf5fde7455d325c6b924266e2e877" Referrer-Policy: - strict-origin-when-cross-origin Transfer-Encoding: @@ -243,9 +243,9 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - f665cb8d-702c-4b7e-acab-6096e2089e5e + - 7ae5d245-26f5-4169-ad0a-5857f2ae1e26 X-Runtime: - - '0.008556' + - '0.008526' X-XSS-Protection: - 1; mode=block status: @@ -267,7 +267,7 @@ interactions: User-Agent: - tests/v311 method: DELETE - uri: http://localhost:3000/api/v1/scheduled_statuses/1 + uri: http://localhost:3000/api/v1/scheduled_statuses/3 response: body: string: '{}' @@ -277,7 +277,7 @@ interactions: Content-Security-Policy: - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; - style-src ''self'' http://localhost:3000 ''nonce-u2m/JaLpujzcMslVCPV/VA==''; + style-src ''self'' http://localhost:3000 ''nonce-vq3gSI3BXir3TR5GiD2HRA==''; media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 @@ -303,9 +303,208 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - 06dc8604-db6e-4e15-a560-17688a61efa3 + - 43ad9ed4-979f-4fcd-8de1-a08017bf5101 + X-Runtime: + - '0.012787' + X-XSS-Protection: + - 1; mode=block + 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: + - tests/v311 + method: GET + uri: http://localhost:3000/api/v1/scheduled_statuses + response: + body: + string: '[]' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src + ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; + style-src ''self'' http://localhost:3000 ''nonce-iUJq9NaSxMW8Tl46vhzO0g==''; + media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' + https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' + data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 + ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' + ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; + worker-src ''self'' blob: http://localhost:3000' + Content-Type: + - application/json; charset=utf-8 + ETag: + - W/"4f53cda18c2baa0c0354bb5f9a3ecbe5" + Referrer-Policy: + - strict-origin-when-cross-origin + Transfer-Encoding: + - chunked + Vary: + - Accept, Origin + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - a280af2d-3f06-43e5-a7fd-81ee15ba423d + X-Runtime: + - '0.007606' + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: status=please+ensure+adequate+headroom&scheduled_at=2022-11-17T18%3A33%3A45%2B00%3A00 + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Authorization: + - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN + Connection: + - keep-alive + Content-Length: + - '85' + Content-Type: + - application/x-www-form-urlencoded + User-Agent: + - tests/v311 + method: POST + uri: http://localhost:3000/api/v1/statuses + response: + body: + string: '{"id":"109360579914087110","created_at":"2022-11-17T18:33:40.663Z","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/109360579914087110","url":"http://localhost:3000/@mastodonpy_test/109360579914087110","replies_count":0,"reblogs_count":0,"favourites_count":0,"edited_at":null,"favourited":false,"reblogged":false,"muted":false,"bookmarked":false,"pinned":false,"content":"\u003cp\u003eplease + ensure adequate headroom\u003c/p\u003e","filtered":[],"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"109337440686176140","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"bot":false,"discoverable":null,"group":false,"created_at":"2022-11-13T00:00:00.000Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/109/337/440/686/176/140/original/d6cd9a5a5e65da30.jpg","avatar_static":"http://localhost:3000/system/accounts/avatars/109/337/440/686/176/140/original/d6cd9a5a5e65da30.jpg","header":"http://localhost:3000/system/accounts/headers/109/337/440/686/176/140/original/2b7760a42692fbde.jpg","header_static":"http://localhost:3000/system/accounts/headers/109/337/440/686/176/140/original/2b7760a42692fbde.jpg","followers_count":0,"following_count":0,"statuses_count":4,"last_status_at":"2022-11-17","noindex":false,"emojis":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src + ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; + style-src ''self'' http://localhost:3000 ''nonce-2aLo0w9hlVj9xfPOBdEXsg==''; + media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' + https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' + data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 + ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' + ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; + worker-src ''self'' blob: http://localhost:3000' + Content-Type: + - application/json; charset=utf-8 + ETag: + - W/"fb00e7f8059ab81e322aa084d8875cb9" + Referrer-Policy: + - strict-origin-when-cross-origin + Transfer-Encoding: + - chunked + Vary: + - Accept, Origin + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-RateLimit-Limit: + - '300' + X-RateLimit-Remaining: + - '299' + X-RateLimit-Reset: + - '2022-11-17T21:00:00.736121Z' + X-Request-Id: + - 2b9fa644-dc09-489c-9381-eec41867cbe9 + X-Runtime: + - '0.085861' + X-XSS-Protection: + - 1; mode=block + 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: + - tests/v311 + method: GET + uri: http://localhost:3000/api/v1/timelines/home + response: + body: + string: '[{"id":"109360579914087110","created_at":"2022-11-17T18:33:40.663Z","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/109360579914087110","url":"http://localhost:3000/@mastodonpy_test/109360579914087110","replies_count":0,"reblogs_count":0,"favourites_count":0,"edited_at":null,"favourited":false,"reblogged":false,"muted":false,"bookmarked":false,"pinned":false,"content":"\u003cp\u003eplease + ensure adequate headroom\u003c/p\u003e","filtered":[],"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"109337440686176140","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"bot":false,"discoverable":null,"group":false,"created_at":"2022-11-13T00:00:00.000Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/109/337/440/686/176/140/original/d6cd9a5a5e65da30.jpg","avatar_static":"http://localhost:3000/system/accounts/avatars/109/337/440/686/176/140/original/d6cd9a5a5e65da30.jpg","header":"http://localhost:3000/system/accounts/headers/109/337/440/686/176/140/original/2b7760a42692fbde.jpg","header_static":"http://localhost:3000/system/accounts/headers/109/337/440/686/176/140/original/2b7760a42692fbde.jpg","followers_count":0,"following_count":0,"statuses_count":4,"last_status_at":"2022-11-17","noindex":false,"emojis":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null},{"id":"109337450437842705","created_at":"2022-11-13T16:31:32.863Z","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/109337450437842705","url":"http://localhost:3000/@mastodonpy_test/109337450437842705","replies_count":0,"reblogs_count":0,"favourites_count":0,"edited_at":null,"favourited":false,"reblogged":false,"muted":false,"bookmarked":false,"pinned":false,"content":"\u003cp\u003eit\u0026#39;s + cool guy\u003c/p\u003e","filtered":[],"reblog":null,"application":{"name":"Mastodon.py + test suite","website":null},"account":{"id":"109337440686176140","username":"mastodonpy_test","acct":"mastodonpy_test","display_name":"John + Lennon","locked":true,"bot":false,"discoverable":null,"group":false,"created_at":"2022-11-13T00:00:00.000Z","note":"\u003cp\u003eI + walk funny\u003c/p\u003e","url":"http://localhost:3000/@mastodonpy_test","avatar":"http://localhost:3000/system/accounts/avatars/109/337/440/686/176/140/original/d6cd9a5a5e65da30.jpg","avatar_static":"http://localhost:3000/system/accounts/avatars/109/337/440/686/176/140/original/d6cd9a5a5e65da30.jpg","header":"http://localhost:3000/system/accounts/headers/109/337/440/686/176/140/original/2b7760a42692fbde.jpg","header_static":"http://localhost:3000/system/accounts/headers/109/337/440/686/176/140/original/2b7760a42692fbde.jpg","followers_count":0,"following_count":0,"statuses_count":4,"last_status_at":"2022-11-17","noindex":false,"emojis":[],"fields":[{"name":"bread","value":"toasty.","verified_at":null},{"name":"lasagna","value":"no!!!","verified_at":null}]},"media_attachments":[],"mentions":[],"tags":[],"emojis":[],"card":null,"poll":null}]' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src + ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; + style-src ''self'' http://localhost:3000 ''nonce-faRlQe20PGT5pFs0kdlAQg==''; + media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' + https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' + data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 + ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' + ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; + worker-src ''self'' blob: http://localhost:3000' + Content-Type: + - application/json; charset=utf-8 + ETag: + - W/"200de3a5f7d0d15a5a008600dee66fb6" + Link: + - ; rel="next", + ; rel="prev" + Referrer-Policy: + - strict-origin-when-cross-origin + Transfer-Encoding: + - chunked + Vary: + - Accept, Origin + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - 91f6a07e-a66d-4800-aaf2-79cbb7fc3486 X-Runtime: - - '0.010733' + - '0.048140' X-XSS-Protection: - 1; mode=block status: @@ -335,7 +534,7 @@ interactions: Content-Security-Policy: - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; - style-src ''self'' http://localhost:3000 ''nonce-tzXPiKt+KZVbunrAM7upNg==''; + style-src ''self'' http://localhost:3000 ''nonce-QHs3ujVPRmUwAFyI/3XtxA==''; media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 @@ -361,9 +560,9 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - 87e716bb-2b09-47f3-b670-8247bc742094 + - 3b1af585-179b-467a-9f0d-5d86b3399547 X-Runtime: - - '0.007378' + - '0.008452' X-XSS-Protection: - 1; mode=block status: diff --git a/tests/test_status.py b/tests/test_status.py index 764cd24..91b07fb 100644 --- a/tests/test_status.py +++ b/tests/test_status.py @@ -3,6 +3,7 @@ from mastodon.Mastodon import MastodonAPIError, MastodonNotFoundError import datetime import pytz import vcr +import time @pytest.mark.vcr() def test_status(status, api): @@ -170,3 +171,11 @@ def test_scheduled_status(api): api.scheduled_status_delete(scheduled_toot_2) scheduled_toot_list_2 = api.scheduled_statuses() assert not scheduled_toot_2.id in map(lambda x: x.id, scheduled_toot_list_2) + + the_very_immediate_future = datetime.datetime.now() + datetime.timedelta(seconds=5) + scheduled_toot_4 = api.status_post("please ensure adequate headroom", scheduled_at=the_very_immediate_future) + time.sleep(15) + statuses = api.timeline_home() + scheduled_toot_list_3 = api.scheduled_statuses() + assert scheduled_toot_4.id in map(lambda x: x.id, statuses) + assert not scheduled_toot_4.id in map(lambda x: x.id, scheduled_toot_list_3) -- cgit v1.2.3