fix(douyu): 修正扫码前待确认角色误判
This commit is contained in:
@@ -700,8 +700,16 @@ def test_deadline_poll_still_checks_role_once_before_timeout(db, monkeypatch):
|
||||
task.result = {
|
||||
"url": "https://example.test/qr",
|
||||
"query_act_aliases": ["bind-act"],
|
||||
"baseline_role_name": "",
|
||||
"baseline_is_bound_act": False,
|
||||
"baseline_role_name": "old-role",
|
||||
"baseline_is_bound_act": True,
|
||||
"before_bind_info": {
|
||||
"act_alias": "bind-act",
|
||||
"role_name": "old-role",
|
||||
"is_bound_act": True,
|
||||
"is_bound_role": True,
|
||||
"need_bind_act": True,
|
||||
"need_bind_role": True,
|
||||
},
|
||||
"bind_polling": True,
|
||||
}
|
||||
db.commit()
|
||||
@@ -711,7 +719,14 @@ def test_deadline_poll_still_checks_role_once_before_timeout(db, monkeypatch):
|
||||
"get_bind_qr",
|
||||
close_db=False,
|
||||
)
|
||||
info = {"act_alias": "bind-act", "role_name": "new-role"}
|
||||
info = {
|
||||
"act_alias": "bind-act",
|
||||
"role_name": "new-role",
|
||||
"is_bound_act": False,
|
||||
"is_bound_role": True,
|
||||
"need_bind_act": True,
|
||||
"need_bind_role": True,
|
||||
}
|
||||
snapshot = {
|
||||
"role_name": "new-role",
|
||||
"area_name": "微信",
|
||||
@@ -732,7 +747,6 @@ def test_deadline_poll_still_checks_role_once_before_timeout(db, monkeypatch):
|
||||
monkeypatch.setattr(runner, "_fetch_bind_info_candidates", lambda *_args: [info])
|
||||
monkeypatch.setattr(runner, "_pick_bind_info", lambda *_args, **_kwargs: info)
|
||||
monkeypatch.setattr(runner, "_bind_snapshot", lambda _info: snapshot)
|
||||
monkeypatch.setattr(runner, "_is_pending_role", lambda *_args, **_kwargs: True)
|
||||
monkeypatch.setattr(
|
||||
runner,
|
||||
"_format_bind_summary",
|
||||
@@ -751,7 +765,7 @@ def test_deadline_poll_still_checks_role_once_before_timeout(db, monkeypatch):
|
||||
assert task.result["bind_ready_for_confirm"] is True
|
||||
|
||||
|
||||
def test_qr_preflight_accepts_existing_action_alias_pending_same_role(
|
||||
def test_qr_preflight_treats_existing_action_alias_pending_as_baseline(
|
||||
db, monkeypatch
|
||||
):
|
||||
_, account, task = _fixtures(db, status="running")
|
||||
@@ -807,18 +821,23 @@ def test_qr_preflight_accepts_existing_action_alias_pending_same_role(
|
||||
)
|
||||
|
||||
db.refresh(task)
|
||||
assert task.status == "success"
|
||||
assert task.status == "running"
|
||||
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"] == "existing_actionable_pending"
|
||||
assert task.result["bind_phase"] == "waiting_scan"
|
||||
assert task.result["bind_ready_for_confirm"] is False
|
||||
assert "pending_role_name" not in task.result
|
||||
action_decision = next(
|
||||
item
|
||||
for item in task.result["bind_candidate_decisions"]
|
||||
if item["alias"] == "20260120QYOOB"
|
||||
)
|
||||
assert action_decision["reason"] == "same_role_stale_pending"
|
||||
|
||||
|
||||
def test_qr_preflight_accepts_same_bound_role_that_still_needs_binding(
|
||||
def test_qr_preflight_keeps_bound_role_waiting_for_new_scan_transition(
|
||||
db, monkeypatch
|
||||
):
|
||||
"""用户重新绑定同名角色时,bindAct=1 不应阻断可确认状态。"""
|
||||
"""历史 bindAct=1 + needBindAct=1 不能直接进入待确认。"""
|
||||
_, account, task = _fixtures(db, status="running")
|
||||
role = "你哥奢皇"
|
||||
legacy = {
|
||||
@@ -873,15 +892,17 @@ def test_qr_preflight_accepts_same_bound_role_that_still_needs_binding(
|
||||
)
|
||||
|
||||
db.refresh(task)
|
||||
assert task.status == "success"
|
||||
assert task.status == "running"
|
||||
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"
|
||||
assert task.result["bind_phase"] == "waiting_scan"
|
||||
assert task.result["bind_ready_for_confirm"] is False
|
||||
assert "pending_role_name" not in task.result
|
||||
action_decision = next(
|
||||
item
|
||||
for item in task.result["bind_candidate_decisions"]
|
||||
if item["alias"] == "20260120QYOOB"
|
||||
)
|
||||
assert action_decision["reason"] == "already_bound"
|
||||
|
||||
|
||||
def test_binding_poll_accepts_existing_action_alias_pending_same_role(
|
||||
@@ -917,8 +938,8 @@ def test_binding_poll_accepts_existing_action_alias_pending_same_role(
|
||||
"url": "https://example.test/qr",
|
||||
"query_act_aliases": ["cjm", "20260120QYOOB"],
|
||||
"baseline_role_name": role,
|
||||
"baseline_is_bound_act": False,
|
||||
"before_bind_info": activity,
|
||||
"baseline_is_bound_act": True,
|
||||
"before_bind_info": {**activity, "is_bound_act": True},
|
||||
"bind_polling": True,
|
||||
}
|
||||
db.commit()
|
||||
@@ -952,13 +973,13 @@ def test_binding_poll_accepts_existing_action_alias_pending_same_role(
|
||||
assert task.result["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"] == "existing_actionable_pending"
|
||||
assert task.result["bind_decision"]["reason"] == "same_alias_after_bound_transition"
|
||||
assert {
|
||||
row["alias"]: row["reason"]
|
||||
for row in task.result["bind_candidate_decisions"]
|
||||
} == {
|
||||
"cjm": "same_role_stale",
|
||||
"20260120QYOOB": "existing_actionable_pending",
|
||||
"20260120QYOOB": "same_alias_after_bound_transition",
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user