34 lines
918 B
Python
34 lines
918 B
Python
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"
|