Skip to content

Commit

Permalink
Update testcase of organization mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
sudan45 committed May 2, 2024
1 parent 1368af0 commit a3a588c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 21 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
1 change: 0 additions & 1 deletion apps/organization/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,4 @@ class Meta:
class OrganizationGqSerializer(UserResourceSerializer):
class Meta:
model = Organization
# fields = ('url','organization_type','title','short_name')
fields = ('title', 'long_name', 'url', 'short_name', 'logo', 'organization_type')
54 changes: 35 additions & 19 deletions apps/organization/tests/test_mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,46 @@


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
verified
}
}
}
'''

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')
self.assertEqual(content['data']['organizationCreate']['result']['verified'], False)
16 changes: 16 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4909,6 +4909,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 @@ -4983,6 +4984,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 a3a588c

Please sign in to comment.