Skip to content

Commit

Permalink
Test download archive and sync
Browse files Browse the repository at this point in the history
  • Loading branch information
7x11x13 committed Jun 24, 2024
1 parent 7f22f4b commit f5801c3
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/test_playlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
25 changes: 25 additions & 0 deletions tests/test_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f5801c3

Please sign in to comment.