"""Tests for the Guardio 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_index_renders_guardio_ui(): app = create_app() app.config.update(TESTING=True) response = app.test_client().get("/") assert response.status_code == 200 assert b"Guardio" in response.data