mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
- Remove all unconditional pytest.skip() calls - Fix file content tests to handle both strict/non-strict modes - Fix missing device_capabilities module in hanzo-network - Fix HanzoNetProvider imports and exports - Fix local_llm.py import errors - Create test helper classes for pagination tests - Fix FastMCP paginator test constructor args - Configure all API keys from ~/.zsh/after.zsh - All tests now pass or skip conditionally based on actual requirements
52 lines
1.9 KiB
Python
52 lines
1.9 KiB
Python
import pytest
|
|
|
|
from dev_aci.editor.exceptions import (
|
|
EditorToolParameterInvalidError,
|
|
EditorToolParameterMissingError,
|
|
ToolError,
|
|
)
|
|
|
|
|
|
def test_tool_error():
|
|
"""Test ToolError raises with correct message."""
|
|
with pytest.raises(ToolError) as exc_info:
|
|
raise ToolError("A tool error occurred")
|
|
assert str(exc_info.value) == "A tool error occurred"
|
|
|
|
|
|
def test_editor_tool_parameter_missing_error():
|
|
"""Test EditorToolParameterMissingError for missing parameter error message."""
|
|
command = "str_replace"
|
|
parameter = "old_str"
|
|
with pytest.raises(EditorToolParameterMissingError) as exc_info:
|
|
raise EditorToolParameterMissingError(command, parameter)
|
|
assert exc_info.value.command == command
|
|
assert exc_info.value.parameter == parameter
|
|
assert (
|
|
exc_info.value.message
|
|
== f"Parameter `{parameter}` is required for command: {command}."
|
|
)
|
|
|
|
|
|
def test_editor_tool_parameter_invalid_error_with_hint():
|
|
"""Test EditorToolParameterInvalidError with hint."""
|
|
parameter = "timeout"
|
|
value = -10
|
|
hint = "Must be a positive integer."
|
|
with pytest.raises(EditorToolParameterInvalidError) as exc_info:
|
|
raise EditorToolParameterInvalidError(parameter, value, hint)
|
|
assert exc_info.value.parameter == parameter
|
|
assert exc_info.value.value == value
|
|
assert exc_info.value.message == f"Invalid `{parameter}` parameter: {value}. {hint}"
|
|
|
|
|
|
def test_editor_tool_parameter_invalid_error_without_hint():
|
|
"""Test EditorToolParameterInvalidError without hint."""
|
|
parameter = "timeout"
|
|
value = -10
|
|
with pytest.raises(EditorToolParameterInvalidError) as exc_info:
|
|
raise EditorToolParameterInvalidError(parameter, value)
|
|
assert exc_info.value.parameter == parameter
|
|
assert exc_info.value.value == value
|
|
assert exc_info.value.message == f"Invalid `{parameter}` parameter: {value}."
|