Files
FabledScribe/tests/test_tool_use_fixes.py
T
2026-05-12 16:40:27 -04:00

31 lines
1.1 KiB
Python

"""Tests for the tool-use fixes from the 2026-05-08 journal session."""
from types import SimpleNamespace
from unittest.mock import AsyncMock, patch
import pytest
def _project(pid: int, title: str, description: str = "", auto_summary: str = ""):
return SimpleNamespace(
id=pid, title=title, description=description, auto_summary=auto_summary,
)
@pytest.mark.asyncio
async def test_search_projects_tool_returns_success_true():
"""The dispatcher sets status from result['success']; without this key
the call gets labeled 'error' even when data is returned."""
from fabledassistant.services.tools import projects as projects_tool
fake_projects = [_project(5, "Famous-Supply Work topics", "AT&T fiber circuit")]
with patch.object(projects_tool, "list_projects", new=AsyncMock(return_value=fake_projects)):
result = await projects_tool.search_projects_tool(
user_id=1, arguments={"query": "famous supply"},
)
assert result["success"] is True
assert result["type"] == "projects_list"
assert len(result["data"]["projects"]) == 1