Files
python-sdk/pkg/hanzo-mcp/tests/test_memory_basic.py
T
zeekay 7ff34ba5bf feat(hanzo-tools): v0.10.17 - modular tool packages + computer control
- Add hanzo-tools-computer package for pyautogui Mac automation
- Fix hanzo-tools-agent imports to use new package structure
- Add get_read_only_*_tools() helpers to filesystem/jupyter
- Remove BatchTool (replaced by dag - one tool per capability)
- Remove hanzo-persona dependency (not published yet)
- Simplify pyproject.toml for local development

Packages ready for PyPI:
- hanzo-tools-core
- hanzo-tools-filesystem
- hanzo-tools-shell
- hanzo-tools-browser
- hanzo-tools-memory
- hanzo-tools-todo
- hanzo-tools-reasoning
- hanzo-tools-lsp
- hanzo-tools-refactor
- hanzo-tools-database
- hanzo-tools-agent
- hanzo-tools-jupyter
- hanzo-tools-editor
- hanzo-tools-computer (NEW)
2025-12-26 06:37:28 -08:00

68 lines
2.3 KiB
Python

"""Basic memory test to debug issues."""
import asyncio
from datetime import datetime
from unittest.mock import Mock, AsyncMock, patch
def test_basic_memory():
"""Basic test without pytest complexity."""
with patch("hanzo_memory.services.memory.get_memory_service") as mock_get_service:
with patch("hanzo_tools.memory.memory_tools.create_tool_context") as mock_create_tool_context:
# Mock the tool context
mock_tool_ctx = Mock()
mock_tool_ctx.set_tool_info = AsyncMock()
mock_tool_ctx.info = AsyncMock()
mock_tool_ctx.send_completion_ping = AsyncMock()
mock_create_tool_context.return_value = mock_tool_ctx
# Mock the memory service
mock_service = Mock()
mock_get_service.return_value = mock_service
# Mock memory creation
from hanzo_memory.models.memory import Memory
mock_memory = Memory(
memory_id="test_123",
user_id="test_user",
project_id="test_project",
content="Test memory content",
metadata={"type": "statement"},
importance=1.0,
created_at=datetime.fromisoformat("2024-01-01T00:00:00"),
updated_at=datetime.fromisoformat("2024-01-01T00:00:00"),
embedding=[0.1] * 1536,
)
mock_service.create_memory.return_value = mock_memory
# Create and test the tool
from hanzo_tools.memory.memory_tools import CreateMemoriesTool
tool = CreateMemoriesTool(user_id="test_user", project_id="test_project")
# Mock context
mock_ctx = Mock()
mock_ctx.request_id = "test-request-id"
# Call the tool
result = asyncio.run(
tool.call(
mock_ctx,
statements=["This is a test memory", "This is another test"],
)
)
print(f"Result: {result}")
print(f"create_memory called: {mock_service.create_memory.call_count} times")
# Check result
assert "Successfully created 2 new memories" in str(result)
assert mock_service.create_memory.call_count == 2
print("Test passed!")
if __name__ == "__main__":
test_basic_memory()