From fc9bd8c8d80ca123509e524b7ffc1a841a67f39f Mon Sep 17 00:00:00 2001 From: Palash Debnath <4178343+debpalash@users.noreply.github.com> Date: Thu, 10 Sep 2026 13:52:50 -0700 Subject: [PATCH] test(dub): import app modules at test time in the bot-check tests --- tests/test_yt_bot_check_2034.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/test_yt_bot_check_2034.py b/tests/test_yt_bot_check_2034.py index 42de57da..379ddcfd 100644 --- a/tests/test_yt_bot_check_2034.py +++ b/tests/test_yt_bot_check_2034.py @@ -5,8 +5,6 @@ which names CLI flags nobody using VoiceStudio can pass. The app's own answer is the Dub tab's cookies.txt import, so the failure gets its own class and hint, and it is never retried as a network blip or escalated like a 403. """ -from core.failure import _HINTS, classify -from services.dub_pipeline import _is_forbidden_download_error, _is_transient_download_error REPORTED = ( "download: ERROR: [youtube] TJAfLE39ZZ8: Sign in to confirm you\u2019re not a bot. " @@ -19,22 +17,30 @@ REPORTED = ( def test_the_reported_message_is_the_bot_check_class(): + from core.failure import classify + assert classify(REPORTED) == "VIDEO_DOWNLOAD_BOT_CHECK" # yt-dlp has shipped both apostrophes. assert classify(REPORTED.replace("\u2019", "'")) == "VIDEO_DOWNLOAD_BOT_CHECK" def test_the_hint_points_at_the_apps_own_cookie_import(): + from core.failure import _HINTS + hint = _HINTS["VIDEO_DOWNLOAD_BOT_CHECK"] assert "cookies.txt" in hint and "Dub" in hint assert "--cookies" not in hint def test_it_is_neither_retried_nor_escalated(): + from services.dub_pipeline import _is_forbidden_download_error, _is_transient_download_error + exc = RuntimeError(REPORTED) assert not _is_transient_download_error(exc) assert not _is_forbidden_download_error(exc) def test_a_plain_network_drop_is_still_the_network_class(): + from core.failure import classify + assert classify("Unable to download video: Connection reset by peer") == "VIDEO_DOWNLOAD_NETWORK"