feat: added proper settings handling

This commit is contained in:
2026-01-01 03:55:23 +01:00
parent 8b406370f1
commit c50091f6bf
23 changed files with 440 additions and 328 deletions
+10 -9
View File
@@ -6,6 +6,7 @@ import pytest
from alfred.agent.prompts import PromptBuilder
from alfred.agent.registry import Tool, _create_tool_from_function, make_tools
from alfred.settings import settings
class TestToolSpecFormat:
@@ -13,7 +14,7 @@ class TestToolSpecFormat:
def test_tool_spec_format_is_openai_compatible(self):
"""CRITICAL: Verify tool specs are OpenAI-compatible."""
tools = make_tools()
tools = make_tools(settings)
builder = PromptBuilder(tools)
specs = builder.build_tools_spec()
@@ -62,7 +63,7 @@ class TestToolSpecFormat:
def test_all_registered_tools_are_callable(self):
"""CRITICAL: Verify all registered tools are actually callable."""
tools = make_tools()
tools = make_tools(settings)
assert len(tools) > 0, "No tools registered"
@@ -78,7 +79,7 @@ class TestToolSpecFormat:
def test_tools_spec_contains_all_registered_tools(self):
"""CRITICAL: Verify build_tools_spec() returns all registered tools."""
tools = make_tools()
tools = make_tools(settings)
builder = PromptBuilder(tools)
specs = builder.build_tools_spec()
@@ -119,7 +120,7 @@ class TestToolSpecFormat:
def test_tool_parameters_have_descriptions(self):
"""Verify all tool parameters have descriptions."""
tools = make_tools()
tools = make_tools(settings)
builder = PromptBuilder(tools)
specs = builder.build_tools_spec()
@@ -150,28 +151,28 @@ class TestToolRegistry:
def test_make_tools_returns_dict(self):
"""Verify make_tools returns a dictionary."""
tools = make_tools()
tools = make_tools(settings)
assert isinstance(tools, dict)
assert len(tools) > 0
def test_all_tools_have_unique_names(self):
"""Verify all tool names are unique."""
tools = make_tools()
tools = make_tools(settings)
names = [tool.name for tool in tools.values()]
assert len(names) == len(set(names)), "Duplicate tool names found"
def test_tool_names_match_dict_keys(self):
"""Verify tool names match their dictionary keys."""
tools = make_tools()
tools = make_tools(settings)
for key, tool in tools.items():
assert key == tool.name, f"Key {key} doesn't match tool name {tool.name}"
def test_expected_tools_are_registered(self):
"""Verify all expected tools are registered."""
tools = make_tools()
tools = make_tools(settings)
expected_tools = [
"set_path_for_folder",
@@ -189,7 +190,7 @@ class TestToolRegistry:
def test_tool_functions_are_valid(self):
"""Verify all tool functions are properly structured."""
tools = make_tools()
tools = make_tools(settings)
# Verify structure without calling functions
# (calling would require full setup with memory, clients, etc.)