Three-level end-to-end suite, all deterministic (no retries, no sleeps, no unmocked network): - tests/e2e/api (209 tests): every route in clipwright/api/app.py + free_tools — health/config, uploads, process submit matrix + worker/webhook/ auto-retry/resume, status/source/download-all, edit/effects, transcript/EDL/ rerender, scenes/reframe, subtitle, hook, Postiz, thumbnails, free tools, and the security/path guards. - tests/e2e/pipeline (136 tests): every stage with real ffmpeg and stubbed Gemini/yt-dlp/ASR/ML — download, transcribe, scene detect, selection, layout, reframe/render, subtitles, hooks, watermark, thumbnails, plus the real CLI full pipeline via stub_env. - dashboard/e2e (19 Playwright specs): route-interception state machine covering every dashboard flow; one real-backend spec left test.fixme. - Foundation: tests/e2e/conftest.py (state isolation, no-network guard, ffmpeg media factory, disk-seeded jobs), FakePopen worker harness, child-process stub_env, architecture-consistent fixtures. - CI: unit + backend-e2e + dashboard-e2e jobs in the python+node container; ffmpeg + Playwright installed in-job; no setup-node/cache (act runner). Verified: unit 790 passed; API E2E 209 passed; pipeline E2E 136 passed; Playwright 19 passed / 1 skipped.
69 lines
2 KiB
Python
69 lines
2 KiB
Python
"""Pipeline E2E fixtures.
|
|
|
|
The tests here run the REAL CLI (``python -m clipwright.pipeline.main``) with
|
|
real ffmpeg, but the child interpreter is started with ``stub_env`` on
|
|
``PYTHONPATH``. ``stub_env/sitecustomize.py`` swaps the ML and network edges
|
|
(ultralytics/mediapipe, ASR, Gemini) for deterministic fakes, so no model is
|
|
downloaded and no request leaves the process. Mark ML-backed variants with
|
|
``pytest.mark.ml``; those run against ``requirements-ml-e2e.txt`` instead.
|
|
"""
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
pytestmark = pytest.mark.pipeline
|
|
|
|
REPO_ROOT = Path(__file__).resolve().parents[3]
|
|
STUB_ENV = Path(__file__).resolve().parent / "stub_env"
|
|
|
|
|
|
@pytest.fixture(scope="session")
|
|
def stub_env_dir():
|
|
"""Directory holding ``sitecustomize.py`` for the pipeline child."""
|
|
assert (STUB_ENV / "sitecustomize.py").is_file()
|
|
return STUB_ENV
|
|
|
|
|
|
@pytest.fixture
|
|
def pipeline_env(stub_env_dir, tmp_path):
|
|
"""Environment for a pipeline subprocess: stub env on PYTHONPATH, no LLM."""
|
|
env = dict(os.environ)
|
|
env.pop("LLM_BASE_URL", None)
|
|
env.pop("LLM_MODEL", None)
|
|
env["GEMINI_API_KEY"] = "stub-gemini-key"
|
|
env["PYTHONPATH"] = os.pathsep.join(
|
|
[str(stub_env_dir), str(REPO_ROOT), env.get("PYTHONPATH", "")]
|
|
).strip(os.pathsep)
|
|
env["PYTHONHASHSEED"] = "0"
|
|
env["TZ"] = "UTC"
|
|
# Keep output inside the test's tmp tree unless the caller overrides it.
|
|
env.setdefault("TRANSCRIBE_BACKEND", "whisper")
|
|
return env
|
|
|
|
|
|
@pytest.fixture
|
|
def run_pipeline(pipeline_env):
|
|
"""Run the real CLI; returns the CompletedProcess.
|
|
|
|
Usage: ``run_pipeline(media.six, "-o", str(out))``.
|
|
"""
|
|
|
|
def _run(input_path, *extra, timeout=180):
|
|
cmd = [
|
|
sys.executable, "-u", "-m", "clipwright.pipeline.main",
|
|
"-i", str(input_path), *extra,
|
|
]
|
|
return subprocess.run(
|
|
cmd,
|
|
cwd=str(REPO_ROOT),
|
|
env=pipeline_env,
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=timeout,
|
|
)
|
|
|
|
return _run
|