feat: 调整新建/重建账号命名格式为 {上游网站名}-{上游分组名/ID}-{KeyID}

This commit is contained in:
liumangmang
2026-07-01 21:11:37 +08:00
parent ebf7def177
commit 94d9550f77
4 changed files with 130 additions and 22 deletions
+5 -3
View File
@@ -156,6 +156,7 @@ def test_organize_groups_full_scenarios(db_session, monkeypatch):
return {"id": account_id, "group_ids": body.get("group_ids")}
monkeypatch.setattr("app.routers.websites.Sub2ApiWebsiteClient", MockClient)
monkeypatch.setattr("app.routers.websites.sync_account_priorities_for_website", lambda db, wid: [])
# 5. 执行一键整理
response = organize_website_groups(wid=w.id, db=db_session)
@@ -175,7 +176,7 @@ def test_organize_groups_full_scenarios(db_session, monkeypatch):
item_g1 = next(item for item in items if item.target_group_id == "TG1" and item.source_group_id == "G1")
assert item_g1.status == "created"
assert item_g1.key_name == "Key-G1"
assert item_g1.account_id.startswith("NEW-SmartUp-")
assert item_g1.account_id.startswith("NEW-U1-")
# TG1 分组下的 G2 (缺少 Key)
item_g2 = next(item for item in items if item.target_group_id == "TG1" and item.source_group_id == "G2")
@@ -196,7 +197,7 @@ def test_organize_groups_full_scenarios(db_session, monkeypatch):
item_g4 = next(item for item in items if item.target_group_id == "TG2" and item.source_group_id == "G4")
assert item_g4.status == "recreated"
assert item_g4.message == "清理后重建账号"
assert item_g4.account_id.startswith("NEW-SmartUp-")
assert item_g4.account_id.startswith("NEW-U1-")
# 7. 检查数据库中 Key 记录的状态变化
db_session.refresh(k1)
@@ -293,6 +294,7 @@ def test_organize_groups_list_accounts_none_conservatively_skips(db_session, mon
return new_acc
monkeypatch.setattr("app.routers.websites.Sub2ApiWebsiteClient", MockClient)
monkeypatch.setattr("app.routers.websites.sync_account_priorities_for_website", lambda db, wid: [])
# 执行一键整理
response = organize_website_groups(wid=w.id, db=db_session)
@@ -309,7 +311,7 @@ def test_organize_groups_list_accounts_none_conservatively_skips(db_session, mon
# G1 (未导入) 仍应该成功创建账号
item_g1 = next(item for item in items if item.source_group_id == "G1")
assert item_g1.status == "created"
assert item_g1.account_id.startswith("NEW-SmartUp-")
assert item_g1.account_id.startswith("NEW-U1-")
assert item_g1.source_group_name == "G1-SourceGroup" # 校验 group_name 优先从绑定中获取!
# G3 (已导入) 应该保守跳过