From 14a286ef0d6ffb5e760efb9457051f6c4a2859fc Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Fri, 3 Mar 2023 08:57:34 +0100 Subject: [PATCH] Use v2 endpoint to upload media v1 is deprecated --- tests/test_console.py | 4 ++-- toot/api.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_console.py b/tests/test_console.py index 9c46b86..b860a6d 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -300,10 +300,10 @@ def test_upload(mock_post, capsys): console.run_command(app, user, 'upload', [__file__]) - mock_post.call_count == 1 + assert mock_post.call_count == 1 args, kwargs = http.post.call_args - assert args == (app, user, '/api/v1/media') + assert args == (app, user, '/api/v2/media') assert isinstance(kwargs['files']['file'], io.BufferedReader) out, err = capsys.readouterr() diff --git a/toot/api.py b/toot/api.py index 83a5c3f..29811da 100644 --- a/toot/api.py +++ b/toot/api.py @@ -348,7 +348,7 @@ def anon_tag_timeline_generator(instance, hashtag, local=False, limit=20): def upload_media(app, user, file, description=None): - return http.post(app, user, '/api/v1/media', + return http.post(app, user, '/api/v2/media', data={'description': description}, files={'file': file} ).json()