feat: implement DCOS source tree, tests, and build configuration
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
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Protocol tests."""
|
||||
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
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"
|
||||
@@ -0,0 +1,27 @@
|
||||
"""
|
||||
Tests for UserInterface.
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from dcos.protocols.user_interface import UserInterface, UserRequest, SystemResponse
|
||||
|
||||
|
||||
class TestUserInterface:
|
||||
def test_process_input(self):
|
||||
ui = UserInterface()
|
||||
request = UserRequest(input="hello", user_id="user_1")
|
||||
parsed = ui.process_input(request)
|
||||
assert parsed["intent"] == "query"
|
||||
|
||||
def test_format_response(self):
|
||||
ui = UserInterface()
|
||||
response = SystemResponse(output="Hello!", agent_id="agent_1")
|
||||
formatted = ui.format_response(response)
|
||||
assert "[agent_1]" in formatted
|
||||
|
||||
def test_history(self):
|
||||
ui = UserInterface()
|
||||
ui.format_response(SystemResponse(output="msg1", agent_id="a"))
|
||||
ui.format_response(SystemResponse(output="msg2", agent_id="b"))
|
||||
history = ui.get_history()
|
||||
assert len(history) == 2
|
||||
Reference in New Issue
Block a user