Skip to content

Commit

Permalink
- implement the organization mutation
Browse files Browse the repository at this point in the history
- testcase updated
  • Loading branch information
sudan45 committed Apr 9, 2024
1 parent c59dade commit a1a7ee6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
2 changes: 1 addition & 1 deletion apps/organization/mutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Arguments:

@classmethod
def check_permissions(cls, info, **kwargs):
return True
return True # global permission is always True


class Mutation():
Expand Down
52 changes: 33 additions & 19 deletions apps/organization/tests/test_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,44 @@


class TestOrganizationMutation(GraphQLTestCase):
CREATE_ORGANIZATION = '''
mutation MyMutation ($input : OrganizationInputType!)
{
errors
ok
result {
id
longName
shortName
title
url
}
}
def test_orgainization_query(self):
self.organization_query = '''
mutation MyMutation ($input : OrganizationInputType!)
{
organizationCreate(data: $input){
errors
ok
result{
id
longName
shortName
title
url
}
}
}
'''

def setUp(self):
super().setUp()
self.member_user = UserFactory.create()
user = UserFactory.create()
minput = dict(
title="Test Organization",
shortName="Short Name",
longName="This is long name"
)

def test_create_organization(self):
def _query_check(minput, **kwargs):
return self.query_check(
self.CREATE_ORGANIZATION,
self.organization_query,
minput=minput,
**kwargs
)
# without login
_query_check(minput, assert_for_error=True)

# with login

self.force_login(user)

content = _query_check(minput)
self.assertEqual(content['data']['organizationCreate']['errors'], None)
self.assertEqual(content['data']['organizationCreate']['result']['title'], 'Test Organization')
16 changes: 16 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4273,6 +4273,7 @@ type MissingPredictionReviewType {
}

type Mutation {
organizationCreate(data: OrganizationInputType!): OrganizationCreate
createAssessmentRegSummaryIssue(data: AssessmentRegistrySummaryIssueCreateInputType!): AssessmentRegistryCreateIssue
fileUpload(data: FileUploadInputType!): UploadFile
genericExportCreate(data: GenericExportCreateInputType!): CreateUserGenericExport
Expand Down Expand Up @@ -4347,6 +4348,21 @@ enum NotificationTypeEnum {
ENTRY_REVIEW_COMMENT_MODIFY
}

type OrganizationCreate {
errors: [GenericScalar!]
ok: Boolean
result: OrganizationType
}

input OrganizationInputType {
title: String!
longName: String
url: String
shortName: String
logo: ID
organizationType: ID
}

type OrganizationListType {
results: [OrganizationType!]
totalCount: Int
Expand Down

0 comments on commit a1a7ee6

Please sign in to comment.