Restructure backend and frontend modules; add story, library, and editor schema migrations. Support editable automatic production, manual confirmation modes, account and user lifecycle management, compact container scrolling, consistent forms, and per-task result previews. Update inference and TTS scheduling, deployment guidance, and regression coverage; remove obsolete standalone pages and temporary acceptance artifacts.
141 lines
4.9 KiB
Python
141 lines
4.9 KiB
Python
from types import SimpleNamespace
|
|
from unittest.mock import AsyncMock
|
|
from sqlalchemy import select
|
|
from app.models import Job
|
|
import pytest
|
|
|
|
|
|
@pytest.mark.parametrize("candidate", [False, True])
|
|
async def test_workflow_imports_only_final_enhanced_output(system, monkeypatch, candidate):
|
|
response = await system.client.post(
|
|
"/api/jobs",
|
|
json={
|
|
"task_type": "video.generate",
|
|
"input": {"prompt": "three-shot source"},
|
|
"parameters": {},
|
|
},
|
|
headers={"Idempotency-Key": "dual-stage-output"},
|
|
)
|
|
assert response.status_code == 202
|
|
job_id = response.json()["jobs"][0]["id"]
|
|
async with system.app.state.db.session() as session:
|
|
job = await session.get(Job, job_id)
|
|
if candidate:
|
|
job.request_key = "candidate:test"
|
|
else:
|
|
job.run_id = "run"
|
|
job.step_key = "shot_1"
|
|
job.upstream_id = "gpu-result"
|
|
job.upstream_result = {
|
|
"outputs": [{"path": "native.mp4"}, {"path": "enhanced.mp4"}],
|
|
"metadata": {"final_output_indices": [1]},
|
|
}
|
|
await session.commit()
|
|
imported = []
|
|
|
|
async def import_one(db, settings, job, path, index, **kwargs):
|
|
imported.append(index)
|
|
return SimpleNamespace(kind="video")
|
|
|
|
monkeypatch.setattr("app.services.orchestration.coordinator.import_output", import_one)
|
|
coordinator = system.app.state.coordinator
|
|
monkeypatch.setattr(coordinator, "_complete", AsyncMock())
|
|
await coordinator._collect_gpu(job)
|
|
assert imported == [1]
|
|
assert system.provider.download_count == 1
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
"run_kind,upscale", [("workflow_auto", False), ("story_auto", True), ("legacy", False)]
|
|
)
|
|
async def test_real_short_auto_video_import_respects_frozen_native_or_upscaled_profile(
|
|
system, run_kind, upscale
|
|
):
|
|
import shutil
|
|
from app.adapters.media import run_process, inspect_video_track
|
|
from app.models import WorkflowDraft, WorkflowRun, User
|
|
from app.services.assets import import_output
|
|
from pathlib import Path
|
|
|
|
ffmpeg = shutil.which(system.settings.ffmpeg_bin)
|
|
ffprobe = shutil.which(system.settings.ffprobe_bin)
|
|
local = Path(__file__).resolve().parents[2] / ".local" / "tools" / "ffmpeg"
|
|
ffmpeg = ffmpeg or next((str(p) for p in local.glob("*/bin/ffmpeg.exe")), None)
|
|
ffprobe = ffprobe or next((str(p) for p in local.glob("*/bin/ffprobe.exe")), None)
|
|
if not ffmpeg or not ffprobe:
|
|
pytest.skip("FFmpeg required")
|
|
system.settings.ffmpeg_bin = ffmpeg
|
|
system.settings.ffprobe_bin = ffprobe
|
|
async with system.app.state.db.session() as s:
|
|
owner = await s.scalar(select(User))
|
|
draft = WorkflowDraft(owner_id=owner.id, name="import boundary", spec={})
|
|
s.add(draft)
|
|
await s.flush()
|
|
run = WorkflowRun(
|
|
owner_id=owner.id,
|
|
draft_id=draft.id,
|
|
draft_revision=1,
|
|
spec_snapshot={},
|
|
spec_hash="a" * 64,
|
|
run_kind=run_kind,
|
|
)
|
|
s.add(run)
|
|
await s.flush()
|
|
job = Job(
|
|
owner_id=owner.id,
|
|
task_type="video.generate",
|
|
request_hash="a" * 64,
|
|
upstream_key="test:" + run.id,
|
|
run_id=run.id,
|
|
step_key="video_0001",
|
|
state="collecting",
|
|
phase="collecting",
|
|
input_json={"prompt": "mock"},
|
|
parameters={
|
|
"num_frames": 25,
|
|
"fps": 24,
|
|
"upscale": upscale,
|
|
"width": 640 if upscale else 1280,
|
|
"height": 352 if upscale else 704,
|
|
"upscale_width": 1280 if upscale else 1920,
|
|
"upscale_height": 704 if upscale else 1056,
|
|
},
|
|
)
|
|
s.add(job)
|
|
await s.commit()
|
|
source = system.settings.job_work_root / "short.mp4"
|
|
source.parent.mkdir(parents=True, exist_ok=True)
|
|
await run_process(
|
|
[
|
|
ffmpeg,
|
|
"-nostdin",
|
|
"-v",
|
|
"error",
|
|
"-f",
|
|
"lavfi",
|
|
"-i",
|
|
"color=c=blue:s=1280x704:r=24",
|
|
"-frames:v",
|
|
"25",
|
|
"-c:v",
|
|
"libx264",
|
|
"-threads",
|
|
"1",
|
|
"-pix_fmt",
|
|
"yuv420p",
|
|
str(source),
|
|
],
|
|
timeout=20,
|
|
)
|
|
track = await inspect_video_track(source, system.settings)
|
|
assert track["frames"] == 25 and track["fps"] == 24
|
|
if run_kind == "legacy":
|
|
with pytest.raises(ValueError, match="Workflow shot"):
|
|
await import_output(system.app.state.db, system.settings, job, source, 0)
|
|
else:
|
|
asset = await import_output(system.app.state.db, system.settings, job, source, 0)
|
|
assert asset.kind == "video" and (asset.width, asset.height) == (1280, 704)
|
|
assert asset.duration_seconds < 1.1
|
|
replay = await import_output(system.app.state.db, system.settings, job, source, 0)
|
|
assert replay.id == asset.id
|