- Expanded package inclusion in `pyproject.toml` to support new modules. - Introduced new `adapters` and `protocol` packages for better organization. - Added backend adapter implementations for control plane integration. - Updated main application imports to reflect new package structure. - Removed deprecated core components and adjusted documentation accordingly. - Enhanced architecture documentation to clarify the new runtime and integration layers.
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
import pytest
|
|
|
|
from tools.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"
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_current_time_uses_local_system_clock(monkeypatch):
|
|
async def _should_not_be_called(_tool_id):
|
|
raise AssertionError("fetch_tool_resource should not be called for current_time")
|
|
|
|
monkeypatch.setattr("tools.executor.fetch_tool_resource", _should_not_be_called)
|
|
|
|
result = await execute_server_tool(
|
|
{
|
|
"id": "call_time_ok",
|
|
"function": {
|
|
"name": "current_time",
|
|
"arguments": "{}",
|
|
},
|
|
}
|
|
)
|
|
|
|
assert result["status"]["code"] == 200
|
|
assert result["status"]["message"] == "ok"
|
|
assert "local_time" in result["output"]
|
|
assert "iso" in result["output"]
|
|
assert "timestamp" in result["output"]
|