k9cli's picture
Flatten package contents to repo root
de01f6a verified
Raw History Blame Contribute Delete
1.4 kB
"""Tests for the CLI argument parser and speaker assignment."""
from __future__ import annotations
import pytest
from video_vec2wav2_tokenizer.cli.commands import build_parser
from video_vec2wav2_tokenizer.pipeline import assign_speaker
from video_vec2wav2_tokenizer.utils.config import Config
def test_parser_process() -> None:
parser = build_parser()
args = parser.parse_args(["process", "./videos", "--extract-features"])
assert args.command == "process"
assert args.input == "./videos"
assert args.extract_features is True
def test_parser_requires_command() -> None:
parser = build_parser()
with pytest.raises(SystemExit):
parser.parse_args([])
@pytest.mark.parametrize("command", ["transcribe", "segment", "features", "train"])
def test_parser_subcommands(command: str) -> None:
parser = build_parser()
args = parser.parse_args([command, "./input"])
assert args.command == command
def test_speaker_modes() -> None:
fixed = Config(speaker_mode="fixed", default_speaker="speaker_001")
assert assign_speaker(fixed, video_index=3, file_index=7) == "speaker_001"
per_video = Config(speaker_mode="per_video")
assert assign_speaker(per_video, video_index=3, file_index=7) == "speaker_003"
per_file = Config(speaker_mode="per_file")
assert assign_speaker(per_file, video_index=3, file_index=7) == "speaker_007"