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/serializers.py b/apps/organization/serializers.py index 0a01bc2e07..3f4df84f6e 100644 --- a/apps/organization/serializers.py +++ b/apps/organization/serializers.py @@ -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') diff --git a/apps/organization/tests/test_mutations.py b/apps/organization/tests/test_mutations.py index 1a54322493..ee5e74a951 100644 --- a/apps/organization/tests/test_mutations.py +++ b/apps/organization/tests/test_mutations.py @@ -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) diff --git a/schema.graphql b/schema.graphql index c8fe6ed00e..6bf4d06dc4 100644 --- a/schema.graphql +++ b/schema.graphql @@ -4909,6 +4909,7 @@ type MissingPredictionReviewType { } type Mutation { + organizationCreate(data: OrganizationInputType!): OrganizationCreate createAssessmentRegSummaryIssue(data: AssessmentRegistrySummaryIssueCreateInputType!): AssessmentRegistryCreateIssue fileUpload(data: FileUploadInputType!): UploadFile genericExportCreate(data: GenericExportCreateInputType!): CreateUserGenericExport @@ -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