From 70b186782b4984cfdda6a2cb9a124ccb993a98f9 Mon Sep 17 00:00:00 2001 From: Chris Fulljames Date: Sat, 8 Feb 2025 13:01:50 -0500 Subject: [PATCH] Use online tests for youtube since it thinks github server is a bot --- test/test_offline.py | 2 ++ test/test_online.py | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/test/test_offline.py b/test/test_offline.py index 9d25fdf..59af5b7 100644 --- a/test/test_offline.py +++ b/test/test_offline.py @@ -303,6 +303,7 @@ def test_upload_song_from_mp4(client): _create_user(client, "user", "password", login=True) _test_upload_song(client, b"Successfully uploaded 'song title'", filename="sample-4s.mp4") +@pytest.skip def test_upload_song_from_youtube(client): _create_user(client, "user", "password", login=True) data = { @@ -353,6 +354,7 @@ def test_update_song_success(client): with open("sample-6s.mp3", "rb") as expected_file: assert response.data == expected_file.read() +@pytest.skip def test_update_song_from_youtube(client): _create_user_and_song(client) data = { diff --git a/test/test_online.py b/test/test_online.py index 3347190..292c735 100644 --- a/test/test_online.py +++ b/test/test_online.py @@ -97,3 +97,20 @@ def test_comments_and_activity(s): songs = _get_song_list_from_page(response.text) assert not any(song["songid"] == songid for song in songs) +def test_upload_song_from_youtube(s): + _login(s, "user", "1234asdf!@#$") + + response = s.post( + url("/upload-song"), + data={"title": "yt-song", "description": "", "tags": "", "collabs": "", "song-url": "https://youtu.be/5e5Z6gZWiEs"}, + ) + response.raise_for_status() + songs = _get_song_list_from_page(response.text) + song = songs[0] + songid = song["songid"] + try: + assert song["title"] == "yt-song" + finally: + response = s.get(url(f"/delete-song/{songid}"), headers={"referer": "/users/user"}) + response.raise_for_status() + -- 2.39.5