mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-26 11:33:55 +03:00
Added additional tests.
This commit is contained in:
parent
822b030938
commit
0408591141
|
@ -3,6 +3,7 @@ from itertools import chain
|
|||
|
||||
from ..utils.orderedtype import OrderedType
|
||||
from .structures import NonNull
|
||||
from .dynamic import Dynamic
|
||||
|
||||
|
||||
class Argument(OrderedType):
|
||||
|
@ -33,6 +34,9 @@ def to_arguments(args, extra_args):
|
|||
iter_arguments = chain(args.items(), extra_args)
|
||||
arguments = OrderedDict()
|
||||
for default_name, arg in iter_arguments:
|
||||
if isinstance(arg, Dynamic):
|
||||
arg = arg.get_type()
|
||||
|
||||
if isinstance(arg, UnmountedType):
|
||||
arg = arg.Argument()
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ from ..mutation import Mutation
|
|||
from ..objecttype import ObjectType
|
||||
from ..schema import Schema
|
||||
from ..scalars import String
|
||||
from ..dynamic import Dynamic
|
||||
|
||||
|
||||
def test_generate_mutation_no_args():
|
||||
|
@ -47,12 +48,15 @@ def test_mutation_execution():
|
|||
class CreateUser(Mutation):
|
||||
class Input:
|
||||
name = String()
|
||||
dynamic = Dynamic(lambda: String())
|
||||
|
||||
name = String()
|
||||
dynamic = Dynamic(lambda: String())
|
||||
|
||||
def mutate(self, args, context, info):
|
||||
name = args.get('name')
|
||||
return CreateUser(name=name)
|
||||
dynamic = args.get('dynamic')
|
||||
return CreateUser(name=name, dynamic=dynamic)
|
||||
|
||||
class Query(ObjectType):
|
||||
a = String()
|
||||
|
@ -62,14 +66,16 @@ def test_mutation_execution():
|
|||
|
||||
schema = Schema(query=Query, mutation=MyMutation)
|
||||
result = schema.execute(''' mutation mymutation {
|
||||
createUser(name:"Peter") {
|
||||
createUser(name:"Peter", dynamic: "dynamic") {
|
||||
name
|
||||
dynamic
|
||||
}
|
||||
}
|
||||
''')
|
||||
assert not result.errors
|
||||
assert result.data == {
|
||||
'createUser': {
|
||||
'name': "Peter"
|
||||
'name': 'Peter',
|
||||
'dynamic': 'dynamic',
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user