2026-11-11 14:08:15 +08:00
|
|
|
"""The public contract and adapter must agree on native fifteen-second shots."""
|
2026-11-14 14:07:26 +08:00
|
|
|
|
2026-11-11 14:08:15 +08:00
|
|
|
import pytest
|
|
|
|
|
|
2026-11-14 14:07:26 +08:00
|
|
|
from app.adapters.provider.client import Provider, ProviderError, capabilities, validate_arguments
|
2026-11-11 14:08:15 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_video_capability_exposes_fifteen_seconds_with_legacy_default(system):
|
2026-11-26 21:06:27 +08:00
|
|
|
system.settings.video_generation_profile = "wan2.2-ti2v-5b-v1"
|
2026-11-14 14:07:26 +08:00
|
|
|
video = next(
|
|
|
|
|
row for row in capabilities(system.settings) if row["task_type"] == "video.generate"
|
|
|
|
|
)
|
|
|
|
|
assert video["defaults"]["num_frames"] == 121
|
|
|
|
|
assert video["constraints"]["num_frames"] == {"min": 5, "max": 361, "step": 4}
|
2026-11-11 14:08:15 +08:00
|
|
|
|
|
|
|
|
|
2026-11-14 14:07:26 +08:00
|
|
|
@pytest.mark.parametrize("frames", [241, 361])
|
2026-11-11 14:08:15 +08:00
|
|
|
async def test_native_long_video_is_accepted_and_forwarded_without_shortening(system, frames):
|
2026-11-14 14:07:26 +08:00
|
|
|
parameters = {"num_frames": frames, "upscale": False}
|
|
|
|
|
validate_arguments(
|
|
|
|
|
"video.generate", {"prompt": "one continuous shot"}, parameters, system.settings
|
|
|
|
|
)
|
|
|
|
|
response = await system.client.post(
|
|
|
|
|
"/api/jobs",
|
|
|
|
|
json={
|
|
|
|
|
"task_type": "video.generate",
|
|
|
|
|
"input": {"prompt": "one continuous shot"},
|
|
|
|
|
"parameters": parameters,
|
|
|
|
|
},
|
|
|
|
|
)
|
2026-11-11 14:08:15 +08:00
|
|
|
assert response.status_code == 202, response.text
|
2026-11-14 14:07:26 +08:00
|
|
|
assert response.json()["jobs"][0]["parameters"]["num_frames"] == frames
|
2026-11-11 14:08:15 +08:00
|
|
|
provider = Provider(system.settings)
|
2026-11-14 14:07:26 +08:00
|
|
|
work = system.settings.job_work_root / "longshot"
|
2026-11-11 14:08:15 +08:00
|
|
|
work.mkdir(parents=True)
|
|
|
|
|
try:
|
2026-11-14 14:07:26 +08:00
|
|
|
payload = await provider.prepare_gpu_payload(
|
|
|
|
|
"video.generate", {"prompt": "one continuous shot"}, parameters, {}, work
|
|
|
|
|
)
|
|
|
|
|
assert payload["parameters"]["num_frames"] == frames
|
|
|
|
|
assert payload["parameters"]["fps"] == 24
|
2026-11-11 14:08:15 +08:00
|
|
|
finally:
|
|
|
|
|
await provider.aclose()
|
|
|
|
|
|
|
|
|
|
|
2026-11-14 14:07:26 +08:00
|
|
|
@pytest.mark.parametrize("frames", [362, 365])
|
2026-11-11 14:08:15 +08:00
|
|
|
def test_out_of_contract_video_frames_remain_rejected(system, frames):
|
|
|
|
|
with pytest.raises(ProviderError):
|
2026-11-14 14:07:26 +08:00
|
|
|
validate_arguments(
|
|
|
|
|
"video.generate",
|
|
|
|
|
{"prompt": "one continuous shot"},
|
|
|
|
|
{"num_frames": frames},
|
|
|
|
|
system.settings,
|
|
|
|
|
)
|