fix(douyu): 修复多 alias 待确认绑定并补充协议文档
This commit is contained in:
@@ -11,6 +11,7 @@ from web.backend.services.account_binding import (
|
||||
BIND_BOUND,
|
||||
BIND_PENDING,
|
||||
BIND_UNBOUND,
|
||||
binding_pending_decision,
|
||||
binding_role_from_result,
|
||||
binding_snapshot,
|
||||
derive_from_bind_info,
|
||||
@@ -39,6 +40,7 @@ def _role_candidate(
|
||||
role_name: str,
|
||||
*,
|
||||
bound_act: bool = False,
|
||||
need_bind_act: bool = True,
|
||||
) -> dict[str, Any]:
|
||||
return {
|
||||
"act_alias": alias,
|
||||
@@ -48,7 +50,7 @@ def _role_candidate(
|
||||
"is_bound_account": True,
|
||||
"is_bound_role": True,
|
||||
"is_bound_act": bound_act,
|
||||
"need_bind_act": True,
|
||||
"need_bind_act": need_bind_act,
|
||||
"need_bind_role": True,
|
||||
}
|
||||
|
||||
@@ -193,6 +195,36 @@ def test_existing_pending_role_is_baseline_not_new_scan_result():
|
||||
)
|
||||
|
||||
|
||||
def test_existing_action_alias_pending_is_confirmable_even_same_role():
|
||||
role = "忧郁情潇藏心中"
|
||||
baseline = _role_candidate(ACT_ALIAS, role, need_bind_act=True)
|
||||
legacy = _role_candidate(LEGACY_ALIAS, role, need_bind_act=False)
|
||||
activity = _role_candidate(ACT_ALIAS, role, need_bind_act=True)
|
||||
picker = _RolePicker()
|
||||
|
||||
decision = binding_pending_decision(
|
||||
activity,
|
||||
baseline_role_name=role,
|
||||
baseline_is_bound_act=False,
|
||||
baseline_info=baseline,
|
||||
actionable_aliases=[ACT_ALIAS],
|
||||
)
|
||||
selected = picker._pick_bind_info(
|
||||
[legacy, activity],
|
||||
baseline_role_name=role,
|
||||
baseline_is_bound_act=False,
|
||||
baseline_info=baseline,
|
||||
prefer_pending=True,
|
||||
prefer_aliases=[LEGACY_ALIAS, ACT_ALIAS],
|
||||
actionable_aliases=[ACT_ALIAS],
|
||||
)
|
||||
|
||||
assert decision["confirmable"] is True
|
||||
assert decision["reason"] == "existing_actionable_pending"
|
||||
assert selected is not None
|
||||
assert selected["act_alias"] == ACT_ALIAS
|
||||
|
||||
|
||||
def test_same_role_after_activity_bind_transition_is_pending():
|
||||
old_role = "少和我较劲"
|
||||
baseline = _role_candidate(ACT_ALIAS, old_role, bound_act=True)
|
||||
|
||||
Reference in New Issue
Block a user