fix(analytics): 词库单字MySQL预览拒扫+IntegrityError 409+MATCH短语净化

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-04 19:48:30 +08:00
parent 0c14be0777
commit c7b3ce9d1c
3 changed files with 55 additions and 5 deletions
+33
View File
@@ -59,3 +59,36 @@ async def test_api_words_crud(make_client):
assert r.status_code == 200 and r.json()["enabled"] is False
r = await client.delete(f"/api/analytics/sensitive/words/{wid}")
assert r.status_code == 200
# 注:单字词 MySQL 拒预览分支(words.py ValueError)在 SQLite 测试库不可达
# ——dialect 判定不满足,不做单测;由注释 + 路由 400 映射保障。
async def test_api_patch_unknown_404(make_client):
async def seed(session):
...
client = await make_client(seed)
r = await client.patch("/api/analytics/sensitive/words/999",
json={"enabled": False})
assert r.status_code == 404
async def test_api_delete_unknown_404(make_client):
async def seed(session):
...
client = await make_client(seed)
r = await client.delete("/api/analytics/sensitive/words/999")
assert r.status_code == 404
async def test_api_create_empty_word_409(make_client):
async def seed(session):
...
client = await make_client(seed)
r = await client.post("/api/analytics/sensitive/words",
json={"word": " "})
assert r.status_code == 409