File size: 3,201 Bytes
35765b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""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()