Skip to main content
Glama

Aidderall MCP Server

by cheezcake
test_handlers.py7.88 kB
# Aidderall MCP Server - Hierarchical task management for AI assistants # Copyright (C) 2024 Briam R. <briamr@gmail.com> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. import asyncio import pytest from src.handlers import AidderallHandlers from src.task_manager import TaskManager class TestHandlers: def setup_method(self): self.task_manager = TaskManager() self.handlers = AidderallHandlers(self.task_manager) @pytest.mark.asyncio async def test_handle_create_new_task(self): result = await self.handlers.handle_create_new_task("Test Task", "Test Body") assert "task_id" in result assert result["message"] == "Created independent task: Test Task" assert result["is_current"] is True assert len(self.task_manager.global_tasks) == 1 @pytest.mark.asyncio async def test_handle_extend_current_task(self): await self.handlers.handle_create_new_task("Main Task", "Main Body") result = await self.handlers.handle_extend_current_task("Sub Task", "Sub Body") assert "task_id" in result assert result["message"] == "Added subtask: Sub Task" assert result["is_current"] is True @pytest.mark.asyncio async def test_handle_extend_current_task_error(self): result = await self.handlers.handle_extend_current_task("Sub Task", "Sub Body") assert "error" in result @pytest.mark.asyncio async def test_handle_get_current_task_zen(self): result = await self.handlers.handle_get_current_task() assert result["message"] == "No tasks (zen state)" assert result["zen_state"] is True @pytest.mark.asyncio async def test_handle_get_current_task(self): await self.handlers.handle_create_new_task("Task", "Body") result = await self.handlers.handle_get_current_task() assert "task_id" in result assert result["title"] == "Task" assert result["body"] == "Body" assert result["stack_depth"] == 1 assert len(result["siblings_to_left"]) == 0 @pytest.mark.asyncio async def test_handle_get_big_picture(self): result = await self.handlers.handle_get_big_picture() assert result["structure"] == "No tasks (zen state)" await self.handlers.handle_create_new_task("Task", "Body") result = await self.handlers.handle_get_big_picture() assert "Task (current) <-- YOU ARE HERE" in result["structure"] @pytest.mark.asyncio async def test_handle_complete_current_task(self): await self.handlers.handle_create_new_task("Task", "Body") result = await self.handlers.handle_complete_current_task() assert "completed_task_id" in result assert result["completed_task_title"] == "Task" assert result["new_current_task_title"] == "Task" # Task stays in structure @pytest.mark.asyncio async def test_handle_complete_current_task_error(self): result = await self.handlers.handle_complete_current_task() assert result["error"] == "No current task to complete" @pytest.mark.asyncio async def test_handle_get_completed_tasks(self): await self.handlers.handle_create_new_task("Task 1", "Body 1") await self.handlers.handle_complete_current_task() result = await self.handlers.handle_get_completed_tasks() assert result["count"] == 1 assert len(result["tasks"]) == 1 assert result["tasks"][0]["title"] == "Task 1" @pytest.mark.asyncio async def test_handle_update_current_task(self): await self.handlers.handle_create_new_task("Task", "Original") result = await self.handlers.handle_update_current_task("Updated") assert result["message"] == "Task body updated successfully" assert self.task_manager.current_task.body == "Updated" @pytest.mark.asyncio async def test_handle_update_current_task_error(self): result = await self.handlers.handle_update_current_task("Body") assert "error" in result @pytest.mark.asyncio async def test_handle_get_stack_overview(self): result = await self.handlers.handle_get_stack_overview() assert result["zen_state"] is True assert result["stack_depth"] == 0 @pytest.mark.asyncio async def test_handle_peek_context(self): await self.handlers.handle_create_new_task("Main", "Body") await self.handlers.handle_extend_current_task("Sub", "Sub Body") result = await self.handlers.handle_peek_context() assert result["parent_context"]["title"] == "Main" assert result["immediate_context"] is None @pytest.mark.asyncio async def test_handle_list_siblings(self): await self.handlers.handle_create_new_task("Main", "Body") await self.handlers.handle_extend_current_task("Sub 1", "Body 1") await self.handlers.handle_extend_current_task("Sub 2", "Body 2") result = await self.handlers.handle_list_siblings() assert result["count"] == 1 assert result["siblings"][0]["title"] == "Sub 1" def test_get_tool_definitions(self): tools = self.handlers.get_tool_definitions() assert len(tools) == 12 tool_names = [tool.name for tool in tools] expected_names = [ "create_new_task", "extend_current_task", "get_current_task", "get_big_picture", "complete_current_task", "get_completed_tasks", "update_current_task", "get_stack_overview", "peek_context", "list_siblings", "switch_focus", "remove_task", ] for name in expected_names: assert name in tool_names @pytest.mark.asyncio async def test_handle_switch_focus(self): # Create tasks result1 = await self.handlers.handle_create_new_task("Task 1", "Body 1") task1_id = result1["task_id"] result2 = await self.handlers.handle_create_new_task("Task 2", "Body 2") task2_id = result2["task_id"] # Switch to task 1 result = await self.handlers.handle_switch_focus(task1_id) assert result["success"] is True assert "Task 1" in result["message"] assert task1_id in result["task_id"] # Try to switch to same task result = await self.handlers.handle_switch_focus(task1_id) assert result["success"] is True assert "already the current focus" in result["message"] # Try invalid task ID result = await self.handlers.handle_switch_focus("invalid-id") assert "error" in result @pytest.mark.asyncio async def test_handle_remove_task(self): # Create tasks result1 = await self.handlers.handle_create_new_task("Task 1", "Body 1") task1_id = result1["task_id"] result2 = await self.handlers.handle_create_new_task("Task 2", "Body 2") # Remove task 1 result = await self.handlers.handle_remove_task(task1_id) assert result["success"] is True assert "Task 1" in result["message"] # Try to remove non-existent task result = await self.handlers.handle_remove_task("invalid-id") assert "error" in result

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cheezcake/aidderall_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server