nwe files
some files
This commit is contained in:
7
testing/pyproject.toml
Normal file
7
testing/pyproject.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
[tool.pytest.ini_options]
|
||||
testpaths = ["tests"]
|
||||
addopts = "-ra"
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 100
|
||||
target-version = "py310"
|
||||
78
testing/test_sanity.py
Normal file
78
testing/test_sanity.py
Normal file
@@ -0,0 +1,78 @@
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
def test_ffmpeg_exists_or_skip():
|
||||
if shutil.which("ffmpeg") is None:
|
||||
pytest.skip("ffmpeg not found in PATH (required for rendering).")
|
||||
p = subprocess.run(["ffmpeg", "-version"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
assert p.returncode == 0
|
||||
|
||||
|
||||
def test_selection_parsing_logic():
|
||||
# Minimal expectation for selection parsing behavior
|
||||
def parse(selection: str, n: int):
|
||||
s = selection.strip().lower()
|
||||
if s in {"all", "auto"}:
|
||||
return list(range(n))
|
||||
out = []
|
||||
for part in [p.strip() for p in s.split(",") if p.strip()]:
|
||||
if "-" in part:
|
||||
a, b = part.split("-", 1)
|
||||
a_i = int(a) - 1
|
||||
b_i = int(b) - 1
|
||||
if a_i > b_i:
|
||||
a_i, b_i = b_i, a_i
|
||||
out.extend(list(range(a_i, b_i + 1)))
|
||||
else:
|
||||
out.append(int(part) - 1)
|
||||
# unique + clamp
|
||||
seen = set()
|
||||
filtered = []
|
||||
for i in out:
|
||||
if 0 <= i < n and i not in seen:
|
||||
seen.add(i)
|
||||
filtered.append(i)
|
||||
return filtered
|
||||
|
||||
assert parse("all", 5) == [0, 1, 2, 3, 4]
|
||||
assert parse("auto", 3) == [0, 1, 2]
|
||||
assert parse("1,3,5", 5) == [0, 2, 4]
|
||||
assert parse("1-3", 10) == [0, 1, 2]
|
||||
assert parse("3-1", 10) == [0, 1, 2]
|
||||
assert parse("1-2,2-3", 10) == [0, 1, 2]
|
||||
|
||||
|
||||
def test_example_report_schema_if_present():
|
||||
# If the example JSON exists in repo root, validate basic schema.
|
||||
root = Path(".").resolve()
|
||||
ex = root / "example_teaser_report.json"
|
||||
if not ex.exists():
|
||||
pytest.skip("example_teaser_report.json not present in this environment.")
|
||||
data = json.loads(ex.read_text(encoding="utf-8"))
|
||||
assert "version" in data
|
||||
assert "settings" in data
|
||||
assert "tracks" in data
|
||||
assert isinstance(data["tracks"], list)
|
||||
|
||||
if data["tracks"]:
|
||||
t0 = data["tracks"][0]
|
||||
assert "filename" in t0
|
||||
if data.get("version") == "v3":
|
||||
assert "camelot" in t0
|
||||
|
||||
|
||||
def test_cli_wrapper_help_runs():
|
||||
# Ensure autoclip.py exists and prints help without crashing.
|
||||
root = Path(".").resolve()
|
||||
cli = root / "autoclip.py"
|
||||
if not cli.exists():
|
||||
pytest.skip("autoclip.py not present in this environment.")
|
||||
p = subprocess.run([sys.executable, str(cli), "--help"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||
assert p.returncode == 0
|
||||
assert "Auto Clip" in (p.stdout + p.stderr)
|
||||
Reference in New Issue
Block a user