42c11dedae
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57 lines
2.0 KiB
Python
57 lines
2.0 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
|
|
|
|
|
|
def test_strip_type_nouns_removes_task_word():
|
|
from fabledassistant.services.notes import _strip_type_nouns
|
|
assert _strip_type_nouns("sebring secondary task") == ["sebring", "secondary"]
|
|
|
|
|
|
def test_strip_type_nouns_removes_all_variants():
|
|
from fabledassistant.services.notes import _strip_type_nouns
|
|
assert _strip_type_nouns("project notes task") == []
|
|
|
|
|
|
def test_strip_type_nouns_case_insensitive():
|
|
from fabledassistant.services.notes import _strip_type_nouns
|
|
assert _strip_type_nouns("Sebring Task NOTES") == ["Sebring"]
|
|
|
|
|
|
def test_strip_type_nouns_preserves_real_content_words():
|
|
from fabledassistant.services.notes import _strip_type_nouns
|
|
assert _strip_type_nouns("circuit configuration") == ["circuit", "configuration"]
|
|
|
|
|
|
def test_strip_type_nouns_handles_empty_string():
|
|
from fabledassistant.services.notes import _strip_type_nouns
|
|
assert _strip_type_nouns("") == []
|
|
assert _strip_type_nouns(" ") == []
|