refactor(douyu): 统一腾讯角色绑定协议与状态判断

This commit is contained in:
yml
2026-11-18 10:59:20 +08:00
parent 9958e4ab7d
commit 8a58f2857d
14 changed files with 1681 additions and 215 deletions
+15 -10
View File
@@ -1291,22 +1291,27 @@ class TestDeriveFromBindInfo:
== BIND_BOUND
)
def test_role_flag_is_the_only_signal(self):
"""**只看 is_bound_role** —— 这一列问的是「角色绑没绑」。
曾经用 is_bound_act 做兜底("避免漏掉已绑但没回角色名的"),
那是把"活动维度"当成"角色维度"。实测那些判为 bound 的账号
**100% 都有角色名**,证明 is_bound_role 本身就够用。
"""
def test_bind_act_is_the_final_confirmation_signal(self):
"""最新抓包:bindRole 只是选中角色,actBind 后 bindAct 才是最终绑定。"""
from web.backend.services.account_binding import (
BIND_BOUND,
BIND_PENDING,
derive_from_bind_info,
)
assert (
derive_from_bind_info(
{"is_bound_role": True, "is_bound_act": False, "role_name": "x"}
)
== BIND_PENDING
)
assert derive_from_bind_info({"is_bound_role": True}) == BIND_BOUND
# 只有 act 没有 role → **推不出角色结论**,保持 unknown(别拿活动当角色)
assert derive_from_bind_info({"is_bound_act": True}) is None
assert derive_from_bind_info({"is_bound_act": "1"}) is None
# 新接口的最终绑定以 bindAct 为准。
assert (
derive_from_bind_info({"is_bound_role": False, "is_bound_act": True})
== BIND_BOUND
)
assert derive_from_bind_info({"is_bound_act": "1"}) == BIND_BOUND
def test_unbound_when_role_flag_explicitly_false(self):
from web.backend.services.account_binding import (