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

Function test_create_project

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

Test creating a new project.

(mock_request, orm_session, test_user)

Source from the content-addressed store, hash-verified

87
88@pytest.mark.asyncio
89async def test_create_project(mock_request, orm_session, test_user):
90 """Test creating a new project."""
91 # Create a fresh org and user-org relationship
92 org = OrgModel(name="Test Org for Create")
93 orm_session.add(org)
94 orm_session.flush()
95
96 # Add the test user as an owner of the org
97 user_id = mock_request.state.session.user_id
98 user_org = UserOrgModel(
99 user_id=user_id, org_id=org.id, role=OrgRoles.owner, user_email="test@example.com"
100 )
101 orm_session.add(user_org)
102 orm_session.flush()
103
104 # Create the request body
105 body = ProjectCreateSchema(
106 name="New Test Project", org_id=str(org.id), environment=Environment.staging.value
107 )
108
109 # Call the endpoint function
110 result = create_project(request=mock_request, orm=orm_session, body=body)
111
112 # Verify the project was created with the right data
113 assert result.name == body.name
114 assert result.org_id == body.org_id
115 assert result.environment == body.environment
116 assert result.api_key is not None
117
118 # Verify we can find it in the database
119 created_project = orm_session.query(ProjectModel).filter_by(id=uuid.UUID(result.id)).one()
120 assert created_project.name == body.name
121 assert created_project.environment == Environment.staging
122
123
124@pytest.mark.asyncio

Callers

nothing calls this directly

Calls 4

OrgModelClass · 0.90
UserOrgModelClass · 0.90
ProjectCreateSchemaClass · 0.90
create_projectFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…