fix(qa): 修 3 个 QA MEDIUM——规则/档位路由校验收紧
- 规则 GET 不存在 project → 404(原返误导性空 200,掩盖坏 id):list_rules 加 项目存在校验(仿 C1/H2)。 - 规则 content 纯空白 → 422(原 strip 前校验 min_length,空白行入库成垃圾): 改 StringConstraints(strip_whitespace=True, min_length=1)。 - 档位路由 tier 限定 writer/analyst/light(Tier Literal)→ 未知档位 422 (原接受任意字符串)。 回归测试:test_generation(GET rules 404)/ test_rules(空白 content 422)/ test_settings_providers(未知 tier 422)。门禁绿:ruff/format/mypy(210)/pytest。
This commit is contained in:
@@ -210,6 +210,16 @@ def _client(app: Any) -> httpx.AsyncClient:
|
||||
return httpx.AsyncClient(transport=transport, base_url="http://test")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_rules_unknown_project_returns_404() -> None:
|
||||
# QA MEDIUM 回归:GET 规则列表对不存在 project 返 404(原返误导性空 200,掩盖坏 id)。
|
||||
app, _ = _make_app(project_repo=FakeProjectRepo(), gateway=object())
|
||||
async with _client(app) as client:
|
||||
resp = await client.get(f"/projects/{uuid.uuid4()}/rules")
|
||||
assert resp.status_code == 404
|
||||
assert resp.json()["error"]["code"] == ErrorCode.NOT_FOUND
|
||||
|
||||
|
||||
# ---- 世界观生成 ----
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user