From c4a4166ffe8d506f37648bd29c5c886c8f257b48 Mon Sep 17 00:00:00 2001 From: Chris Fulljames Date: Sat, 8 Feb 2025 16:59:07 -0500 Subject: [PATCH] Fix audio uploader bug --- main.py | 4 ++-- test/test_offline.py | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/main.py b/main.py index 415b194..fbd61fc 100644 --- a/main.py +++ b/main.py @@ -328,7 +328,7 @@ def update_song(): except ValueError: abort(400) - file = request.files["song"] if "song" in request.files else None + file = request.files["song-file"] if "song-file" in request.files else None yt_url = request.form["song-url"] if "song-url" in request.form else None title = request.form["title"] description = request.form["description"] @@ -376,7 +376,7 @@ def update_song(): return error def create_song(): - file = request.files["song"] if "song" in request.files else None + file = request.files["song-file"] if "song-file" in request.files else None yt_url = request.form["song-url"] if "song-url" in request.form else None title = request.form["title"] description = request.form["description"] diff --git a/test/test_offline.py b/test/test_offline.py index 18ddce8..34fd7d8 100644 --- a/test/test_offline.py +++ b/test/test_offline.py @@ -239,7 +239,7 @@ def _test_upload_song(client, msg, error=False, songid=None, user="user", filena song_file = open(filename, "rb") data = { - "song": song_file, + "song-file": song_file, "title": "song title", "description": "song description", "tags": "tag", @@ -401,14 +401,13 @@ def test_update_song_collab_too_long(client): def test_update_song_invalid_mp3(client): _create_user_and_song(client) - song_file = open(__file__, "rb") - _test_upload_song(client, b"Invalid audio file", error=True, songid=1, song=song_file) + _test_upload_song(client, b"Invalid audio file", error=True, songid=1, filename=__file__) def test_update_song_invalid_song(client): _create_user_and_song(client) data = { - "song": open("sample-3s.mp3", "rb"), + "song-file": open("sample-3s.mp3", "rb"), "title": "song title", "description": "song description", "tags": "tag", @@ -422,7 +421,7 @@ def test_update_song_invalid_id(client): _create_user_and_song(client) data = { - "song": open("sample-3s.mp3", "rb"), + "song-file": open("sample-3s.mp3", "rb"), "title": "song title", "description": "song description", "tags": "tag", @@ -437,7 +436,7 @@ def test_update_song_other_users_song(client): _create_user(client, "user2", login=True) data = { - "song": open("sample-3s.mp3", "rb"), + "song-file": open("sample-3s.mp3", "rb"), "title": "song title", "description": "song description", "tags": "tag", -- 2.39.5