mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-16 19:12:21 +03:00
Add a test
This commit is contained in:
parent
a2872f2a92
commit
79653b3530
|
@ -26,7 +26,6 @@ from graphql import (
|
||||||
GraphQLObjectType,
|
GraphQLObjectType,
|
||||||
GraphQLSchema,
|
GraphQLSchema,
|
||||||
GraphQLString,
|
GraphQLString,
|
||||||
Undefined,
|
|
||||||
)
|
)
|
||||||
from graphql.execution import ExecutionContext
|
from graphql.execution import ExecutionContext
|
||||||
from graphql.execution.values import get_argument_values
|
from graphql.execution.values import get_argument_values
|
||||||
|
|
|
@ -6,6 +6,7 @@ from graphql.type import (
|
||||||
GraphQLInputField,
|
GraphQLInputField,
|
||||||
GraphQLInputObjectType,
|
GraphQLInputObjectType,
|
||||||
GraphQLInterfaceType,
|
GraphQLInterfaceType,
|
||||||
|
GraphQLNonNull,
|
||||||
GraphQLObjectType,
|
GraphQLObjectType,
|
||||||
GraphQLString,
|
GraphQLString,
|
||||||
)
|
)
|
||||||
|
@ -94,6 +95,23 @@ def test_objecttype():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_required_argument_with_default_value():
|
||||||
|
class MyObjectType(ObjectType):
|
||||||
|
foo = String(
|
||||||
|
bar=String(required=True, default_value="x")
|
||||||
|
)
|
||||||
|
|
||||||
|
type_map = create_type_map([MyObjectType])
|
||||||
|
|
||||||
|
graphql_type = type_map["MyObjectType"]
|
||||||
|
foo_field = graphql_type.fields["foo"]
|
||||||
|
|
||||||
|
bar_argument = foo_field.args["bar"]
|
||||||
|
assert bar_argument.default_value == "x"
|
||||||
|
assert isinstance(bar_argument.type, GraphQLNonNull)
|
||||||
|
assert bar_argument.type.of_type == GraphQLString
|
||||||
|
|
||||||
|
|
||||||
def test_dynamic_objecttype():
|
def test_dynamic_objecttype():
|
||||||
class MyObjectType(ObjectType):
|
class MyObjectType(ObjectType):
|
||||||
"""Description"""
|
"""Description"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user