From a1a7ee619d14515f6e2f5c9f1c4298f1e3bdcc8b Mon Sep 17 00:00:00 2001 From: sudan45 Date: Mon, 1 Apr 2024 13:56:14 +0545 Subject: [PATCH] - implement the organization mutation - testcase updated --- apps/organization/mutation.py | 2 +- apps/organization/tests/test_mutations.py | 52 ++++++++++++++--------- schema.graphql | 16 +++++++ 3 files changed, 50 insertions(+), 20 deletions(-) diff --git a/apps/organization/mutation.py b/apps/organization/mutation.py index 1ca126b50d..e263d0bb98 100644 --- a/apps/organization/mutation.py +++ b/apps/organization/mutation.py @@ -24,7 +24,7 @@ class Arguments: @classmethod def check_permissions(cls, info, **kwargs): - return True + return True # global permission is always True class Mutation(): diff --git a/apps/organization/tests/test_mutations.py b/apps/organization/tests/test_mutations.py index 1a54322493..cf50ceba37 100644 --- a/apps/organization/tests/test_mutations.py +++ b/apps/organization/tests/test_mutations.py @@ -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') diff --git a/schema.graphql b/schema.graphql index 54f022c4ef..254ba20335 100644 --- a/schema.graphql +++ b/schema.graphql @@ -4273,6 +4273,7 @@ type MissingPredictionReviewType { } type Mutation { + organizationCreate(data: OrganizationInputType!): OrganizationCreate createAssessmentRegSummaryIssue(data: AssessmentRegistrySummaryIssueCreateInputType!): AssessmentRegistryCreateIssue fileUpload(data: FileUploadInputType!): UploadFile genericExportCreate(data: GenericExportCreateInputType!): CreateUserGenericExport @@ -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