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.
93 lines
3.2 KiB
Python
93 lines
3.2 KiB
Python
from test_timeline_v2 import spec
|
|
|
|
|
|
async def draft(system):
|
|
response = await system.client.post("/api/workflows", json={"spec": spec()})
|
|
assert response.status_code == 201
|
|
return response.json()
|
|
|
|
|
|
def workflow_item(d):
|
|
return {
|
|
"kind": "workflow",
|
|
"draft_id": d["id"],
|
|
"draft_revision": d["revision"],
|
|
"expected_version": d["version"],
|
|
}
|
|
|
|
|
|
async def test_queued_workflow_parents_are_bounded_before_any_child_exists(system):
|
|
system.settings.max_owner_runs = 1
|
|
first_body = {"items": [workflow_item(await draft(system))]}
|
|
first = await system.client.post(
|
|
"/api/batches", json=first_body, headers={"Idempotency-Key": "parent-one"}
|
|
)
|
|
assert first.status_code == 202
|
|
second = await system.client.post(
|
|
"/api/batches",
|
|
json={"items": [workflow_item(await draft(system))]},
|
|
headers={"Idempotency-Key": "parent-two"},
|
|
)
|
|
assert second.status_code == 429 and second.json()["detail"]["code"] == "quota_exceeded"
|
|
replay = await system.client.post(
|
|
"/api/batches", json=first_body, headers={"Idempotency-Key": "parent-one"}
|
|
)
|
|
assert replay.status_code == 202 and replay.json()["batch"]["id"] == first.json()["batch"]["id"]
|
|
|
|
|
|
async def test_open_batch_parent_limit_and_replay(system):
|
|
system.settings.max_owner_batches = 1
|
|
body = {"items": [{"kind": "job", "task_type": "math.solve", "input": {"prompt": "2+2"}}]}
|
|
first = await system.client.post(
|
|
"/api/batches", json=body, headers={"Idempotency-Key": "batch-one"}
|
|
)
|
|
assert first.status_code == 202
|
|
assert (
|
|
await system.client.post(
|
|
"/api/batches", json=body, headers={"Idempotency-Key": "batch-two"}
|
|
)
|
|
).status_code == 429
|
|
assert (
|
|
await system.client.post(
|
|
"/api/batches", json=body, headers={"Idempotency-Key": "batch-one"}
|
|
)
|
|
).status_code == 202
|
|
|
|
|
|
async def test_creation_rate_is_shared_by_run_and_job_commands(system):
|
|
system.settings.max_creation_commands_per_minute = 1
|
|
d = await draft(system)
|
|
first = await system.client.post(
|
|
"/api/workflows/" + d["id"] + "/runs",
|
|
json={"draft_revision": d["revision"], "expected_version": d["version"]},
|
|
headers={"Idempotency-Key": "run-one"},
|
|
)
|
|
assert first.status_code == 202
|
|
second = await system.client.post(
|
|
"/api/jobs",
|
|
json={"task_type": "math.solve", "input": {"prompt": "2+2"}},
|
|
headers={"Idempotency-Key": "job-two"},
|
|
)
|
|
assert second.status_code == 429
|
|
|
|
|
|
async def test_internal_batch_children_do_not_consume_creation_command_rate(system):
|
|
system.settings.max_creation_commands_per_minute = 2
|
|
body = {
|
|
"items": [
|
|
{"kind": "job", "task_type": "image.generate", "input": {"prompt": str(i)}}
|
|
for i in range(3)
|
|
]
|
|
}
|
|
assert (
|
|
await system.client.post(
|
|
"/api/batches", json=body, headers={"Idempotency-Key": "three-leaves"}
|
|
)
|
|
).status_code == 202
|
|
second = await system.client.post(
|
|
"/api/jobs",
|
|
json={"task_type": "math.solve", "input": {"prompt": "2+2"}},
|
|
headers={"Idempotency-Key": "next-command"},
|
|
)
|
|
assert second.status_code == 202
|