28 行
852 B
Python
28 行
852 B
Python
|
|
from adapters.astrbot_command_adapter import ChatCommandContext
|
||
|
|
from backend.services.chat_workflow_service import ChatWorkflowService
|
||
|
|
|
||
|
|
|
||
|
|
def test_chat_request_context_preserves_platform_and_session_origin() -> None:
|
||
|
|
service = ChatWorkflowService(
|
||
|
|
lambda *_args, **_kwargs: {"ok": True, "data": {}},
|
||
|
|
config_loader=lambda: {
|
||
|
|
"chat_access": {
|
||
|
|
"group_allowlist": ["group-a"],
|
||
|
|
"user_allowlist": ["user-a"],
|
||
|
|
}
|
||
|
|
},
|
||
|
|
)
|
||
|
|
chat = ChatCommandContext(
|
||
|
|
platform="qq",
|
||
|
|
user_id="user-a",
|
||
|
|
group_id="group-a",
|
||
|
|
message_origin="origin-a",
|
||
|
|
message_id="message-a",
|
||
|
|
)
|
||
|
|
|
||
|
|
ctx = service._request_context(chat, "character_workflow")
|
||
|
|
|
||
|
|
assert ctx.platform == "qq"
|
||
|
|
assert ctx.session_key == "origin-a"
|
||
|
|
assert ctx.actor_id == "user-a"
|