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.
66 lines
2.1 KiB
Python
66 lines
2.1 KiB
Python
"""L1 API core: job status polling and source-video streaming."""
|
|
|
|
import pytest
|
|
|
|
pytestmark = pytest.mark.e2e
|
|
|
|
|
|
async def test_status_of_a_queued_job(client, app_state):
|
|
job_id = "job-status"
|
|
app_state.app.jobs[job_id] = {
|
|
"status": "queued",
|
|
"logs": app_state.app._TimedLog(["Job queued."]),
|
|
"result": None,
|
|
"partial": None,
|
|
}
|
|
app_state.app._enqueue_job(job_id)
|
|
|
|
resp = await client.get(f"/api/status/{job_id}")
|
|
assert resp.status_code == 200
|
|
body = resp.json()
|
|
assert body["status"] == "queued"
|
|
assert body["logs"] == ["Job queued."]
|
|
assert body["log_times"] is not None and len(body["log_times"]) == 1
|
|
assert body["queue"]["position"] == 1
|
|
assert body["result"] is None
|
|
|
|
|
|
async def test_status_of_a_disk_recovered_job(client, app_state, seeded_job):
|
|
job_id = seeded_job(job_id="job-status-disk", base="status", clips=1)
|
|
|
|
resp = await client.get(f"/api/status/{job_id}")
|
|
assert resp.status_code == 200
|
|
body = resp.json()
|
|
assert body["status"] == "completed"
|
|
assert body["result"]["clips"][0]["video_url"].endswith("/status_clip_1.mp4")
|
|
# A completed job is not on the queue.
|
|
assert body["queue"] is None
|
|
|
|
|
|
async def test_status_unknown_job_is_404(client):
|
|
resp = await client.get("/api/status/nobody-home")
|
|
assert resp.status_code == 404
|
|
assert resp.json()["detail"] == "Job not found"
|
|
|
|
|
|
async def test_source_url_returns_the_plain_path(client):
|
|
resp = await client.get("/api/source-url/any-job")
|
|
assert resp.status_code == 200
|
|
assert resp.json() == {"url": "/api/source/any-job"}
|
|
|
|
|
|
async def test_source_without_a_file_is_404(client):
|
|
resp = await client.get("/api/source/nobody-home")
|
|
assert resp.status_code == 404
|
|
assert resp.json()["detail"] == "Source not found"
|
|
|
|
|
|
async def test_source_streams_an_upload(client, app_state):
|
|
job_id = "job-source"
|
|
payload = b"pretend this is a video"
|
|
(app_state.up / f"{job_id}_source.mp4").write_bytes(payload)
|
|
|
|
resp = await client.get(f"/api/source/{job_id}")
|
|
assert resp.status_code == 200
|
|
assert resp.content == payload
|
|
assert resp.headers["content-type"] == "video/mp4"
|