浏览器兑换独立成页面并按斗鱼模式优化导入
新增 /huya/browser-exchange 页面(精英宝典下方),支持导入账号与 执行兑换,客服仅见已分配账号;账号管理页移除该功能。导入弹窗对齐 斗鱼操作台:服务端分页筛选、可搜索标签、无 CK 不展示、导入本页/ 一键导入全部/导入选中;新增 /accounts/ids 接口与 workbench browser_exchange scope。
This commit is contained in:
@@ -6,6 +6,7 @@ from web.backend.database import Base
|
||||
from web.backend.models import HuyaAccount, HuyaWorkbench, HuyaWorkbenchAccount, User
|
||||
from web.backend.routers.huya import (
|
||||
delete_account,
|
||||
list_huya_account_ids,
|
||||
list_huya_workbench_accounts,
|
||||
list_tasks,
|
||||
update_huya_workbench_accounts,
|
||||
@@ -70,6 +71,37 @@ class TestHuyaWorkbenchScope:
|
||||
handbook_scope="invalid",
|
||||
)
|
||||
|
||||
def test_browser_exchange_scope_and_account_ids(self):
|
||||
no_cookie = HuyaAccount(uid="200", yyuid="200", cookie="")
|
||||
self.session.add(no_cookie)
|
||||
self.session.commit()
|
||||
|
||||
update_huya_workbench_accounts(
|
||||
HuyaWorkbenchAccountsUpdate(handbook_scope="browser_exchange", account_ids=[self.account.id]),
|
||||
db=self.session,
|
||||
current=self.user,
|
||||
)
|
||||
assert list_huya_workbench_accounts("browser_exchange", db=self.session, current=self.user) == {
|
||||
"account_ids": [self.account.id],
|
||||
"configured": True,
|
||||
}
|
||||
# browser_exchange 与 elite 两个 scope 的账号集合互不影响
|
||||
assert list_huya_workbench_accounts("elite", db=self.session, current=self.user) == {
|
||||
"account_ids": [],
|
||||
"configured": False,
|
||||
}
|
||||
|
||||
# ids 接口:has_cookie=True 只返回有 Cookie 的账号
|
||||
result = list_huya_account_ids(has_cookie=True, db=self.session, current=self.user)
|
||||
assert result == {"account_ids": [self.account.id], "total": 1}
|
||||
all_ids = list_huya_account_ids(db=self.session, current=self.user)
|
||||
assert sorted(all_ids["account_ids"]) == sorted([self.account.id, no_cookie.id])
|
||||
assert all_ids["total"] == 2
|
||||
|
||||
# ids 接口:search 匹配 uid
|
||||
searched = list_huya_account_ids(search="200", db=self.session, current=self.user)
|
||||
assert searched["account_ids"] == [no_cookie.id]
|
||||
|
||||
def test_account_delete_cleans_workbench_membership(self):
|
||||
self.session.add(
|
||||
HuyaWorkbenchAccount(
|
||||
|
||||
Reference in New Issue
Block a user