test: 修复 7 个失败用例 + 测试隔离(225/225 全绿)
- 新增 tests/conftest.py:CALLLOG_DB 指向临时目录 + 自动打开库(TestClient 不走 lifespan) - 4 个 /logs 用例适配读库后的行为(断言前 flush;只看自己改为库里塞记录 + /logs/calls 断言) - 夹具 grok-4.6 → grok-4.7(模型清单已同步) - api_calls 增 video_id 列(自动迁移),/logs 映射补回该字段 - requirements-dev.txt(pytest);测试改为幂等 - 版本 2.9.13 → 2.9.14
This commit is contained in:
1 parent
a9a200bf9c
commit
80bd551656
6 files changed
+89
-20
No files matched your search
+5
-3
@@ -61,6 +61,7 @@ CREATE TABLE IF NOT EXISTS api_calls (
|
||||
served TEXT,
|
||||
provider TEXT,
|
||||
caller TEXT,
|
||||
video_id TEXT,
|
||||
stream INTEGER DEFAULT 0,
|
||||
ok INTEGER DEFAULT 1,
|
||||
status INTEGER,
|
||||
@@ -112,7 +113,7 @@ CREATE INDEX IF NOT EXISTS idx_vj_status ON video_jobs(status, created);
|
||||
"""
|
||||
|
||||
_COLUMNS = ("ts", "rid", "account", "key_id", "kind", "method", "path", "model",
|
||||
"served", "provider", "caller", "stream", "ok", "status", "latency_ms",
|
||||
"served", "provider", "caller", "video_id", "stream", "ok", "status", "latency_ms",
|
||||
"ip", "ua", "prompt", "completion",
|
||||
"tok_prompt", "tok_completion", "tok_cached", "tok_reasoning", "ver")
|
||||
|
||||
@@ -231,7 +232,7 @@ class CallLogStore:
|
||||
def _migrate(db: sqlite3.Connection) -> None:
|
||||
"""轻量迁移:老库缺 token 列时补上(2026-10-23 加)。"""
|
||||
have = {r[1] for r in db.execute("PRAGMA table_info(api_calls)")}
|
||||
for col in ("tok_prompt", "tok_completion", "tok_cached", "tok_reasoning"):
|
||||
for col in ("tok_prompt", "tok_completion", "tok_cached", "tok_reasoning", "video_id"):
|
||||
if col not in have:
|
||||
db.execute(f"ALTER TABLE api_calls ADD COLUMN {col} INTEGER DEFAULT 0")
|
||||
log.info("调用日志表已补列: %s", col)
|
||||
@@ -376,7 +377,7 @@ class CallLogStore:
|
||||
# 列表页也要「内容」列(2026-10-23 老板要求):始终取 prompt 生成单行预览,
|
||||
# 但不把动辄几千字的原文整包吐给列表(with_content=1 才给完整 prompt/completion)。
|
||||
cols = ("id, ts, rid, account, key_id, kind, method, path, model, served, provider, "
|
||||
"caller, stream, ok, status, latency_ms, ip, ua, ver, prompt, "
|
||||
"caller, video_id, stream, ok, status, latency_ms, ip, ua, ver, prompt, "
|
||||
"tok_prompt, tok_completion, tok_cached, tok_reasoning")
|
||||
if with_content:
|
||||
cols += ", completion"
|
||||
@@ -697,6 +698,7 @@ def _row(entry: dict[str, Any], meta: dict[str, Any]) -> dict[str, Any]:
|
||||
"served": entry.get("served"),
|
||||
"provider": entry.get("provider"),
|
||||
"caller": entry.get("caller"),
|
||||
"video_id": entry.get("video_id"),
|
||||
"stream": 1 if entry.get("stream") else 0,
|
||||
"ok": 1 if entry.get("ok") else 0,
|
||||
"status": meta.get("status"),
|
||||
|
||||
Reference in new issue
Block a user