clipwright/tests/e2e/pipeline/conftest.py
pedro-bento 6911a2665c
All checks were successful
CI / unit (pull_request) Successful in 48s
CI / backend-e2e (pull_request) Successful in 1m17s
CI / dashboard-e2e (pull_request) Successful in 1m46s
chore: drop watermark feature, CLI, docs, design.md; consolidate requirements
- Remove the watermark feature end to end (watermarked.py, apply_watermark/
  mark_delivery/watermark_filter, WATERMARK env, assets/) and its tests; self-host
  delivery is now unconditionally clean.
- Delete the unused cli/ package and .github/workflows/publish-cli.yml.
- Delete docs/ (compliance) and design.md; drop the dangling references in the
  legal page and the design-token/ui comments.
- Consolidate requirements: requirements.txt (runtime) + requirements-test.txt
  (unit + E2E); remove requirements-e2e.txt and requirements-ml-e2e.txt and
  point both CI jobs at the single test file. Add libgl1 to the unit job
  (scenedetect -> opencv-python links libGL).

Verified in the CI container: unit 701 passed; API E2E 209; pipeline E2E 127;
Playwright 19 passed / 1 skipped.
2026-10-05 09:54:01 +01:00

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 need the heavy ML stack from ``requirements.txt``.
"""
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