fix(fulfillment): 通过状态转换识别最新角色
This commit is contained in:
@@ -6,6 +6,7 @@ from datetime import UTC, datetime
|
||||
from typing import Any
|
||||
|
||||
from core.douyu import DouyuActivityClient
|
||||
from web.backend.models import Account
|
||||
from web.backend.services.account_binding import (
|
||||
BIND_BOUND,
|
||||
BIND_PENDING,
|
||||
@@ -172,6 +173,51 @@ def test_existing_pending_role_is_baseline_not_new_scan_result():
|
||||
baseline_role_name=old_role,
|
||||
baseline_is_bound_act=False,
|
||||
)
|
||||
assert not is_pending_binding_role(
|
||||
candidates[0],
|
||||
baseline_role_name=old_role,
|
||||
baseline_is_bound_act=True,
|
||||
)
|
||||
assert not is_pending_binding_role(
|
||||
candidates[1],
|
||||
baseline_role_name=old_role,
|
||||
baseline_is_bound_act=True,
|
||||
)
|
||||
assert not is_pending_binding_role(
|
||||
candidates[0],
|
||||
baseline_role_name=old_role,
|
||||
baseline_is_bound_act=True,
|
||||
baseline_info=candidates[1],
|
||||
)
|
||||
|
||||
|
||||
def test_same_role_after_activity_bind_transition_is_pending():
|
||||
old_role = "少和我较劲"
|
||||
baseline = _role_candidate(ACT_ALIAS, old_role, bound_act=True)
|
||||
after_scan = _role_candidate(ACT_ALIAS, old_role, bound_act=False)
|
||||
|
||||
assert is_pending_binding_role(
|
||||
after_scan,
|
||||
baseline_role_name=old_role,
|
||||
baseline_is_bound_act=True,
|
||||
baseline_info=baseline,
|
||||
)
|
||||
|
||||
|
||||
def test_confirmed_new_role_replaces_account_current_role():
|
||||
account = Account(
|
||||
username="replace-role",
|
||||
password="p",
|
||||
email="replace-role@example.com",
|
||||
email_password="ep",
|
||||
status="active",
|
||||
game_name="少和我较劲",
|
||||
)
|
||||
new_role = _role_candidate(ACT_ALIAS, "新的绑定角色", bound_act=True)
|
||||
|
||||
_RolePicker()._apply_bind_info_to_account(account, new_role)
|
||||
|
||||
assert account.game_name == "新的绑定角色"
|
||||
|
||||
|
||||
def test_new_role_wins_when_cjm_and_activity_snapshots_differ():
|
||||
|
||||
Reference in New Issue
Block a user