Add whisper remote backend and CLI
This commit is contained in:
11
cli/tests/conftest.py
Normal file
11
cli/tests/conftest.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SRC = ROOT / "src"
|
||||
|
||||
if str(SRC) not in sys.path:
|
||||
sys.path.insert(0, str(SRC))
|
||||
28
cli/tests/test_main.py
Normal file
28
cli/tests/test_main.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import os
|
||||
from argparse import Namespace
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from whisper_remote_cli import main
|
||||
|
||||
|
||||
def test_resolve_server_from_env(monkeypatch) -> None:
|
||||
monkeypatch.setenv("WHISPER_REMOTE", "http://localhost:8000/")
|
||||
assert main.resolve_server(Namespace(server=None)) == "http://localhost:8000"
|
||||
|
||||
|
||||
def test_resolve_server_requires_value(monkeypatch) -> None:
|
||||
monkeypatch.delenv("WHISPER_REMOTE", raising=False)
|
||||
with pytest.raises(SystemExit):
|
||||
main.resolve_server(Namespace(server=None))
|
||||
|
||||
|
||||
def test_infer_output_path_for_directory(tmp_path: Path) -> None:
|
||||
destination = main.infer_output_path(tmp_path, Path("clip.wav"), "srt")
|
||||
assert destination == tmp_path / "clip.srt"
|
||||
|
||||
|
||||
def test_infer_output_path_for_explicit_file(tmp_path: Path) -> None:
|
||||
destination = main.infer_output_path(tmp_path / "custom-name.txt", Path("clip.wav"), "txt")
|
||||
assert destination == tmp_path / "custom-name.txt"
|
||||
Reference in New Issue
Block a user