chore: ran linter and formatter
This commit is contained in:
@@ -52,7 +52,7 @@ class PromptBuilder:
|
|||||||
# Show first 5 results
|
# Show first 5 results
|
||||||
for i, result in enumerate(result_list[:5]):
|
for i, result in enumerate(result_list[:5]):
|
||||||
name = result.get("name", "Unknown")
|
name = result.get("name", "Unknown")
|
||||||
lines.append(f" {i+1}. {name}")
|
lines.append(f" {i + 1}. {name}")
|
||||||
if len(result_list) > 5:
|
if len(result_list) > 5:
|
||||||
lines.append(f" ... and {len(result_list) - 5} more")
|
lines.append(f" ... and {len(result_list) - 5} more")
|
||||||
|
|
||||||
|
|||||||
@@ -15,9 +15,9 @@ class TestPromptBuilderToolsInjection:
|
|||||||
|
|
||||||
# Verify each tool is mentioned
|
# Verify each tool is mentioned
|
||||||
for tool_name in tools.keys():
|
for tool_name in tools.keys():
|
||||||
assert (
|
assert tool_name in prompt, (
|
||||||
tool_name in prompt
|
f"Tool {tool_name} not mentioned in system prompt"
|
||||||
), f"Tool {tool_name} not mentioned in system prompt"
|
)
|
||||||
|
|
||||||
def test_tools_spec_contains_all_registered_tools(self, memory):
|
def test_tools_spec_contains_all_registered_tools(self, memory):
|
||||||
"""CRITICAL: Verify build_tools_spec() returns all tools."""
|
"""CRITICAL: Verify build_tools_spec() returns all tools."""
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ class TestToolSpecFormat:
|
|||||||
|
|
||||||
for spec in specs:
|
for spec in specs:
|
||||||
# OpenAI format requires these fields
|
# OpenAI format requires these fields
|
||||||
assert (
|
assert spec["type"] == "function", (
|
||||||
spec["type"] == "function"
|
f"Tool type must be 'function', got {spec.get('type')}"
|
||||||
), f"Tool type must be 'function', got {spec.get('type')}"
|
)
|
||||||
assert "function" in spec, "Tool spec missing 'function' key"
|
assert "function" in spec, "Tool spec missing 'function' key"
|
||||||
|
|
||||||
func = spec["function"]
|
func = spec["function"]
|
||||||
@@ -55,9 +55,9 @@ class TestToolSpecFormat:
|
|||||||
# Verify required vs optional
|
# Verify required vs optional
|
||||||
assert "name" in tool.parameters["required"], "name should be required"
|
assert "name" in tool.parameters["required"], "name should be required"
|
||||||
assert "age" in tool.parameters["required"], "age should be required"
|
assert "age" in tool.parameters["required"], "age should be required"
|
||||||
assert (
|
assert "active" not in tool.parameters["required"], (
|
||||||
"active" not in tool.parameters["required"]
|
"active has default, should not be required"
|
||||||
), "active has default, should not be required"
|
)
|
||||||
|
|
||||||
def test_all_registered_tools_are_callable(self):
|
def test_all_registered_tools_are_callable(self):
|
||||||
"""CRITICAL: Verify all registered tools are actually callable."""
|
"""CRITICAL: Verify all registered tools are actually callable."""
|
||||||
@@ -127,9 +127,9 @@ class TestToolSpecFormat:
|
|||||||
properties = params.get("properties", {})
|
properties = params.get("properties", {})
|
||||||
|
|
||||||
for param_name, param_spec in properties.items():
|
for param_name, param_spec in properties.items():
|
||||||
assert (
|
assert "description" in param_spec, (
|
||||||
"description" in param_spec
|
f"Parameter {param_name} in {spec['function']['name']} missing description"
|
||||||
), f"Parameter {param_name} in {spec['function']['name']} missing description"
|
)
|
||||||
|
|
||||||
def test_required_parameters_are_marked_correctly(self):
|
def test_required_parameters_are_marked_correctly(self):
|
||||||
"""Verify required parameters are correctly identified."""
|
"""Verify required parameters are correctly identified."""
|
||||||
|
|||||||
@@ -181,9 +181,9 @@ class TestMakeToolsEdgeCases:
|
|||||||
params = tool.parameters
|
params = tool.parameters
|
||||||
if "required" in params and "properties" in params:
|
if "required" in params and "properties" in params:
|
||||||
for req in params["required"]:
|
for req in params["required"]:
|
||||||
assert (
|
assert req in params["properties"], (
|
||||||
req in params["properties"]
|
f"Required param {req} not in properties for {tool.name}"
|
||||||
), f"Required param {req} not in properties for {tool.name}"
|
)
|
||||||
|
|
||||||
def test_make_tools_descriptions_not_empty(self, memory):
|
def test_make_tools_descriptions_not_empty(self, memory):
|
||||||
"""Should have non-empty descriptions."""
|
"""Should have non-empty descriptions."""
|
||||||
@@ -234,9 +234,9 @@ class TestMakeToolsEdgeCases:
|
|||||||
if "properties" in tool.parameters:
|
if "properties" in tool.parameters:
|
||||||
for prop_name, prop_schema in tool.parameters["properties"].items():
|
for prop_name, prop_schema in tool.parameters["properties"].items():
|
||||||
if "type" in prop_schema:
|
if "type" in prop_schema:
|
||||||
assert (
|
assert prop_schema["type"] in valid_types, (
|
||||||
prop_schema["type"] in valid_types
|
f"Invalid type for {tool.name}.{prop_name}"
|
||||||
), f"Invalid type for {tool.name}.{prop_name}"
|
)
|
||||||
|
|
||||||
def test_make_tools_enum_values(self, memory):
|
def test_make_tools_enum_values(self, memory):
|
||||||
"""Should have valid enum values."""
|
"""Should have valid enum values."""
|
||||||
|
|||||||
@@ -226,13 +226,13 @@ class TestJsonTVShowRepository:
|
|||||||
[ShowStatus.ONGOING, ShowStatus.ENDED, ShowStatus.UNKNOWN]
|
[ShowStatus.ONGOING, ShowStatus.ENDED, ShowStatus.UNKNOWN]
|
||||||
):
|
):
|
||||||
show = TVShow(
|
show = TVShow(
|
||||||
imdb_id=ImdbId(f"tt{i+1000000:07d}"),
|
imdb_id=ImdbId(f"tt{i + 1000000:07d}"),
|
||||||
title=f"Show {status.value}",
|
title=f"Show {status.value}",
|
||||||
seasons_count=1,
|
seasons_count=1,
|
||||||
status=status,
|
status=status,
|
||||||
)
|
)
|
||||||
repo.save(show)
|
repo.save(show)
|
||||||
loaded = repo.find_by_imdb_id(ImdbId(f"tt{i+1000000:07d}"))
|
loaded = repo.find_by_imdb_id(ImdbId(f"tt{i + 1000000:07d}"))
|
||||||
assert loaded.status == status
|
assert loaded.status == status
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user