From f5801c36fcf68ffc6d3461057c87be7a2797f07c Mon Sep 17 00:00:00 2001 From: 7x11x13 Date: Sun, 23 Jun 2024 20:42:06 -0400 Subject: [PATCH] Test download archive and sync --- tests/test_playlist.py | 36 ++++++++++++++++++++++++++++++++++++ tests/test_track.py | 25 +++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/tests/test_playlist.py b/tests/test_playlist.py index 6bd4dd5..6397685 100644 --- a/tests/test_playlist.py +++ b/tests/test_playlist.py @@ -128,3 +128,39 @@ def test_strict_playlist(tmp_path: Path): assert r.returncode == 1 assert_not_track(tmp_path / "test playlist", "1_testing - test track.mp3") assert_not_track(tmp_path / "test playlist", "2_test track 2.mp3") + + +def test_sync(tmp_path: Path): + os.chdir(tmp_path) + os.makedirs("test playlist") + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/7x11x13/wan-bushi-eurodance-vibes-part-123", + "--onlymp3", + "--name-format", + "{title}", + "--path", + "test playlist", + ) + assert r.returncode == 0 + assert_track( + tmp_path / "test playlist", + "Wan Bushi - Eurodance Vibes (part 1+2+3).mp3", + check_metadata=False, + ) + with open("archive.txt", "w", encoding="utf-8") as f: + f.writelines(["1032303631"]) + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/one-thousand-and-one/sets/test-playlist/s-ZSLfNrbPoXR", + "--playlist-name-format", + "{title}", + "--sync", + "archive.txt", + ) + assert r.returncode == 0 + assert_not_track( + tmp_path / "test playlist", "Wan Bushi - Eurodance Vibes (part 1+2+3).mp3" + ) + with open("archive.txt", "r") as f: + assert f.read().split() == ["1855267053", "1855318536"] diff --git a/tests/test_track.py b/tests/test_track.py index f3846fa..5c63333 100644 --- a/tests/test_track.py +++ b/tests/test_track.py @@ -271,3 +271,28 @@ def test_remove(tmp_path: Path): assert r.returncode == 0 assert_track(tmp_path, "track.wav", check_metadata=False) assert_not_track(tmp_path, "track.mp3") + + +def test_download_archive(tmp_path: Path): + os.chdir(tmp_path) + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/one-thousand-and-one/test-track", + "--name-format", + "track", + "--onlymp3", + "--download-archive=archive.txt", + ) + assert r.returncode == 0 + os.remove("track.mp3") + assert not os.path.exists("track.mp3") + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/one-thousand-and-one/test-track", + "--name-format", + "track", + "--onlymp3", + "--download-archive=archive.txt", + ) + assert r.returncode == 1 + assert "already exists" in r.stderr