From d20279fc9731ba11e70b1b2f2282ac77ee650210 Mon Sep 17 00:00:00 2001 From: 7x11x13 Date: Fri, 26 Jul 2024 13:39:44 -0400 Subject: [PATCH] Fix tests for pull requests --- tests/test_track.py | 7 +++++++ tests/utils.py | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_track.py b/tests/test_track.py index c7a6de6..aa60739 100644 --- a/tests/test_track.py +++ b/tests/test_track.py @@ -7,6 +7,7 @@ from tests.utils import assert_not_track, assert_track, call_scdl_with_auth +@pytest.mark.skipif(not os.getenv("AUTH_TOKEN"), reason="No auth token specified") def test_original_download(tmp_path: Path) -> None: os.chdir(tmp_path) r = call_scdl_with_auth( @@ -54,6 +55,7 @@ def test_mp3_to_stdout(tmp_path: Path) -> None: assert_track(tmp_path, "track.mp3") +@pytest.mark.skipif(not os.getenv("AUTH_TOKEN"), reason="No auth token specified") def test_flac_to_stdout(tmp_path: Path) -> None: os.chdir(tmp_path) r = call_scdl_with_auth( @@ -73,6 +75,7 @@ def test_flac_to_stdout(tmp_path: Path) -> None: assert_track(tmp_path, "track.flac", "copy", "saves", None) +@pytest.mark.skipif(not os.getenv("AUTH_TOKEN"), reason="No auth token specified") def test_flac(tmp_path: Path) -> None: os.chdir(tmp_path) r = call_scdl_with_auth( @@ -86,6 +89,7 @@ def test_flac(tmp_path: Path) -> None: assert_track(tmp_path, "track.flac", "copy", "saves", None) +@pytest.mark.skipif(not os.getenv("AUTH_TOKEN"), reason="No auth token specified") def test_m4a(tmp_path: Path) -> None: os.chdir(tmp_path) r = call_scdl_with_auth( @@ -163,6 +167,7 @@ def test_original_art(tmp_path: Path) -> None: assert_track(tmp_path, "track.mp3", expected_artwork_len=3409) +@pytest.mark.skipif(not os.getenv("AUTH_TOKEN"), reason="No auth token specified") def test_original_name(tmp_path: Path) -> None: os.chdir(tmp_path) r = call_scdl_with_auth( @@ -176,6 +181,7 @@ def test_original_name(tmp_path: Path) -> None: assert_track(tmp_path, "original.wav", check_metadata=False) +@pytest.mark.skipif(not os.getenv("AUTH_TOKEN"), reason="No auth token specified") def test_original_metadata(tmp_path: Path) -> None: os.chdir(tmp_path) r = call_scdl_with_auth( @@ -189,6 +195,7 @@ def test_original_metadata(tmp_path: Path) -> None: assert_track(tmp_path, "track.wav", "og title", "og artist", "og genre", 0) +@pytest.mark.skipif(not os.getenv("AUTH_TOKEN"), reason="No auth token specified") def test_force_metadata(tmp_path: Path) -> None: os.chdir(tmp_path) r = call_scdl_with_auth( diff --git a/tests/utils.py b/tests/utils.py index eaa5847..d4a5da4 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -13,8 +13,7 @@ def call_scdl_with_auth( *args: str, encoding: Optional[str] = "utf-8", ) -> subprocess.CompletedProcess: - auth_token = os.getenv("AUTH_TOKEN") - assert auth_token + auth_token = os.getenv("AUTH_TOKEN", "") args = ("scdl", *args, f"--auth-token={auth_token}", f"--client-id={client_id}") return subprocess.run( args,