fix(douyu): 升级工作台任务流并修正换绑冷却
This commit is contained in:
@@ -62,6 +62,74 @@ def _fixtures(db, *, status: str = "planned") -> tuple[User, Account, DouyuTask]
|
||||
return user, account, task
|
||||
|
||||
|
||||
def test_query_change_bind_time_ignores_unbound_placeholder_wait(db, monkeypatch):
|
||||
_, account, task = _fixtures(db, status="running")
|
||||
task.task_type = "query_change_bind_time"
|
||||
db.commit()
|
||||
|
||||
activity = {
|
||||
"act_alias": "20260120QYOOB",
|
||||
"role_name": "",
|
||||
"is_bound_account": False,
|
||||
"is_bound_role": False,
|
||||
"is_bound_act": False,
|
||||
"need_bind_act": True,
|
||||
"need_bind_role": True,
|
||||
"change_role_wait_time": 2_592_000,
|
||||
"can_change_time": 0,
|
||||
"can_change_role": False,
|
||||
}
|
||||
legacy = {
|
||||
**activity,
|
||||
"act_alias": "cjm",
|
||||
"need_bind_act": False,
|
||||
"change_role_wait_time": 0,
|
||||
}
|
||||
role = {
|
||||
"status": "unbound",
|
||||
"query_act_aliases": ["20260120QYOOB", "cjm"],
|
||||
"bind_infos": [activity, legacy],
|
||||
"bind_info": activity,
|
||||
"candidates": [],
|
||||
"errors": [],
|
||||
"pending_role_name": "",
|
||||
}
|
||||
config = {
|
||||
"legacy_act_alias": "cjm",
|
||||
"confirm_act_alias": "20260120QYOOB",
|
||||
"bind_act_alias": "20260120QYOOB",
|
||||
}
|
||||
runner = DouyuBatchRunner(
|
||||
db,
|
||||
task.batch_id,
|
||||
task.task_type,
|
||||
close_db=False,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"web.backend.services.douyu_runner_bind.resolve_elite_role",
|
||||
lambda *_args, **_kwargs: role,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"web.backend.services.douyu_runner_bind.persist_probe_result",
|
||||
lambda *_args, **_kwargs: None,
|
||||
)
|
||||
|
||||
runner._execute_query_change_bind_time(
|
||||
db,
|
||||
task,
|
||||
account,
|
||||
account.cookie,
|
||||
config,
|
||||
)
|
||||
|
||||
assert task.status == "success"
|
||||
assert task.result["change_role_wait_time"] == 0
|
||||
assert task.result["change_role_wait_text"] == "0"
|
||||
assert task.result["can_change_time"] is None
|
||||
assert task.result["can_change_role"] is True
|
||||
assert "可换绑" in task.message
|
||||
|
||||
|
||||
def test_task_rows_commit_before_started_events(db, monkeypatch):
|
||||
user = User(username="event-order", password_hash="hash", role="operation")
|
||||
db.add(user)
|
||||
|
||||
Reference in New Issue
Block a user