fix(douyu): 支持同名角色重新绑定
This commit is contained in:
@@ -238,7 +238,34 @@ def test_same_role_after_activity_bind_transition_is_pending():
|
||||
)
|
||||
|
||||
|
||||
def test_pending_candidate_picker_ignores_legacy_same_role_residual():
|
||||
def test_same_bound_role_with_need_bind_act_is_confirmable():
|
||||
role = "少和我较劲"
|
||||
baseline = _role_candidate(
|
||||
ACT_ALIAS,
|
||||
role,
|
||||
bound_act=True,
|
||||
need_bind_act=True,
|
||||
)
|
||||
candidate = _role_candidate(
|
||||
ACT_ALIAS,
|
||||
role,
|
||||
bound_act=True,
|
||||
need_bind_act=True,
|
||||
)
|
||||
|
||||
decision = binding_pending_decision(
|
||||
candidate,
|
||||
baseline_role_name=role,
|
||||
baseline_is_bound_act=True,
|
||||
baseline_info=baseline,
|
||||
actionable_aliases=[ACT_ALIAS],
|
||||
)
|
||||
|
||||
assert decision["confirmable"] is True
|
||||
assert decision["reason"] == "same_alias_after_bound_transition"
|
||||
|
||||
|
||||
def test_pending_candidate_picker_uses_action_alias_same_role():
|
||||
old_role = "少和我较劲"
|
||||
baseline = _role_candidate(ACT_ALIAS, old_role, bound_act=True)
|
||||
legacy = _role_candidate(LEGACY_ALIAS, old_role, bound_act=False)
|
||||
@@ -252,7 +279,8 @@ def test_pending_candidate_picker_ignores_legacy_same_role_residual():
|
||||
baseline_info=baseline,
|
||||
)
|
||||
|
||||
assert selected is None
|
||||
assert selected is not None
|
||||
assert selected["act_alias"] == ACT_ALIAS
|
||||
|
||||
|
||||
def test_task_result_helpers_use_shared_same_role_transition_rule():
|
||||
|
||||
@@ -815,6 +815,75 @@ def test_qr_preflight_accepts_existing_action_alias_pending_same_role(
|
||||
assert task.result["bind_decision"]["reason"] == "existing_actionable_pending"
|
||||
|
||||
|
||||
def test_qr_preflight_accepts_same_bound_role_that_still_needs_binding(
|
||||
db, monkeypatch
|
||||
):
|
||||
"""用户重新绑定同名角色时,bindAct=1 不应阻断可确认状态。"""
|
||||
_, account, task = _fixtures(db, status="running")
|
||||
role = "你哥奢皇"
|
||||
legacy = {
|
||||
"act_alias": "cjm",
|
||||
"role_name": role,
|
||||
"area_name": "微信",
|
||||
"plat_name": "安卓(android)",
|
||||
"is_bound_account": True,
|
||||
"is_bound_role": True,
|
||||
"is_bound_act": False,
|
||||
"need_bind_act": False,
|
||||
"need_bind_role": True,
|
||||
"change_role_wait_time": 0,
|
||||
"can_change_time": 0,
|
||||
"can_change_role": True,
|
||||
}
|
||||
activity = {
|
||||
**legacy,
|
||||
"act_alias": "20260120QYOOB",
|
||||
"is_bound_act": True,
|
||||
"need_bind_act": True,
|
||||
"can_change_time": 1_790_870_400,
|
||||
}
|
||||
client = type(
|
||||
"Client",
|
||||
(),
|
||||
{"get_bind_qr": lambda self, _alias: {"url": "https://example.test/qr"}},
|
||||
)()
|
||||
runner = DouyuBatchRunner(
|
||||
db,
|
||||
task.batch_id,
|
||||
"get_bind_qr",
|
||||
close_db=False,
|
||||
)
|
||||
monkeypatch.setattr(runner, "_client", lambda _cookie: client)
|
||||
monkeypatch.setattr(
|
||||
runner,
|
||||
"_fetch_bind_info_candidates",
|
||||
lambda *_args: [legacy, activity],
|
||||
)
|
||||
|
||||
runner._execute_get_bind_qr(
|
||||
db,
|
||||
task,
|
||||
account,
|
||||
"PHPSESSID=x",
|
||||
{
|
||||
"bind_act_alias": "20260120QYOOB",
|
||||
"confirm_act_alias": "20260120QYOOB",
|
||||
"legacy_act_alias": "cjm",
|
||||
},
|
||||
)
|
||||
|
||||
db.refresh(task)
|
||||
assert task.status == "success"
|
||||
assert task.result["url"] == "https://example.test/qr"
|
||||
assert task.result["pending_role_name"] == role
|
||||
assert task.result["bind_ready_for_confirm"] is True
|
||||
assert task.result["bind_decision"]["alias"] == "20260120QYOOB"
|
||||
assert (
|
||||
task.result["bind_decision"]["reason"]
|
||||
== "same_alias_after_bound_transition"
|
||||
)
|
||||
|
||||
|
||||
def test_binding_poll_accepts_existing_action_alias_pending_same_role(
|
||||
db, monkeypatch
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user