2Tests for the CLI scripts.
5from pathlib import Path
7from subprocess import PIPE
9from chives import cli # noqa: F401
12class TestConvertSrtToVtt:
14 Tests for the `srt-to-vtt` command.
17 def test_no_args(self) -> None:
19 If you don't supply any arguments, you get an error.
21 proc = subprocess.Popen(["srt-to-vtt"], stdout=PIPE, stderr=PIPE, text=True)
22 stdout, stderr = proc.communicate(timeout=1)
24 assert proc.returncode == 1
26 assert stderr == "Usage: srt-to-vtt <SRT_PATH>...\n"
28 def test_multiple_args(self, tmp_path: Path) -> None:
30 If you supply multiple SRT paths, they all get converted to VTT.
32 srt_path1 = tmp_path / "example1.en.srt"
34 "1\n00:00:01,001 --> 00:00:10,010\nSomebody said the first thing\n"
37 srt_path2 = tmp_path / "example2.en.srt"
39 "1\n00:02:00,002 --> 00:20:00,020\nSomebody else said the second thing\n"
42 proc = subprocess.Popen(
43 ["srt-to-vtt", str(srt_path1), str(srt_path2)],
48 stdout, stderr = proc.communicate(timeout=1)
50 assert proc.returncode == 0
51 assert stdout == (f"{tmp_path}/example1.en.vtt\n{tmp_path}/example2.en.vtt\n")