From 4e230884e5c636777d0bee29e54a191b2039abfc Mon Sep 17 00:00:00 2001 From: halcy Date: Sun, 23 Apr 2023 20:50:23 +0300 Subject: [PATCH] Fix reconversion to str after path resolve --- mastodon/internals.py | 2 +- tests/cassettes/test_account_search.yaml | 130 +++++++---------------- 2 files changed, 42 insertions(+), 90 deletions(-) diff --git a/mastodon/internals.py b/mastodon/internals.py index 05485a6..ad54f54 100644 --- a/mastodon/internals.py +++ b/mastodon/internals.py @@ -627,7 +627,7 @@ class Mastodon(): media_file = str(media_file) if isinstance(media_file, str): try: # Explicitly resolve to canonical for robustness. This can and will fail if Path isn't available because python too old. - media_file = Path(media_file).resolve() + media_file = str(Path(media_file).resolve()) except: pass if isinstance(media_file, str) and os.path.isfile(media_file): diff --git a/tests/cassettes/test_account_search.yaml b/tests/cassettes/test_account_search.yaml index 286169b..a59a401 100644 --- a/tests/cassettes/test_account_search.yaml +++ b/tests/cassettes/test_account_search.yaml @@ -13,27 +13,19 @@ interactions: User-Agent: - tests/v311 method: GET - uri: http://localhost:3000/api/v1/accounts/search?q=admin&following=0 + uri: http://localhost:3000/api/v1/accounts/search?q=admin&following=0&resolve=0 response: body: - string: '[{"id":"109440137501589086","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2022-12-01T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"fields":[]},{"id":"109440137619167380","username":"admin2","acct":"admin2","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2022-12-01T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin2","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"fields":[]}]' + string: '[{"id":"110248832095206210","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2023-04-23T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"roles":[{"id":"3","name":"Owner","color":""}],"fields":[]},{"id":"110248832232646816","username":"admin2","acct":"admin2","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2023-04-23T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin2","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"roles":[{"id":"3","name":"Owner","color":""}],"fields":[]}]' headers: Cache-Control: - - no-store + - private, 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-3TX14a4nRM1CL8fV2nTtSA==''; - 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' + - default-src 'none'; frame-ancestors 'none'; form-action 'none' Content-Type: - application/json; charset=utf-8 ETag: - - W/"da6f23110852835a635c238b2bac8b76" + - W/"af5f2f56762bae5140ef1597349aa08c" Referrer-Policy: - strict-origin-when-cross-origin Transfer-Encoding: @@ -49,9 +41,9 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - a7a19609-1785-4b85-9c4f-68c933622a67 + - 72643b11-5c33-496e-8c9e-4ee80985b636 X-Runtime: - - '0.025905' + - '0.170843' X-XSS-Protection: - 1; mode=block status: @@ -75,27 +67,19 @@ interactions: User-Agent: - tests/v311 method: POST - uri: http://localhost:3000/api/v1/accounts/109440137501589086/follow + uri: http://localhost:3000/api/v1/accounts/110248832095206210/follow response: body: - string: '{"id":"109440137501589086","following":true,"showing_reblogs":true,"notifying":false,"languages":null,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false,"note":""}' + string: '{"id":"110248832095206210","following":true,"showing_reblogs":true,"notifying":false,"languages":null,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"requested_by":false,"domain_blocking":false,"endorsed":false,"note":""}' headers: Cache-Control: - - no-store + - private, 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-vy7uDmKjcR1TR4c+lysmjw==''; - 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' + - default-src 'none'; frame-ancestors 'none'; form-action 'none' Content-Type: - application/json; charset=utf-8 ETag: - - W/"a7521adf429fc1c54a67dc3198e1f911" + - W/"fb99ca7a603d191cb0c4f49568ec8993" Referrer-Policy: - strict-origin-when-cross-origin Transfer-Encoding: @@ -115,11 +99,11 @@ interactions: X-RateLimit-Remaining: - '399' X-RateLimit-Reset: - - '2022-12-02T00:00:00.740841Z' + - '2023-04-24T00:00:00.074078Z' X-Request-Id: - - 69052db2-dbe5-40db-a06c-dce459d86b8c + - a06b700b-c729-46fd-acea-0ac5444bce35 X-Runtime: - - '0.044179' + - '0.169897' X-XSS-Protection: - 1; mode=block status: @@ -139,27 +123,19 @@ interactions: User-Agent: - tests/v311 method: GET - uri: http://localhost:3000/api/v1/accounts/search?q=admin&following=1 + uri: http://localhost:3000/api/v1/accounts/search?q=admin&following=1&resolve=0 response: body: - string: '[{"id":"109440137501589086","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2022-12-01T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"fields":[]}]' + string: '[{"id":"110248832095206210","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2023-04-23T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":1,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"roles":[{"id":"3","name":"Owner","color":""}],"fields":[]}]' headers: Cache-Control: - - no-store + - private, 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-hCyWXhceDcgNNIOR4B4aSQ==''; - 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' + - default-src 'none'; frame-ancestors 'none'; form-action 'none' Content-Type: - application/json; charset=utf-8 ETag: - - W/"d5f0b4c5503f27c7de3d5491e947b64b" + - W/"717458afb6d13eac22f6c462e7874ff6" Referrer-Policy: - strict-origin-when-cross-origin Transfer-Encoding: @@ -175,9 +151,9 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - caa9fd80-08b3-4076-9b50-4b8712f119ed + - a6a519e0-0eb2-4295-8cb9-8eb651acc128 X-Runtime: - - '0.013136' + - '0.018187' X-XSS-Protection: - 1; mode=block status: @@ -199,27 +175,19 @@ interactions: User-Agent: - tests/v311 method: POST - uri: http://localhost:3000/api/v1/accounts/109440137501589086/unfollow + uri: http://localhost:3000/api/v1/accounts/110248832095206210/unfollow response: body: - string: '{"id":"109440137501589086","following":false,"showing_reblogs":false,"notifying":false,"languages":null,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"domain_blocking":false,"endorsed":false,"note":""}' + string: '{"id":"110248832095206210","following":false,"showing_reblogs":false,"notifying":false,"languages":null,"followed_by":false,"blocking":false,"blocked_by":false,"muting":false,"muting_notifications":false,"requested":false,"requested_by":false,"domain_blocking":false,"endorsed":false,"note":""}' headers: Cache-Control: - - no-store + - private, 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-K7rcIS5Jos9R1eDX/ipI3g==''; - 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' + - default-src 'none'; frame-ancestors 'none'; form-action 'none' Content-Type: - application/json; charset=utf-8 ETag: - - W/"19a1735290f397bc4442b5dc8508d01e" + - W/"a8ca34b852f96be5134e5c46c6af3ddf" Referrer-Policy: - strict-origin-when-cross-origin Transfer-Encoding: @@ -235,9 +203,9 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - d7059e7b-2f9b-4e1a-9903-26867294f17d + - c8018255-5419-4742-9a2a-2ddeb4c093a8 X-Runtime: - - '0.026451' + - '0.032950' X-XSS-Protection: - 1; mode=block status: @@ -257,23 +225,15 @@ interactions: User-Agent: - tests/v311 method: GET - uri: http://localhost:3000/api/v1/accounts/search?q=admin&following=1 + uri: http://localhost:3000/api/v1/accounts/search?q=admin&following=1&resolve=0 response: body: string: '[]' headers: Cache-Control: - - no-store + - private, 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-vSJP/3jgKcLGkEFAlGZeuA==''; - 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' + - default-src 'none'; frame-ancestors 'none'; form-action 'none' Content-Type: - application/json; charset=utf-8 ETag: @@ -293,9 +253,9 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - d75b0a10-c860-4c14-aff9-5285ccfca6d4 + - 5b71e595-f65b-4727-b825-9a0e1393fcbe X-Runtime: - - '0.010306' + - '0.011075' X-XSS-Protection: - 1; mode=block status: @@ -315,27 +275,19 @@ interactions: User-Agent: - tests/v311 method: GET - uri: http://localhost:3000/api/v1/accounts/search?q=admin&following=0 + uri: http://localhost:3000/api/v1/accounts/search?q=admin&following=0&resolve=0 response: body: - string: '[{"id":"109440137501589086","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2022-12-01T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"fields":[]},{"id":"109440137619167380","username":"admin2","acct":"admin2","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2022-12-01T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin2","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"fields":[]}]' + string: '[{"id":"110248832095206210","username":"admin","acct":"admin","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2023-04-23T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"roles":[{"id":"3","name":"Owner","color":""}],"fields":[]},{"id":"110248832232646816","username":"admin2","acct":"admin2","display_name":"","locked":false,"bot":false,"discoverable":null,"group":false,"created_at":"2023-04-23T00:00:00.000Z","note":"","url":"http://localhost:3000/@admin2","avatar":"http://localhost:3000/avatars/original/missing.png","avatar_static":"http://localhost:3000/avatars/original/missing.png","header":"http://localhost:3000/headers/original/missing.png","header_static":"http://localhost:3000/headers/original/missing.png","followers_count":0,"following_count":0,"statuses_count":0,"last_status_at":null,"noindex":false,"emojis":[],"roles":[{"id":"3","name":"Owner","color":""}],"fields":[]}]' headers: Cache-Control: - - no-store + - private, 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-3BQi3tnMcGK04MOA93cR7Q==''; - 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' + - default-src 'none'; frame-ancestors 'none'; form-action 'none' Content-Type: - application/json; charset=utf-8 ETag: - - W/"da6f23110852835a635c238b2bac8b76" + - W/"af5f2f56762bae5140ef1597349aa08c" Referrer-Policy: - strict-origin-when-cross-origin Transfer-Encoding: @@ -351,9 +303,9 @@ interactions: X-Permitted-Cross-Domain-Policies: - none X-Request-Id: - - 89b882e3-8cae-4e82-b065-e9ba32dce932 + - cfbf3265-476a-4247-abcd-391c761d5d3c X-Runtime: - - '0.018040' + - '0.022876' X-XSS-Protection: - 1; mode=block status: