初始化提交
This commit is contained in:
commit
887c1f449e
963 files changed
+166869
No files matched your search
@@ -0,0 +1,41 @@
|
||||
"""Run 列表 API 测试(归档页运行时间河数据源)。"""
|
||||
|
||||
from collections.abc import AsyncGenerator
|
||||
|
||||
import pytest
|
||||
from httpx import ASGITransport, AsyncClient
|
||||
|
||||
from app.main import app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
async def client() -> AsyncGenerator[AsyncClient, None]:
|
||||
transport = ASGITransport(app=app)
|
||||
async with AsyncClient(transport=transport, base_url="http://test") as http_client:
|
||||
yield http_client
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_runs_returns_page(client: AsyncClient) -> None:
|
||||
resp = await client.get("/api/v1/runs")
|
||||
assert resp.status_code == 200
|
||||
body = resp.json()
|
||||
assert "items" in body
|
||||
assert "total" in body
|
||||
assert body["page"] == 1
|
||||
assert isinstance(body["items"], list)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_runs_filters_accepted(client: AsyncClient) -> None:
|
||||
# 过滤参数被接受;seed 后无 run,验证端点工作且不报错
|
||||
resp = await client.get("/api/v1/runs?status=completed&character_id=character_none")
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["total"] == 0
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_run_detail_not_found(client: AsyncClient) -> None:
|
||||
# 列表端点("")不破坏详情端点(/{run_id})的路由顺序
|
||||
resp = await client.get("/api/v1/runs/run_missing")
|
||||
assert resp.status_code == 404
|
||||
Reference in new issue
Block a user