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