clipwright/tests/test_restoring_static.py
pedro-bento 59e0db8c24 chore: remove dead code, unused assets, and the server-render chain
Backend:
- Drop unused imports/locals and zero-reference helpers (truncate_ip,
  in_split, GEMINI_PROMPT_TEMPLATE, legacy subtitles SRT path, dead paths)
- Remove unwired features (delete_uploaded, mark_ai_generated, unmark_job,
  compact_words, restoring_static restorer hook, gemini_worker __main__)
- Remove shelved panel_layout module + its flags/tests
- Remove the /api/render proxy + RENDER_SERVICE_URL

Frontend:
- Delete App.css, react.svg, vite.svg, agent screenshot, demo mp4s
- Remove dead exports (downloadBlobUrl, consent reopen machinery, dead zod
  schemas/CITED_STATS) and unused deps (@remotion/media-utils, zod)
- Drop the /render dev proxy; rewrite dashboard README

Repo/config:
- Delete render-service/ and top-level remotion/ (superseded by the
  dashboard's in-browser Remotion copy); drop the compose renderer service
- Delete docker-compose.e2e.local.yml and 4 unreferenced screenshots
- Prune .env.example dead keys, add GEMINI_API_KEY/MAX_CONCURRENT_JOBS
- Tighten .dockerignore/.gitignore; add dashboard lint to CI
- Fix stale compliance doc + README structure

Backend 709 passed / 18 skipped; dashboard lint+build green; compose valid.
2026-10-04 21:24:42 +01:00

43 lines
1.4 KiB
Python

"""/videos serving: StaticFiles that refuses non-deliverables via ``guard``,
keeping Range support. There is no restorer hook in this fork.
"""
import os
from starlette.applications import Starlette
from starlette.testclient import TestClient
from clipwright.api.restoring_static import RestoringStaticFiles
JOB = "cff3ad6c-c1e6-48e8-9a75-be74f39779c5"
def _app(tmp_path, guard=None):
app = Starlette()
app.mount("/videos", RestoringStaticFiles(directory=str(tmp_path), guard=guard))
return TestClient(app), tmp_path
def test_existing_file_is_served(tmp_path):
client, root = _app(tmp_path)
os.makedirs(root / JOB)
(root / JOB / "clip_1.mp4").write_bytes(b"x" * 100)
r = client.get(f"/videos/{JOB}/clip_1.mp4")
assert r.status_code == 200
def test_guard_refuses_a_non_deliverable(tmp_path):
def guard(path):
return not path.endswith(".json")
client, root = _app(tmp_path, guard)
os.makedirs(root / JOB)
(root / JOB / "clip_1.mp4").write_bytes(b"x" * 100)
(root / JOB / "x_metadata.json").write_bytes(b"{}")
assert client.get(f"/videos/{JOB}/clip_1.mp4").status_code == 200
# A refused path must look exactly like a missing one.
assert client.get(f"/videos/{JOB}/x_metadata.json").status_code == 404
def test_no_guard_behaves_like_staticfiles(tmp_path):
client, _root = _app(tmp_path, None)
assert client.get(f"/videos/{JOB}/clip_1.mp4").status_code == 404