63 lines
2.3 KiB
Python
63 lines
2.3 KiB
Python
|
|
from copy import deepcopy
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from test_native_dialogue_workflow import capabilities, native_story, _drive, _start
|
||
|
|
|
||
|
|
|
||
|
|
async def test_inspection_with_no_clean_audio_cannot_start_picture_generation(system):
|
||
|
|
did, draft = await native_story(system)
|
||
|
|
sid = draft["manifest"]["shot_ids"][0]
|
||
|
|
url = f"/api/editors/{did}"
|
||
|
|
body = dict(
|
||
|
|
output_goal="caption_inspect",
|
||
|
|
targets=["native_report:" + sid],
|
||
|
|
expected_version=draft["version"],
|
||
|
|
)
|
||
|
|
res = await system.client.post(url + "/plan", json=body)
|
||
|
|
assert res.status_code == 200, res.text
|
||
|
|
plan = res.json()
|
||
|
|
assert plan["steps"] == [] and plan["issues"][0]["unit_id"] == sid
|
||
|
|
rejected = await system.client.post(
|
||
|
|
url + "/runs",
|
||
|
|
json={**body, "expected_plan_hash": plan["plan_hash"]},
|
||
|
|
headers={"Idempotency-Key": "existing-audio-only"},
|
||
|
|
)
|
||
|
|
assert rejected.status_code == 422
|
||
|
|
assert not system.provider.submitted_payloads
|
||
|
|
|
||
|
|
|
||
|
|
async def test_existing_audio_inspection_only_submits_single_selected_inspect_job(system, tmp_path):
|
||
|
|
from app.services.dialogue import apply_pending_result
|
||
|
|
|
||
|
|
capabilities(system)
|
||
|
|
did, draft = await native_story(system)
|
||
|
|
rid = await _start(system, did, draft["version"])
|
||
|
|
_, _, state, error, _ = await _drive(system, rid, tmp_path)
|
||
|
|
assert state == "succeeded", error
|
||
|
|
await apply_pending_result(system.app.state.db, rid, system.settings)
|
||
|
|
url = f"/api/editors/{did}"
|
||
|
|
draft = (await system.client.get(url)).json()
|
||
|
|
sid = draft["manifest"]["shot_ids"][0]
|
||
|
|
body = dict(
|
||
|
|
output_goal="caption_inspect",
|
||
|
|
targets=["native_report:" + sid],
|
||
|
|
expected_version=draft["version"],
|
||
|
|
)
|
||
|
|
res = await system.client.post(url + "/plan", json=body)
|
||
|
|
assert res.status_code == 200, res.text
|
||
|
|
plan = res.json()
|
||
|
|
assert plan["issues"] == []
|
||
|
|
assert [(s["kind"], s["status"]) for s in plan["steps"]] == [
|
||
|
|
("audio.dialogue.inspect", "generate")
|
||
|
|
]
|
||
|
|
run = await system.client.post(
|
||
|
|
url + "/runs",
|
||
|
|
json={**body, "expected_plan_hash": plan["plan_hash"]},
|
||
|
|
headers={"Idempotency-Key": "inspect-one"},
|
||
|
|
)
|
||
|
|
assert run.status_code == 202, run.text
|
||
|
|
rid2 = run.json()["run"]["id"]
|
||
|
|
_, _, state, error, calls = await _drive(system, rid2, tmp_path)
|
||
|
|
assert state == "succeeded", error
|
||
|
|
assert calls == {"audio.dialogue.inspect": 1}
|