feat: 平台自动同步代码内置 provider,移除手动添加/删除平台 - 启动时 sync_platforms:注册表中的 provider 自动生成为平台记录 - 前端移除添加平台按钮与删除入口,平台列表只读 + 停用/启用 + 监控参数编辑 - 平台编辑表单仅保留间隔/重试/超时/备注(提供方锁定) - 测试更新:内置平台自动同步用例,共 93 个

This commit is contained in:
2026-08-05 07:37:30 +08:00
parent bdeb353bc2
commit 86ef5aa412
5 changed files with 52 additions and 51 deletions
+15 -5
View File
@@ -52,21 +52,31 @@ PLATFORM_PAYLOAD = {
class TestPlatforms:
def test_builtin_platforms_auto_synced(self, client):
"""代码内置 provider 启动时自动同步为平台记录,无需手动添加。"""
h = _auth(client)
provs = client.get("/api/providers", headers=h).json()
plats = client.get("/api/platforms", headers=h).json()
for p in provs:
assert any(x["provider_id"] == p["id"] for x in plats), p["id"]
dp = next(x for x in plats if x["provider_id"] == "deepseek")
assert dp["name"] == "DeepSeek" and dp["currency"] == "CNY"
def test_crud_flow(self, client):
h = _auth(client)
pid = client.post("/api/platforms", json=PLATFORM_PAYLOAD, headers=h).json()["id"]
lst = client.get("/api/platforms", headers=h).json()
assert len(lst) == 1 and lst[0]["account_count"] == 0
assert lst[0]["provider_id"] == "deepseek"
assert lst[0]["currency"] == "CNY" # 默认取 provider 的货币
created = next(p for p in lst if p["id"] == pid)
assert created["provider_id"] == "deepseek"
assert created["currency"] == "CNY" # 默认取 provider 的货币
upd = client.put(f"/api/platforms/{pid}", json={"currency": "USD", "interval_seconds": 300}, headers=h)
assert upd.status_code == 200
assert client.get("/api/platforms", headers=h).json()[0]["currency"] == "USD"
assert next(p for p in client.get("/api/platforms", headers=h).json() if p["id"] == pid)["currency"] == "USD"
assert client.delete(f"/api/platforms/{pid}", headers=h).status_code == 200
assert client.get("/api/platforms", headers=h).json() == []
assert all(p["id"] != pid for p in client.get("/api/platforms", headers=h).json())
def test_duplicate_name_409(self, client):
h = _auth(client)