Skip to content

Commit

Permalink
- add query of project roles
Browse files Browse the repository at this point in the history
- test case updated
  • Loading branch information
sudan45 committed Apr 23, 2024
1 parent 3a1cbc7 commit 33a771c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apps/project/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ class Query:
recent_projects = graphene.List(graphene.NonNull(ProjectDetailType))
recent_activities = graphene.List(graphene.NonNull(RecentActivityType))
project_explore_stats = graphene.Field(ProjectExploreStatType)
project_roles = graphene.List(graphene.NonNull(ProjectRoleType))

# only the region for which project are public
projects_by_region = DjangoPaginatedListObjectField(ProjectByRegionListType)
Expand Down Expand Up @@ -650,3 +651,7 @@ def resolve_public_projects_by_region(*args, **kwargs):
@staticmethod
def resolve_user_pinned_project(root, info, **kwargs):
return ProjectPinned.objects.filter(user=info.context.user)

@staticmethod
def resolve_project_roles(root, info) -> QuerySet:
return ProjectRole.objects.all()
23 changes: 23 additions & 0 deletions apps/project/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ProjectUserGroupMembership,
ProjectStats,
Project,
ProjectRole,
)
from deep.permissions import ProjectPermissions as PP
from deep.caches import CacheKey
Expand Down Expand Up @@ -1003,6 +1004,28 @@ def _query_check(project_id, **kwargs):
# It's inactive as ahead by Project.PROJECT_INACTIVE_AFTER_MONTHS
assert project.status == Project.Status.INACTIVE

def test_project_role(self):
query = '''
query MyQuery {
projectRoles{
id
level
title
type
}
}
'''
user = UserFactory.create()

# without login
self.query_check(query, assert_for_error=True)
# with login
self.force_login(user)
project_role_count = ProjectRole.objects.count()
content = self.query_check(query)
self.assertEqual(len(content['data']['projectRoles']), project_role_count)


class TestProjectViz(GraphQLTestCase):
ENABLE_NOW_PATCHER = True
Expand Down
1 change: 1 addition & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5060,6 +5060,7 @@ type Query {
recentProjects: [ProjectDetailType!]
recentActivities: [RecentActivityType!]
projectExploreStats: ProjectExploreStatType
projectRoles: [ProjectRoleType!]
projectsByRegion(projectFilter: RegionProjectFilterData, ordering: String): ProjectByRegionListType
publicProjects(createdAt: DateTime, createdAtGte: DateTime, createdAtLte: DateTime, modifiedAt: DateTime, modifiedAtGte: DateTime, modifiedAtLte: DateTime, createdBy: [ID!], modifiedBy: [ID!], ids: [ID!], excludeIds: [ID!], status: ProjectStatusEnum, organizations: [ID!], analysisFrameworks: [ID!], regions: [ID!], search: String, isCurrentUserMember: Boolean, hasPermissionAccess: ProjectPermission, ordering: [PublicProjectOrderingEnum!], isTest: Boolean, page: Int = 1, pageSize: Int): PublicProjectListType
publicProjectsByRegion(projectFilter: RegionProjectFilterData, page: Int = 1, ordering: String, pageSize: Int): PublicProjectByRegionListType
Expand Down

0 comments on commit 33a771c

Please sign in to comment.