Added extra test to objecttypes

This commit is contained in:
Syrus Akbary 2017-11-02 21:07:05 -07:00
parent f79eb57c06
commit 43cda1d46a

View File

@ -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)