mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
Added extra test to objecttypes
This commit is contained in:
parent
f79eb57c06
commit
43cda1d46a
|
@ -4,6 +4,7 @@ from ..field import Field
|
||||||
from ..interface import Interface
|
from ..interface import Interface
|
||||||
from ..objecttype import ObjectType
|
from ..objecttype import ObjectType
|
||||||
from ..unmountedtype import UnmountedType
|
from ..unmountedtype import UnmountedType
|
||||||
|
from ..structures import NonNull
|
||||||
|
|
||||||
|
|
||||||
class MyType(Interface):
|
class MyType(Interface):
|
||||||
|
@ -56,6 +57,20 @@ def test_generate_objecttype_with_meta():
|
||||||
assert MyObjectType._meta.interfaces == (MyType, )
|
assert MyObjectType._meta.interfaces == (MyType, )
|
||||||
|
|
||||||
|
|
||||||
|
def test_generate_lazy_objecttype():
|
||||||
|
class MyObjectType(ObjectType):
|
||||||
|
example = Field(lambda: InnerObjectType, required=True)
|
||||||
|
|
||||||
|
class InnerObjectType(ObjectType):
|
||||||
|
field = Field(MyType)
|
||||||
|
|
||||||
|
|
||||||
|
assert MyObjectType._meta.name == "MyObjectType"
|
||||||
|
example_field = MyObjectType._meta.fields['example']
|
||||||
|
assert isinstance(example_field.type, NonNull)
|
||||||
|
assert example_field.type.of_type == InnerObjectType
|
||||||
|
|
||||||
|
|
||||||
def test_generate_objecttype_with_fields():
|
def test_generate_objecttype_with_fields():
|
||||||
class MyObjectType(ObjectType):
|
class MyObjectType(ObjectType):
|
||||||
field = Field(MyType)
|
field = Field(MyType)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user