From 43cda1d46a426ec463d27a6eac731dff803d59a2 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Thu, 2 Nov 2017 21:07:05 -0700 Subject: [PATCH] Added extra test to objecttypes --- graphene/types/tests/test_objecttype.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/graphene/types/tests/test_objecttype.py b/graphene/types/tests/test_objecttype.py index 5ff972de..9ad0f817 100644 --- a/graphene/types/tests/test_objecttype.py +++ b/graphene/types/tests/test_objecttype.py @@ -4,6 +4,7 @@ from ..field import Field from ..interface import Interface from ..objecttype import ObjectType from ..unmountedtype import UnmountedType +from ..structures import NonNull class MyType(Interface): @@ -56,6 +57,20 @@ def test_generate_objecttype_with_meta(): 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(): class MyObjectType(ObjectType): field = Field(MyType)