Import tool setting
This commit is contained in:
33
engine/tests/test_tool_executor.py
Normal file
33
engine/tests/test_tool_executor.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import pytest
|
||||
|
||||
from core.tool_executor import execute_server_tool
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_code_interpreter_simple_expression():
|
||||
result = await execute_server_tool(
|
||||
{
|
||||
"id": "call_ci_ok",
|
||||
"function": {
|
||||
"name": "code_interpreter",
|
||||
"arguments": '{"code":"sum([1, 2, 3]) + 4"}',
|
||||
},
|
||||
}
|
||||
)
|
||||
assert result["status"]["code"] == 200
|
||||
assert result["output"]["result"] == 10
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_code_interpreter_blocks_import_and_io():
|
||||
result = await execute_server_tool(
|
||||
{
|
||||
"id": "call_ci_bad",
|
||||
"function": {
|
||||
"name": "code_interpreter",
|
||||
"arguments": '{"code":"__import__(\\"os\\").system(\\"ls\\")"}',
|
||||
},
|
||||
}
|
||||
)
|
||||
assert result["status"]["code"] == 422
|
||||
assert result["status"]["message"] == "invalid_code"
|
||||
Reference in New Issue
Block a user