fix(douyu): 升级工作台任务流并修正换绑冷却
This commit is contained in:
@@ -6,7 +6,7 @@ import pytest
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy import func, or_
|
||||
|
||||
from web.backend.models import Account, DouyuTask, User
|
||||
from web.backend.models import Account, DouyuTask, DouyuWorkbenchAccount, User
|
||||
from web.backend.routers.douyu import (
|
||||
_split_task_scope_query,
|
||||
_visible_tasks_query,
|
||||
@@ -310,6 +310,68 @@ def test_support_task_list_matches_legacy_semantics(db):
|
||||
assert exc_info.value.status_code == 403
|
||||
|
||||
|
||||
def test_workbench_task_list_is_limited_to_selected_accounts(db):
|
||||
support, _, admin, _, tasks = _seed_tasks(db)
|
||||
support_account_id = tasks["assigned_elite"].account_id
|
||||
db.add(
|
||||
DouyuWorkbenchAccount(
|
||||
user_id=support.id,
|
||||
handbook_scope="elite",
|
||||
account_id=support_account_id,
|
||||
sort_order=0,
|
||||
)
|
||||
)
|
||||
db.add(
|
||||
DouyuWorkbenchAccount(
|
||||
user_id=admin.id,
|
||||
handbook_scope="elite",
|
||||
account_id=support_account_id,
|
||||
sort_order=0,
|
||||
)
|
||||
)
|
||||
db.commit()
|
||||
|
||||
for user in (support, admin):
|
||||
result = list_tasks(
|
||||
batch_id=None,
|
||||
handbook_scope="elite",
|
||||
workbench_only=True,
|
||||
include_detail=False,
|
||||
page=1,
|
||||
page_size=100,
|
||||
db=db,
|
||||
current=user,
|
||||
)
|
||||
assert result["total"] == 2
|
||||
assert {item.account_id for item in result["items"]} == {support_account_id}
|
||||
assert {item.id for item in result["items"]} == {
|
||||
tasks["assigned_elite"].id,
|
||||
tasks["both_legacy_elite"].id,
|
||||
}
|
||||
|
||||
empty = list_tasks(
|
||||
batch_id=None,
|
||||
handbook_scope="elite",
|
||||
workbench_only=True,
|
||||
include_detail=False,
|
||||
page=1,
|
||||
page_size=100,
|
||||
db=db,
|
||||
current=User(
|
||||
username="task-list-no-workbench",
|
||||
password_hash="hash",
|
||||
role="super_admin",
|
||||
is_active=True,
|
||||
),
|
||||
)
|
||||
assert empty == {
|
||||
"items": [],
|
||||
"total": 0,
|
||||
"page": 1,
|
||||
"page_size": 100,
|
||||
}
|
||||
|
||||
|
||||
def test_empty_support_task_list_stays_empty(db):
|
||||
support = User(
|
||||
username="empty-task-support",
|
||||
|
||||
Reference in New Issue
Block a user