Spaces:
Running
Running
Test durable tenant-scoped generation attempt history
Browse files
tests/test_generation_foundation.py
CHANGED
|
@@ -313,6 +313,36 @@ async def test_generation_request_idempotency_and_cancel(generation_container) -
|
|
| 313 |
assert retrieved.status is GenerationJobStatus.CANCELLED
|
| 314 |
|
| 315 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
@pytest.mark.asyncio
|
| 317 |
async def test_generation_records_are_workspace_isolated(generation_container) -> None:
|
| 318 |
context_a = await create_context(generation_container, "Generation A")
|
|
|
|
| 313 |
assert retrieved.status is GenerationJobStatus.CANCELLED
|
| 314 |
|
| 315 |
|
| 316 |
+
@pytest.mark.asyncio
|
| 317 |
+
async def test_generation_attempt_history_is_durable_and_workspace_scoped(
|
| 318 |
+
generation_container,
|
| 319 |
+
) -> None:
|
| 320 |
+
context = await create_context(generation_container, "Generation attempt history")
|
| 321 |
+
request = await generation_container.generation.create(
|
| 322 |
+
workspace_id=context.workspace_id,
|
| 323 |
+
user_id=context.user_id,
|
| 324 |
+
payload=request_payload(),
|
| 325 |
+
idempotency_key="generation-attempt-history",
|
| 326 |
+
)
|
| 327 |
+
claimed = await generation_container.generation.claim_dispatchable_jobs(limit=1)
|
| 328 |
+
assert len(claimed) == 1
|
| 329 |
+
assert claimed[0].generation_job_id == request.job.id
|
| 330 |
+
|
| 331 |
+
attempts = await generation_container.generation.list_job_attempts(
|
| 332 |
+
context.workspace_id, context.user_id, request.job.id
|
| 333 |
+
)
|
| 334 |
+
assert len(attempts) == 1
|
| 335 |
+
assert attempts[0].attempt_number == 1
|
| 336 |
+
assert attempts[0].status == "submitting"
|
| 337 |
+
assert attempts[0].generation_job_id == request.job.id
|
| 338 |
+
|
| 339 |
+
other_context = await create_context(generation_container, "Other workspace")
|
| 340 |
+
with pytest.raises(GenerationJobNotFoundError):
|
| 341 |
+
await generation_container.generation.list_job_attempts(
|
| 342 |
+
other_context.workspace_id, other_context.user_id, request.job.id
|
| 343 |
+
)
|
| 344 |
+
|
| 345 |
+
|
| 346 |
@pytest.mark.asyncio
|
| 347 |
async def test_generation_records_are_workspace_isolated(generation_container) -> None:
|
| 348 |
context_a = await create_context(generation_container, "Generation A")
|