baseline: initial working version
This commit is contained in:
61
tests/test_main_cli.py
Normal file
61
tests/test_main_cli.py
Normal file
@@ -0,0 +1,61 @@
|
||||
"""Tests for CLI parser and translation config wiring."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
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"
|
||||
Reference in New Issue
Block a user