fix(accounts): 完善手机号必绑与账号注销等登录异常分型识别

- 补充必须绑定手机号与账号注销/封禁/冻结等错误文案的识别规则
- 增加数据修正迁移 20261008_0052,回写历史账号和登录任务的失败分型
- 增加列表查询与导出时根据错误文案自动兜底细化 failure_kind 的逻辑
- 增加并完善相关分型单元测试
This commit is contained in:
yml2213
2026-10-08 11:26:19 +08:00
parent f8ad6e1777
commit 4eef45efe4
5 changed files with 122 additions and 10 deletions
+18
View File
@@ -61,6 +61,12 @@ class TestAccountFailureClassificationAndExport:
classify_failure("跳过手机号绑定失败: 必须绑定手机号") == "must_bind_mobile"
)
assert classify_failure("登录失败: 必须绑定手机号") == "must_bind_mobile"
assert (
classify_failure(
"重新登录失败: 跳过手机号绑定失败: 必须绑定手机号(旧 Cookie 已保留)"
)
== "must_bind_mobile"
)
assert failure_kind_label("must_bind_mobile") == "必须绑定手机号"
# 验证 must_bind_mobile 在 CK 失效时被 derive_status 推导为 manual 待人工
@@ -76,6 +82,18 @@ class TestAccountFailureClassificationAndExport:
)
assert derive_status(acc) == STATUS_MANUAL
def test_classify_account_canceled_or_banned(self):
"""测试账号已注销/封禁/冻结归入凭证/账号异常问题。"""
assert (
classify_failure(
"重新登录失败: 第二次登录失败: 账号已注销(旧 Cookie 已保留)"
)
== "credential"
)
assert classify_failure("第二次登录失败: 账号已注销") == "credential"
assert classify_failure("登录失败: 该账号已被封禁") == "credential"
assert classify_failure("账号已冻结,请联系客服") == "credential"
def test_list_accounts_filter_by_failure_kind_and_serialization(self):
"""测试按 failure_kind 筛选与 AccountOut 序列化包含失败字段。"""
self._create_account(
+1 -1
View File
@@ -26,7 +26,7 @@ TESTS_DIR = Path(__file__).resolve().parent
PROJECT_ROOT = TESTS_DIR.parent
VERSIONS_DIR = PROJECT_ROOT / "web" / "backend" / "migrations" / "versions"
HEAD_REVISION = "20261004_0051"
HEAD_REVISION = "20261008_0052"
# 迁移新增、但不声明在模型里的复合查询索引。
EXTRA_INDEXES = (