From: Chris Fulljames Date: Sat, 1 Feb 2025 21:11:01 +0000 (-0500) Subject: Fix issue with tags being converted to lowercase X-Git-Url: https://littlesong.place/gitweb/?a=commitdiff_plain;h=4f07d1fd32a110e70c426e726bdc46e98a045a61;p=littlesongplace.git Fix issue with tags being converted to lowercase --- diff --git a/main.py b/main.py index 5fe0955..a8ff878 100644 --- a/main.py +++ b/main.py @@ -283,7 +283,7 @@ def update_song(): file = request.files["song"] title = request.form["title"] description = request.form["description"] - tags = [t.strip().lower() for t in request.form["tags"].split(",")] + tags = [t.strip() for t in request.form["tags"].split(",")] collaborators = [c.strip() for c in request.form["collabs"].split(",")] # Make sure song exists and the logged-in user owns it diff --git a/test/test_offline.py b/test/test_offline.py index 097a588..cc2f1e5 100644 --- a/test/test_offline.py +++ b/test/test_offline.py @@ -354,6 +354,26 @@ def test_update_song_other_users_song(client): response = client.post(f"/upload-song?songid=1", data=data) assert response.status_code == 401 +def test_uppercase_tags(client): + _create_user(client, "user", "password", login=True) + _test_upload_song(client, b"Success", tags="TAG1, tag2") + response = client.get("/users/user") + + # Both tag versions present + assert b"TAG1" in response.data + assert b"tag2" in response.data + + # Edit song + _test_upload_song(client, b"Success", tags="T1, t2", songid=1) + + # Uppercase tags still work + response = client.get("/users/user") + assert b"TAG1" not in response.data + assert b"T1" in response.data + + assert b"tag2" not in response.data + assert b"t2" in response.data + ################################################################################ # Delete Song ################################################################################