Files
youtube-auto-dub/tests/test_web_app.py
2026-05-22 19:56:46 +01:00

45 lines
1.5 KiB
Python

"""Tests for the Gradio web UI command adapter."""
from __future__ import annotations
import sys
from web_app import build_pipeline_command, create_app
def test_build_pipeline_command_uses_cli_parser_defaults():
command = build_pipeline_command({"url": "https://youtube.com/watch?v=demo"})
assert command[:3] == [sys.executable, command[1], "https://youtube.com/watch?v=demo"]
assert "--lang" in command
assert command[command.index("--lang") + 1] == "es"
assert "--mix-mode" in command
assert command[command.index("--mix-mode") + 1] == "instrumental-only"
def test_build_pipeline_command_accepts_optional_settings():
command = build_pipeline_command(
{
"url": "https://youtube.com/watch?v=demo",
"lang": "fr",
"browser": "chrome",
"whisper_model": "small",
"lmstudio_base_url": "http://localhost:1234/v1",
"lmstudio_model": "gemma-custom",
"gpu": "on",
}
)
assert command[command.index("--lang") + 1] == "fr"
assert command[command.index("--browser") + 1] == "chrome"
assert command[command.index("--whisper_model") + 1] == "small"
assert command[command.index("--lmstudio-base-url") + 1] == "http://localhost:1234/v1"
assert command[command.index("--lmstudio-model") + 1] == "gemma-custom"
assert "--gpu" in command
def test_create_app_builds_gradio_blocks():
app = create_app()
assert app.title == "Gradio YouTube Auto Dub"