-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add -q <search_query> command line argument (#511)
* Add -s <search_term> command line argument * add final newline * Format and lint * Update README * Update no results test to use random query --------- Co-authored-by: 7x11x13 <[email protected]>
- Loading branch information
1 parent
091596c
commit e06cc9c
Showing
3 changed files
with
80 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import os | ||
import secrets | ||
from pathlib import Path | ||
|
||
from tests.utils import assert_track, call_scdl_with_auth | ||
|
||
|
||
def test_search(tmp_path: Path) -> None: | ||
os.chdir(tmp_path) | ||
r = call_scdl_with_auth( | ||
"-s", | ||
"7x11x13-testing test track", | ||
"--name-format", | ||
"track", | ||
"--onlymp3", | ||
) | ||
assert r.returncode == 0 | ||
assert_track(tmp_path, "track.mp3") | ||
|
||
|
||
def test_search_no_results(tmp_path: Path) -> None: | ||
os.chdir(tmp_path) | ||
r = call_scdl_with_auth( | ||
"-s", | ||
f"this query should not return any results {secrets.token_hex(16)}", | ||
"--name-format", | ||
"track", | ||
"--onlymp3", | ||
) | ||
assert r.returncode == 1 | ||
assert "No results found for query" in r.stderr | ||
|
||
|
||
def test_search_playlist(tmp_path: Path) -> None: | ||
os.chdir(tmp_path) | ||
r = call_scdl_with_auth( | ||
"-s", | ||
"playlist1 7x11x13-testing", | ||
"--playlist-name-format", | ||
"{playlist[tracknumber]}_{title}", | ||
"--onlymp3", | ||
) | ||
assert r.returncode == 0 | ||
assert_track(tmp_path / "playlist1", "1_OK Bye.mp3", check_metadata=False) | ||
assert_track( | ||
tmp_path / "playlist1", | ||
"2_Wan Bushi - Eurodance Vibes (part 1+2+3).mp3", | ||
check_metadata=False, | ||
) |