MCPcopy Create free account
hub / github.com/AgentOps-AI/agentops / test_get_projects

Function test_get_projects

app/api/tests/opsboard/views/test_projects.py:29–56  ·  view source on GitHub ↗

Test getting all projects for a user.

(mock_request, orm_session, test_user)

Source from the content-addressed store, hash-verified

27
28@pytest.mark.asyncio
29async def test_get_projects(mock_request, orm_session, test_user):
30 """Test getting all projects for a user."""
31 # Create an org first
32 org = OrgModel(name="Test Org for Projects")
33 orm_session.add(org)
34 orm_session.flush()
35
36 # Create a user-org relationship with the test user fixture
37 user_org = UserOrgModel(
38 user_id=test_user.id, org_id=org.id, role=OrgRoles.owner, user_email=test_user.email
39 )
40 orm_session.add(user_org)
41
42 # Create a project
43 project = ProjectModel(name="Test Project", org_id=org.id, environment=Environment.development)
44 orm_session.add(project)
45 orm_session.flush()
46
47 # Call the endpoint function
48 result = await get_projects(request=mock_request, orm=orm_session)
49
50 # Verify that it returns a list and the test project is in the results
51 assert isinstance(result, list)
52 assert len(result) > 0
53
54 # Check that our test project is in the results
55 project_ids = [p.id for p in result]
56 assert str(project.id) in project_ids
57
58
59@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 4

OrgModelClass · 0.90
UserOrgModelClass · 0.90
ProjectModelClass · 0.90
get_projectsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…