72 lines
2.0 KiB
Python
72 lines
2.0 KiB
Python
"""Tests for CLI parser and translation config wiring."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from src.audio_separation import DEFAULT_MIX_MODE
|
|
|
|
from main import _build_translation_config, build_parser
|
|
|
|
|
|
def test_parser_accepts_lmstudio_flags():
|
|
parser = build_parser()
|
|
|
|
args = parser.parse_args(
|
|
[
|
|
"https://youtube.com/watch?v=demo",
|
|
"--translation-backend",
|
|
"lmstudio",
|
|
"--lmstudio-base-url",
|
|
"http://localhost:1234/v1",
|
|
"--lmstudio-model",
|
|
"gemma-custom",
|
|
]
|
|
)
|
|
|
|
assert args.translation_backend == "lmstudio"
|
|
assert args.lmstudio_base_url == "http://localhost:1234/v1"
|
|
assert args.lmstudio_model == "gemma-custom"
|
|
|
|
|
|
def test_translation_config_prefers_cli_over_env(monkeypatch):
|
|
monkeypatch.setenv("LM_STUDIO_BASE_URL", "http://env-host:1234/v1")
|
|
monkeypatch.setenv("LM_STUDIO_MODEL", "env-model")
|
|
|
|
parser = build_parser()
|
|
args = parser.parse_args(
|
|
[
|
|
"https://youtube.com/watch?v=demo",
|
|
"--lmstudio-base-url",
|
|
"http://cli-host:1234/v1",
|
|
"--lmstudio-model",
|
|
"cli-model",
|
|
]
|
|
)
|
|
|
|
config = _build_translation_config(args)
|
|
|
|
assert config.base_url == "http://cli-host:1234/v1"
|
|
assert config.model == "cli-model"
|
|
|
|
|
|
def test_translation_config_uses_env_defaults(monkeypatch):
|
|
monkeypatch.setenv("LM_STUDIO_BASE_URL", "http://env-host:1234/v1")
|
|
monkeypatch.setenv("LM_STUDIO_MODEL", "env-model")
|
|
monkeypatch.setenv("LM_STUDIO_API_KEY", "env-key")
|
|
|
|
parser = build_parser()
|
|
args = parser.parse_args(["https://youtube.com/watch?v=demo"])
|
|
|
|
config = _build_translation_config(args)
|
|
|
|
assert config.base_url == "http://env-host:1234/v1"
|
|
assert config.model == "env-model"
|
|
assert config.api_key == "env-key"
|
|
|
|
|
|
def test_parser_defaults_to_instrumental_only_mix_mode():
|
|
parser = build_parser()
|
|
|
|
args = parser.parse_args(["https://youtube.com/watch?v=demo"])
|
|
|
|
assert args.mix_mode == DEFAULT_MIX_MODE
|