feat: enhance tool documentation and add unit test for slash-prefixed properties

This commit is contained in:
Daniel Bauer
2025-12-02 16:53:25 +01:00
parent 5451883739
commit 7b77186ced
3 changed files with 75 additions and 30 deletions

View File

@@ -464,6 +464,39 @@ class TestSearchObjects:
"nonexistent:data", object_type=None, page_size=25, page_num=0
)
@patch("cordra_mcp.server.cordra_client")
async def test_search_objects_with_slash_prefixed_properties(
self, mock_client: Any
) -> None:
"""Test object search with correct slash-prefixed property syntax."""
mock_search_result = {
"results": [
{
"id": "reports/2024-annual",
"type": "Document",
"content": {"title": "Annual Report 2024"},
},
],
"total_size": 1,
"page_num": 0,
"page_size": 25,
}
mock_client.find = AsyncMock(return_value=mock_search_result)
# Test with slash-prefixed property and nested property
result = await search_objects("/title:*report* AND /author/name:Daniel")
parsed_result = json.loads(result)
assert parsed_result["results"] == ["reports/2024-annual"]
assert parsed_result["total_count"] == 1
mock_client.find.assert_called_once_with(
"/title:*report* AND /author/name:Daniel",
object_type=None,
page_size=25,
page_num=0,
)
@patch("cordra_mcp.server.cordra_client")
async def test_search_objects_client_error(self, mock_client: Any) -> None:
"""Test object search with client error."""