]> littlesong.place Git - littlesongplace.git/commitdiff
Fix audio uploader bug
authorChris Fulljames <christianfulljames@gmail.com>
Sat, 8 Feb 2025 21:59:07 +0000 (16:59 -0500)
committerChris Fulljames <christianfulljames@gmail.com>
Sat, 8 Feb 2025 21:59:07 +0000 (16:59 -0500)
main.py
test/test_offline.py

diff --git a/main.py b/main.py
index 415b194e8f13e5f7c3214f4f37c63d3eceb976a2..fbd61fc0f9c5dcb4cabeac88fc89fc305ee2f4c2 100644 (file)
--- 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"]
index 18ddce8b767e58fd201378f73fd3e66d0aca81b7..34fd7d8412af6996423e34f4bc191ebe16ce93ff 100644 (file)
@@ -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",