Spaces:
Build error
Build error
| """Test script to verify MCP tools work correctly.""" | |
| import sys | |
| sys.path.insert(0, '.') | |
| from app.database import init_db, SessionLocal | |
| from app.models import User, generate_user_id | |
| from app.tools.projects import create_project, list_projects, join_project | |
| from app.tools.tasks import create_task, list_tasks, list_activity | |
| def create_test_user(first_name: str, last_name: str) -> str: | |
| """Create a test user and return their ID.""" | |
| db = SessionLocal() | |
| try: | |
| user_id = generate_user_id(first_name) | |
| user = User(id=user_id, first_name=first_name, last_name=last_name) | |
| db.add(user) | |
| db.commit() | |
| return user.id | |
| finally: | |
| db.close() | |
| def main(): | |
| # Initialize database | |
| print("Initializing database...") | |
| init_db() | |
| # Create test users | |
| print("\n1. Creating test users...") | |
| user1_id = create_test_user("Alice", "Developer") | |
| user2_id = create_test_user("Bob", "Engineer") | |
| print(f" Created User 1: {user1_id}") | |
| print(f" Created User 2: {user2_id}") | |
| # Test create_project | |
| print("\n2. Testing create_project...") | |
| project = create_project( | |
| name="AI Memory System", | |
| description="Building a shared AI memory for dev teams", | |
| user_id=user1_id | |
| ) | |
| print(f" Created project: {project}") | |
| project_id = project["id"] | |
| # Test list_projects | |
| print("\n3. Testing list_projects...") | |
| projects = list_projects(user_id=user1_id) | |
| print(f" User 1's projects: {projects}") | |
| # Test join_project | |
| print("\n4. Testing join_project...") | |
| join_result = join_project(project_id=project_id, user_id=user2_id) | |
| print(f" Join result: {join_result}") | |
| # Verify User 2 now sees the project | |
| projects2 = list_projects(user_id=user2_id) | |
| print(f" User 2's projects: {projects2}") | |
| # Test create_task | |
| print("\n5. Testing create_task...") | |
| task1 = create_task( | |
| project_id=project_id, | |
| title="Set up database schema", | |
| description="Create SQLAlchemy models for all entities", | |
| assigned_to=user1_id | |
| ) | |
| print(f" Created task 1: {task1}") | |
| task2 = create_task( | |
| project_id=project_id, | |
| title="Implement MCP server", | |
| description="Set up MCP server with tool definitions" | |
| ) | |
| print(f" Created task 2: {task2}") | |
| # Test list_tasks | |
| print("\n6. Testing list_tasks...") | |
| tasks = list_tasks(project_id=project_id) | |
| print(f" All tasks: {tasks}") | |
| # Test list_tasks with status filter | |
| print("\n7. Testing list_tasks with status filter...") | |
| todo_tasks = list_tasks(project_id=project_id, status="todo") | |
| print(f" Todo tasks: {todo_tasks}") | |
| # Test list_activity (should be empty initially) | |
| print("\n8. Testing list_activity...") | |
| activity = list_activity(project_id=project_id) | |
| print(f" Activity (empty expected): {activity}") | |
| print("\n✅ All Foundation Layer tests passed!") | |
| print("\nReady for Dev B to implement:") | |
| print(" - complete_task (with LLM documentation generation)") | |
| print(" - memory_search (with vector search)") | |
| if __name__ == "__main__": | |
| main() | |