Add video resolution and duration options to video generation forms; implement video status polling in frontend
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -226,7 +226,8 @@ def test_generate_video_text_mode(client):
|
||||
with patch("frontend.app.main.httpx.request", return_value=mock):
|
||||
resp = client.post("/generate/video", data={
|
||||
"mode": "text", "model": "openai/sora-2-pro",
|
||||
"prompt": "A sunset", "aspect_ratio": "16:9"
|
||||
"prompt": "A sunset", "aspect_ratio": "16:9",
|
||||
"duration_seconds": "10", "resolution": "720p",
|
||||
})
|
||||
assert resp.status_code == 200
|
||||
assert b"queued" in resp.data
|
||||
@@ -347,3 +348,73 @@ def test_profile_update_failure(client):
|
||||
"/users/profile", data={"email": "bad", "password": ""})
|
||||
# redirects regardless, flash message shown on next GET
|
||||
assert resp.status_code == 302
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# GET /generate/video/status (polling proxy)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
def test_video_status_proxy_completed(client):
|
||||
_set_auth(client)
|
||||
mock = _mock_response(200, {
|
||||
"id": "v1", "model": "", "status": "completed",
|
||||
"video_url": "https://example.com/video.mp4",
|
||||
"unsigned_urls": ["https://example.com/video.mp4"],
|
||||
})
|
||||
with patch("frontend.app.main.httpx.request", return_value=mock):
|
||||
resp = client.get(
|
||||
"/generate/video/status",
|
||||
query_string={
|
||||
"polling_url": "https://openrouter.ai/api/v1/videos/v1"},
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
data = resp.get_json()
|
||||
assert data["status"] == "completed"
|
||||
assert data["video_url"] == "https://example.com/video.mp4"
|
||||
|
||||
|
||||
def test_video_status_proxy_processing(client):
|
||||
_set_auth(client)
|
||||
mock = _mock_response(
|
||||
200, {"id": "v1", "model": "", "status": "processing"})
|
||||
with patch("frontend.app.main.httpx.request", return_value=mock):
|
||||
resp = client.get(
|
||||
"/generate/video/status",
|
||||
query_string={
|
||||
"polling_url": "https://openrouter.ai/api/v1/videos/v1"},
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.get_json()["status"] == "processing"
|
||||
|
||||
|
||||
def test_video_status_proxy_requires_login(client):
|
||||
resp = client.get(
|
||||
"/generate/video/status",
|
||||
query_string={"polling_url": "https://openrouter.ai/api/v1/videos/v1"},
|
||||
)
|
||||
assert resp.status_code == 302
|
||||
assert "/login" in resp.headers["Location"]
|
||||
|
||||
|
||||
def test_video_status_proxy_missing_url(client):
|
||||
_set_auth(client)
|
||||
resp = client.get("/generate/video/status")
|
||||
assert resp.status_code == 400
|
||||
assert b"polling_url" in resp.data
|
||||
|
||||
|
||||
def test_video_generate_renders_polling_ui(client):
|
||||
"""When response has polling_url, template shows polling div."""
|
||||
_set_auth(client)
|
||||
mock = _mock_response(200, {
|
||||
"id": "v1", "model": "openai/sora-2-pro", "status": "queued",
|
||||
"polling_url": "https://openrouter.ai/api/v1/videos/v1",
|
||||
})
|
||||
with patch("frontend.app.main.httpx.request", return_value=mock):
|
||||
resp = client.post("/generate/video", data={
|
||||
"mode": "text", "model": "openai/sora-2-pro",
|
||||
"prompt": "A sunset", "aspect_ratio": "16:9",
|
||||
})
|
||||
assert resp.status_code == 200
|
||||
assert b"video-poll-status" in resp.data
|
||||
assert b"openrouter.ai/api/v1/videos/v1" in resp.data
|
||||
|
||||
Reference in New Issue
Block a user