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.
556 lines
20 KiB
Python
556 lines
20 KiB
Python
import copy
|
|
import pytest
|
|
from sqlalchemy import select
|
|
from app.models import Job, Asset
|
|
from app.models import WorkflowRun, WorkflowStep
|
|
from test_timeline_v2 import spec
|
|
|
|
|
|
@pytest.fixture
|
|
async def wf(system):
|
|
from app.api.routes.workflows import router, runs_router
|
|
from app.api.routes.batches import router as batches
|
|
|
|
system.app.include_router(router, prefix="/api")
|
|
system.app.include_router(runs_router, prefix="/api")
|
|
system.app.include_router(batches, prefix="/api")
|
|
return system
|
|
|
|
|
|
async def draft(wf):
|
|
r = await wf.client.post("/api/workflows", json={"name": "test", "spec": spec()})
|
|
assert r.status_code == 201, r.text
|
|
return r.json()
|
|
|
|
|
|
async def run(wf, d, key="start"):
|
|
r = await wf.client.post(
|
|
f"/api/workflows/{d['id']}/runs",
|
|
json={"draft_revision": d["revision"], "expected_version": d["version"]},
|
|
headers={"Idempotency-Key": key},
|
|
)
|
|
assert r.status_code == 202, r.text
|
|
return r.json()
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_snapshot_version_idempotency_owner(wf, other_client):
|
|
d = await draft(wf)
|
|
a = await run(wf, d)
|
|
b = await run(wf, d)
|
|
assert a["run"]["id"] == b["run"]["id"]
|
|
r = await other_client.get("/api/workflow-runs/" + a["run"]["id"])
|
|
assert r.status_code == 404
|
|
r = await wf.client.patch(
|
|
"/api/workflows/" + d["id"], json={"name": "new"}, headers={"If-Match": str(d["version"])}
|
|
)
|
|
assert r.status_code == 409
|
|
current = (await wf.client.get("/api/workflows/" + d["id"])).json()
|
|
changed = spec()
|
|
changed["shots"][0]["prompt"] = "new prompt"
|
|
r = await wf.client.patch(
|
|
"/api/workflows/" + d["id"],
|
|
json={"spec": changed},
|
|
headers={"If-Match": str(current["version"])},
|
|
)
|
|
assert r.status_code == 200
|
|
async with wf.app.state.db.session() as s:
|
|
row = await s.get(WorkflowRun, a["run"]["id"])
|
|
assert row.spec_snapshot["shots"][0]["prompt"] != "new prompt"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_engine_durable_parallel_cancel_and_no_new_job(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
|
|
d = await draft(wf)
|
|
snap = await run(wf, d)
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + snap["run"]["id"])).json()
|
|
assert len(snap["jobs"]) == 3 and snap["jobs"][0]["step_key"] == "shot_1"
|
|
r = await wf.client.post(
|
|
"/api/workflow-runs/" + snap["run"]["id"] + "/cancel",
|
|
json={},
|
|
headers={"Idempotency-Key": "cancel"},
|
|
)
|
|
assert r.status_code == 200, r.text
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + snap["run"]["id"])).json()
|
|
assert snap["run"]["state"] == "cancelled" and len(snap["jobs"]) == 3
|
|
assert wf.provider.submitted_payloads == []
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_failed_step_explicit_retry_only_and_old_target_rejected(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
|
|
snap = await run(wf, await draft(wf))
|
|
rid = snap["run"]["id"]
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
async with wf.app.state.db.session() as s:
|
|
old = await s.scalar(select(Job).where(Job.run_id == rid))
|
|
old.state = "failed"
|
|
old.phase = "failed"
|
|
oid = old.id
|
|
await s.commit()
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
assert snap["run"]["state"] == "blocked" and len(snap["jobs"]) == 3
|
|
body = {"expected_run_version": snap["run"]["version"], "target_job_id": oid}
|
|
r = await wf.client.post(
|
|
f"/api/workflow-runs/{rid}/steps/shot_1/retry",
|
|
json=body,
|
|
headers={"Idempotency-Key": "redo"},
|
|
)
|
|
assert r.status_code == 202, r.text
|
|
again = await wf.client.post(
|
|
f"/api/workflow-runs/{rid}/steps/shot_1/retry",
|
|
json=body,
|
|
headers={"Idempotency-Key": "redo"},
|
|
)
|
|
assert again.status_code == 202 and len(again.json()["jobs"]) == 4
|
|
r = await wf.client.post(
|
|
f"/api/workflow-runs/{rid}/steps/shot_1/retry",
|
|
json={**body, "expected_run_version": again.json()["run"]["version"]},
|
|
headers={"Idempotency-Key": "stale"},
|
|
)
|
|
assert r.status_code == 409
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_batch_mixed_persistent_one_active_member(wf):
|
|
d = await draft(wf)
|
|
body = {
|
|
"items": [
|
|
{
|
|
"kind": "job",
|
|
"task_type": "image.generate",
|
|
"input": {"prompt": "one"},
|
|
"parameters": {},
|
|
},
|
|
{
|
|
"kind": "workflow",
|
|
"draft_id": d["id"],
|
|
"draft_revision": d["revision"],
|
|
"expected_version": d["version"],
|
|
},
|
|
]
|
|
}
|
|
r = await wf.client.post("/api/batches", json=body, headers={"Idempotency-Key": "batch"})
|
|
assert r.status_code == 202, r.text
|
|
snap = r.json()
|
|
assert len(snap["items"]) == 2
|
|
async with wf.app.state.db.session() as s:
|
|
jobs = (await s.scalars(select(Job))).all()
|
|
assert all(j.execution_mode == "batch" for j in jobs)
|
|
same = await wf.client.post("/api/batches", json=body, headers={"Idempotency-Key": "batch"})
|
|
assert same.json()["batch"]["id"] == snap["batch"]["id"]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_old_result_after_retry_cannot_advance_selected_step(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
|
|
snap = await run(wf, await draft(wf))
|
|
rid = snap["run"]["id"]
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
async with wf.app.state.db.session() as s:
|
|
old = await s.scalar(select(Job).where(Job.run_id == rid))
|
|
old.state = "failed"
|
|
old.phase = "failed"
|
|
oid = old.id
|
|
await s.commit()
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
r = await wf.client.post(
|
|
f"/api/workflow-runs/{rid}/steps/shot_1/retry",
|
|
json={"expected_run_version": snap["run"]["version"], "target_job_id": oid},
|
|
headers={"Idempotency-Key": "retry"},
|
|
)
|
|
assert r.status_code == 202
|
|
async with wf.app.state.db.session() as s:
|
|
old = await s.get(Job, oid)
|
|
old.state = "succeeded"
|
|
await s.commit()
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
assert len(snap["jobs"]) == 4
|
|
shot = next(s for s in snap["steps"] if s["step_key"] == "shot_1")
|
|
assert shot["state"] != "succeeded" and shot["selected_job_id"] != oid
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_batch_pause_resume_preserves_member_manual_pause(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
|
|
d = await draft(wf)
|
|
r = await wf.client.post(
|
|
"/api/batches",
|
|
json={
|
|
"items": [
|
|
{
|
|
"kind": "workflow",
|
|
"draft_id": d["id"],
|
|
"draft_revision": d["revision"],
|
|
"expected_version": d["version"],
|
|
}
|
|
]
|
|
},
|
|
headers={"Idempotency-Key": "b"},
|
|
)
|
|
bid = r.json()["batch"]["id"]
|
|
rid = r.json()["items"][0]["target_id"]
|
|
r = await wf.client.post(
|
|
f"/api/workflow-runs/{rid}/pause", json={}, headers={"Idempotency-Key": "manual"}
|
|
)
|
|
assert r.status_code == 200
|
|
for intent in ("pause", "run"):
|
|
r = await wf.client.post(
|
|
f"/api/batches/{bid}/control",
|
|
json={"desired_state": intent},
|
|
headers={"Idempotency-Key": intent},
|
|
)
|
|
assert r.status_code == 200, r.text
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
assert snap["run"]["desired_state"] == "pause" and snap["jobs"] == []
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_batch_qwen_uses_finish_current_admission(wf):
|
|
r = await wf.client.post(
|
|
"/api/batches",
|
|
json={"items": [{"kind": "job", "task_type": "math.solve", "input": {"prompt": "2+2"}}]},
|
|
headers={"Idempotency-Key": "unsafe"},
|
|
)
|
|
assert r.status_code == 202, r.text
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_retry_with_active_execution_refuses_even_failed_job(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
from app.models import Execution
|
|
|
|
snap = await run(wf, await draft(wf))
|
|
rid = snap["run"]["id"]
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
async with wf.app.state.db.session() as s:
|
|
old = await s.scalar(select(Job).where(Job.run_id == rid))
|
|
old.state = "failed"
|
|
old.phase = "failed"
|
|
oid = old.id
|
|
s.add(
|
|
Execution(
|
|
job_id=oid,
|
|
ordinal=1,
|
|
phase_key="execute",
|
|
resource_pool="new_gpu",
|
|
fence_token="f",
|
|
state="unknown",
|
|
)
|
|
)
|
|
await s.commit()
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
r = await wf.client.post(
|
|
f"/api/workflow-runs/{rid}/steps/shot_1/retry",
|
|
json={"expected_run_version": snap["run"]["version"], "target_job_id": oid},
|
|
headers={"Idempotency-Key": "retry"},
|
|
)
|
|
assert r.status_code == 409 and r.json()["detail"]["code"] == "cleanup_pending"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_draft_deletion_reference_and_snapshot_guards(wf, png_bytes):
|
|
upload = await wf.client.post(
|
|
"/api/assets", files={"file": ("reference.png", png_bytes, "image/png")}
|
|
)
|
|
assert upload.status_code == 201, upload.text
|
|
aid = upload.json()["id"]
|
|
body = spec()
|
|
body["shots"][0]["image_asset_id"] = aid
|
|
r = await wf.client.post("/api/workflows", json={"spec": body})
|
|
assert r.status_code == 201
|
|
r = await wf.client.delete("/api/assets/" + aid)
|
|
assert r.status_code == 409, r.text
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_duplicate_workflow_batch_items_freeze_same_revision(wf):
|
|
d = await draft(wf)
|
|
item = {
|
|
"kind": "workflow",
|
|
"draft_id": d["id"],
|
|
"draft_revision": d["revision"],
|
|
"expected_version": d["version"],
|
|
}
|
|
r = await wf.client.post(
|
|
"/api/batches", json={"items": [item, item]}, headers={"Idempotency-Key": "tworuns"}
|
|
)
|
|
assert r.status_code == 202, r.text
|
|
assert len({i["target_id"] for i in r.json()["items"]}) == 2
|
|
|
|
|
|
async def publish_video(wf, jid, *, compose=False):
|
|
import hashlib
|
|
from app.models import utcnow
|
|
|
|
async with wf.app.state.db.session() as s:
|
|
j = await s.get(Job, jid)
|
|
j.state = "succeeded"
|
|
j.phase = "completed"
|
|
j.finished_at = utcnow()
|
|
data = b"v"
|
|
storage_key = "test-" + jid + ".mp4"
|
|
(wf.settings.asset_root / storage_key).write_bytes(data)
|
|
a = Asset(
|
|
owner_id=j.owner_id,
|
|
name="video.mp4",
|
|
storage_key=storage_key,
|
|
kind="video",
|
|
mime_type="video/mp4",
|
|
size_bytes=len(data),
|
|
sha256=hashlib.sha256(data).hexdigest(),
|
|
width=1920,
|
|
height=1080 if compose else 1056,
|
|
duration_seconds=15 if compose else 121 / 24,
|
|
ready=True,
|
|
origin="generated",
|
|
source_job_id=j.id,
|
|
source_output_index=0,
|
|
)
|
|
s.add(a)
|
|
await s.flush()
|
|
aid = a.id
|
|
await s.commit()
|
|
return aid
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_compose_retry_reuses_all_shots_and_old_run_cannot_overwrite(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
|
|
d = await draft(wf)
|
|
snap = await run(wf, d)
|
|
rid = snap["run"]["id"]
|
|
for key in ("shot_1", "shot_2", "shot_3"):
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
selected = next(s for s in snap["steps"] if s["step_key"] == key)["selected_job_id"]
|
|
await publish_video(wf, selected)
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
compose = next(s for s in snap["steps"] if s["step_key"] == "compose")
|
|
async with wf.app.state.db.session() as s:
|
|
j = await s.get(Job, compose["selected_job_id"])
|
|
j.state = "failed"
|
|
j.phase = "failed"
|
|
await s.commit()
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
r = await wf.client.post(
|
|
f"/api/workflow-runs/{rid}/steps/compose/retry",
|
|
json={
|
|
"expected_run_version": snap["run"]["version"],
|
|
"target_job_id": compose["selected_job_id"],
|
|
},
|
|
headers={"Idempotency-Key": "compose-retry"},
|
|
)
|
|
assert r.status_code == 202, r.text
|
|
assert sum(j["task_type"] == "video.generate" for j in r.json()["jobs"]) == 3
|
|
await publish_video(
|
|
wf,
|
|
next(s for s in r.json()["steps"] if s["step_key"] == "compose")["selected_job_id"],
|
|
compose=True,
|
|
)
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
assert snap["run"]["state"] == "succeeded"
|
|
current = (await wf.client.get("/api/workflows/" + d["id"])).json()
|
|
body = spec()
|
|
body["shots"][1]["prompt"] = "new shot2"
|
|
changed = await wf.client.patch(
|
|
"/api/workflows/" + d["id"],
|
|
json={"spec": body},
|
|
headers={"If-Match": str(current["version"])},
|
|
)
|
|
current = changed.json()
|
|
r = await wf.client.post(
|
|
"/api/workflows/" + d["id"] + "/runs",
|
|
json={
|
|
"draft_revision": current["revision"],
|
|
"expected_version": current["version"],
|
|
"reuse_run_id": rid,
|
|
},
|
|
headers={"Idempotency-Key": "new-run"},
|
|
)
|
|
assert r.status_code == 202, r.text
|
|
new = r.json()
|
|
assert sum(s["state"] == "succeeded" for s in new["steps"]) == 2
|
|
assert len(new["jobs"]) == 2
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
current = (await wf.client.get("/api/workflows/" + d["id"])).json()
|
|
assert current["current_run_id"] == new["run"]["id"]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_cancel_with_inflight_child_waits_and_success_late_does_not_publish(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
|
|
snap = await run(wf, await draft(wf))
|
|
rid = snap["run"]["id"]
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
async with wf.app.state.db.session() as s:
|
|
j = await s.scalar(select(Job).where(Job.run_id == rid))
|
|
j.state = "running"
|
|
j.phase = "inference"
|
|
j.upstream_id = "remote"
|
|
jid = j.id
|
|
await s.commit()
|
|
r = await wf.client.post(
|
|
"/api/workflow-runs/" + rid + "/cancel", json={}, headers={"Idempotency-Key": "cancel"}
|
|
)
|
|
assert r.json()["run"]["state"] == "cancelling"
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
assert snap["run"]["state"] == "cancelling"
|
|
await publish_video(wf, jid)
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
assert (
|
|
snap["run"]["state"] == "cancelled"
|
|
and snap["run"]["result_assets"] == []
|
|
and len(snap["jobs"]) == 3
|
|
)
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_parallel_run_and_patch_versions_accept_one(wf):
|
|
import asyncio
|
|
|
|
d = await draft(wf)
|
|
|
|
async def patch(name):
|
|
return await wf.client.patch(
|
|
"/api/workflows/" + d["id"],
|
|
json={"name": name},
|
|
headers={"If-Match": str(d["version"])},
|
|
)
|
|
|
|
responses = await asyncio.gather(patch("a"), patch("b"))
|
|
assert sorted(r.status_code for r in responses) == [200, 409]
|
|
d = (await wf.client.get("/api/workflows/" + d["id"])).json()
|
|
|
|
async def start(key):
|
|
return await wf.client.post(
|
|
"/api/workflows/" + d["id"] + "/runs",
|
|
json={"draft_revision": d["revision"], "expected_version": d["version"]},
|
|
headers={"Idempotency-Key": key},
|
|
)
|
|
|
|
responses = await asyncio.gather(start("a"), start("b"))
|
|
assert sorted(r.status_code for r in responses) == [202, 409]
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_batch_retains_unknown_cleanup_while_other_member_progresses(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
from app.models import Execution
|
|
|
|
r = await wf.client.post(
|
|
"/api/batches",
|
|
json={
|
|
"items": [
|
|
{"kind": "job", "task_type": "image.generate", "input": {"prompt": p}}
|
|
for p in ("one", "two")
|
|
]
|
|
},
|
|
headers={"Idempotency-Key": "batch"},
|
|
)
|
|
items = r.json()["items"]
|
|
bid = r.json()["batch"]["id"]
|
|
async with wf.app.state.db.session() as s:
|
|
j = await s.get(Job, items[0]["target_id"])
|
|
j.state = "failed"
|
|
j.phase = "failed"
|
|
s.add(
|
|
Execution(
|
|
job_id=j.id,
|
|
ordinal=1,
|
|
phase_key="execute",
|
|
resource_pool="new_gpu",
|
|
fence_token="f",
|
|
state="unknown",
|
|
)
|
|
)
|
|
await s.commit()
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
async with wf.app.state.db.session() as s:
|
|
j = await s.get(Job, items[1]["target_id"])
|
|
assert "batch_wait" not in j.hold_reasons
|
|
snap = (await wf.client.get("/api/batches/" + bid)).json()
|
|
assert snap["items"][0]["state"] == "cleanup_pending"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_missing_selected_output_blocks_only_affected_run(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
|
|
snap = await run(wf, await draft(wf))
|
|
rid = snap["run"]["id"]
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
async with wf.app.state.db.session() as s:
|
|
j = await s.scalar(select(Job).where(Job.run_id == rid))
|
|
j.state = "succeeded"
|
|
await s.commit()
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
assert snap["run"]["state"] == "blocked" and len(snap["jobs"]) == 3
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_maintenance_keeps_existing_run_queued_without_creating_children(wf):
|
|
from app.services.orchestration.workflow_engine import advance_workflows
|
|
|
|
snap = await run(wf, await draft(wf))
|
|
rid = snap["run"]["id"]
|
|
marker = wf.settings.state_root / "maintenance"
|
|
marker.write_text("on")
|
|
try:
|
|
await advance_workflows(wf.app.state.db, wf.settings, wf.provider)
|
|
snap = (await wf.client.get("/api/workflow-runs/" + rid)).json()
|
|
assert snap["jobs"] == [] and snap["run"]["state"] != "failed"
|
|
finally:
|
|
marker.unlink()
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_batch_capability_downgrade_rejected_before_acceptance(wf, monkeypatch):
|
|
async def caps():
|
|
return {"protocol_version": 1, "admission_policy": False}
|
|
|
|
monkeypatch.setattr(wf.provider, "upstream_capabilities", caps, raising=False)
|
|
r = await wf.client.post(
|
|
"/api/batches",
|
|
json={
|
|
"items": [{"kind": "job", "task_type": "image.generate", "input": {"prompt": "one"}}]
|
|
},
|
|
headers={"Idempotency-Key": "old-upstream"},
|
|
)
|
|
assert r.status_code == 503 and r.json()["detail"]["code"] == "upstream_protocol_incompatible"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_accepted_batch_replays_even_when_capability_goes_offline(wf, monkeypatch):
|
|
body = {"items": [{"kind": "job", "task_type": "image.generate", "input": {"prompt": "one"}}]}
|
|
first = await wf.client.post("/api/batches", json=body, headers={"Idempotency-Key": "accepted"})
|
|
assert first.status_code == 202
|
|
|
|
async def unavailable():
|
|
raise RuntimeError("offline")
|
|
|
|
monkeypatch.setattr(wf.provider, "upstream_capabilities", unavailable, raising=False)
|
|
again = await wf.client.post("/api/batches", json=body, headers={"Idempotency-Key": "accepted"})
|
|
assert again.status_code == 202 and again.json()["batch"]["id"] == first.json()["batch"]["id"]
|