feat(douyu): include binding roles in batch verification
Expose CK and binding-role validity from batch verification and summarize invalid CK, missing roles, and request failures in the collaboration workbench.
This commit is contained in:
@@ -1482,6 +1482,77 @@ class TestDouyuCollabOrders:
|
||||
assert "douyu:collab:ck_export" in ROLE_PERMISSIONS["super_admin"]
|
||||
assert "douyu:collab:ck_export" not in ROLE_PERMISSIONS["support"]
|
||||
|
||||
def test_batch_verify_returns_ck_and_binding_role_results(self, monkeypatch):
|
||||
first = collab.create_order(
|
||||
self.session,
|
||||
self.admin,
|
||||
order_no="DY-BATCH-VERIFY-1",
|
||||
account_username="douyu-account-a",
|
||||
draft=True,
|
||||
)
|
||||
second = collab.create_order(
|
||||
self.session,
|
||||
self.admin,
|
||||
order_no="DY-BATCH-VERIFY-2",
|
||||
account_username="douyu-account-a",
|
||||
draft=True,
|
||||
)
|
||||
orders = {first.id: first, second.id: second}
|
||||
|
||||
monkeypatch.setattr(
|
||||
collab,
|
||||
"get_order",
|
||||
lambda _db, order_id: orders[order_id],
|
||||
)
|
||||
|
||||
def fake_verify(_db, _current, order):
|
||||
if order.id == first.id:
|
||||
probe = {
|
||||
"ok": True,
|
||||
"ck_status": collab.CK_VALID,
|
||||
"bind_game_role": "角色A",
|
||||
"message": "",
|
||||
}
|
||||
else:
|
||||
probe = {
|
||||
"ok": False,
|
||||
"ck_status": collab.CK_VALID,
|
||||
"bind_game_role": "",
|
||||
"message": "绑定角色: 未绑定",
|
||||
}
|
||||
return {"order": order, "probe": probe}
|
||||
|
||||
monkeypatch.setattr(collab, "verify_order", fake_verify)
|
||||
monkeypatch.setattr(
|
||||
collab_api, "_publish_change", lambda *_args, **_kwargs: None
|
||||
)
|
||||
|
||||
result = collab_api.verify_external_orders_batch(
|
||||
[first.id, second.id],
|
||||
db=self.session,
|
||||
current=self.admin,
|
||||
)
|
||||
|
||||
assert result["success"] is True
|
||||
assert result["results"][0] == {
|
||||
"id": first.id,
|
||||
"success": True,
|
||||
"ok": True,
|
||||
"ck_status": collab.CK_VALID,
|
||||
"role": "角色A",
|
||||
"role_ok": True,
|
||||
"message": "",
|
||||
}
|
||||
assert result["results"][1] == {
|
||||
"id": second.id,
|
||||
"success": True,
|
||||
"ok": False,
|
||||
"ck_status": collab.CK_VALID,
|
||||
"role": "",
|
||||
"role_ok": False,
|
||||
"message": "绑定角色: 未绑定",
|
||||
}
|
||||
|
||||
def test_douyu_collab_routes_registered(self):
|
||||
from web.backend.main import app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user