mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 09:20:22 +08:00
- Usage/RequestCandidate/VideoTask/Stats 等表的 user_id/api_key_id 外键从
CASCADE 改为 SET NULL,删除用户或 Key 后历史记录不再丢失
- 各表添加 username/api_key_name 快照字段,删除后仍可追溯归属
- 新增 bulk_cleanup 模块,分批置空大表外键避免长事务锁
- 删除用户/Key 流程集成预清理步骤,先置空再删除
- 精简 candidate_builder 冗余 debug 日志
- 修复 proxy_nodes 启动日志 format 占位符错误({} -> %s)
- 前端批量操作请求增加 5 分钟超时配置
30 lines
797 B
Python
30 lines
797 B
Python
from __future__ import annotations
|
|
|
|
from unittest.mock import MagicMock
|
|
|
|
from src.services.request.candidate import RequestCandidateService
|
|
|
|
|
|
def test_create_candidate_persists_snapshot_fields() -> None:
|
|
db = MagicMock()
|
|
|
|
candidate = RequestCandidateService.create_candidate(
|
|
db=db,
|
|
request_id="req-1",
|
|
candidate_index=0,
|
|
retry_index=1,
|
|
user_id="user-1",
|
|
api_key_id="key-1",
|
|
username="alice",
|
|
api_key_name="Primary Key",
|
|
provider_id="provider-1",
|
|
endpoint_id="endpoint-1",
|
|
key_id="pool-key-1",
|
|
status="available",
|
|
)
|
|
|
|
assert candidate.username == "alice"
|
|
assert candidate.api_key_name == "Primary Key"
|
|
db.add.assert_called_once_with(candidate)
|
|
db.flush.assert_called_once()
|