Complete implementation of the DCOS package including: - 40+ Python source files across agents, communication, core, learning, memory, protocols, utils - pyproject.toml build configuration - 102 unit tests across all subsystems - Fixed flake.nix (Python 3.12, proper dependencies, pyproject build) - Fixed .woodpecker.yml (correct paths, removed silent-fail flags) - Added .gitignore - Cleared stale pytest cache
36 lines
1016 B
Python
36 lines
1016 B
Python
"""
|
|
Tests for ExternalTools.
|
|
"""
|
|
|
|
import pytest
|
|
from dcos.protocols.external_tools import ExternalTools
|
|
|
|
|
|
def sample_handler(param: str) -> str:
|
|
return f"handled: {param}"
|
|
|
|
|
|
class TestExternalTools:
|
|
def test_register_and_execute(self):
|
|
tools = ExternalTools()
|
|
tools.register_tool("sample", sample_handler)
|
|
result = tools.execute("sample", {"param": "test"})
|
|
assert result == "handled: test"
|
|
|
|
def test_list_tools(self):
|
|
tools = ExternalTools()
|
|
tools.register_tool("tool_a", sample_handler)
|
|
tools.register_tool("tool_b", sample_handler)
|
|
assert len(tools.list_tools()) == 2
|
|
|
|
def test_missing_tool(self):
|
|
tools = ExternalTools()
|
|
with pytest.raises(KeyError):
|
|
tools.execute("nonexistent", {})
|
|
|
|
def test_get_result(self):
|
|
tools = ExternalTools()
|
|
tools.register_tool("calc", sample_handler)
|
|
tools.execute("calc", {"param": "42"})
|
|
assert tools.get_result("calc") == "handled: 42"
|