From e42a826078a64144a2feda70c227c3c500ad9a67 Mon Sep 17 00:00:00 2001 From: Jonathan Kim Date: Sat, 27 Jun 2020 18:15:35 +0100 Subject: [PATCH] Improve mutation test --- .../decorators/tests/test_mutation.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/graphene/experimental/decorators/tests/test_mutation.py b/graphene/experimental/decorators/tests/test_mutation.py index c4e54559..b9c52462 100644 --- a/graphene/experimental/decorators/tests/test_mutation.py +++ b/graphene/experimental/decorators/tests/test_mutation.py @@ -179,30 +179,25 @@ def test_mutation_complex_input(): name = String(required=True) email = String(required=True) - class CreateUserSuccess(ObjectType): + MUTATION_PREFIX = "CreateUser" + + class Success(ObjectType, type_name=f"{MUTATION_PREFIX}Success"): user = Field(User, required=True) - class CreateUserError(ObjectType): + class Error(ObjectType, type_name=f"{MUTATION_PREFIX}Error"): error_message = String(required=True) - class CreateUserOutput(Union): - class Meta: - types = [ - CreateUserSuccess, - CreateUserError, - ] - - class CreateUserInput(InputObjectType): + class Input(InputObjectType, type_name=f"{MUTATION_PREFIX}Input"): name = String(required=True) email = String(required=True) @mutation( - CreateUserOutput, + Union.create_type(f"{MUTATION_PREFIX}Output", types=[Success, Error]), required=True, - arguments={"user": CreateUserInput(required=True)}, + arguments={"user": Input(required=True)}, ) def create_user(root, info, user): - return CreateUserSuccess(user=User(**user)) + return Success(user=User(**user)) class Query(ObjectType): a = String()