统一推送前Python代码格式
This commit is contained in:
@@ -26,7 +26,9 @@ class TestHuyaWorkbenchScope:
|
||||
Base.metadata.create_all(self.engine)
|
||||
self.session = sessionmaker(bind=self.engine)()
|
||||
self.user = User(username="operator", password_hash="hash", role="super_admin")
|
||||
self.account = HuyaAccount(uid="100", yyuid="100", cookie="yyuid=100; udb_uid=100")
|
||||
self.account = HuyaAccount(
|
||||
uid="100", yyuid="100", cookie="yyuid=100; udb_uid=100"
|
||||
)
|
||||
self.session.add_all([self.user, self.account])
|
||||
self.session.commit()
|
||||
|
||||
@@ -37,11 +39,15 @@ class TestHuyaWorkbenchScope:
|
||||
|
||||
def test_accounts_and_tasks_are_scoped(self):
|
||||
update_huya_workbench_accounts(
|
||||
HuyaWorkbenchAccountsUpdate(handbook_scope="elite", account_ids=[self.account.id]),
|
||||
HuyaWorkbenchAccountsUpdate(
|
||||
handbook_scope="elite", account_ids=[self.account.id]
|
||||
),
|
||||
db=self.session,
|
||||
current=self.user,
|
||||
)
|
||||
result = list_huya_workbench_accounts("elite", db=self.session, current=self.user)
|
||||
result = list_huya_workbench_accounts(
|
||||
"elite", db=self.session, current=self.user
|
||||
)
|
||||
assert result == {"account_ids": [self.account.id], "configured": True}
|
||||
assert self.session.query(HuyaWorkbench).count() == 1
|
||||
|
||||
@@ -77,29 +83,39 @@ class TestHuyaWorkbenchScope:
|
||||
self.session.commit()
|
||||
|
||||
update_huya_workbench_accounts(
|
||||
HuyaWorkbenchAccountsUpdate(handbook_scope="browser_exchange", account_ids=[self.account.id]),
|
||||
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) == {
|
||||
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) == {
|
||||
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)
|
||||
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)
|
||||
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):
|
||||
|
||||
Reference in New Issue
Block a user