From b81e961c8684b27ac2fce23360b5b9cc238f46d8 Mon Sep 17 00:00:00 2001 From: mongkok Date: Sat, 3 Feb 2018 03:16:58 +0530 Subject: [PATCH] Test DjangoObjectType with custom meta #364 --- graphene_django/tests/test_types.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/graphene_django/tests/test_types.py b/graphene_django/tests/test_types.py index 83d9b40..10db943 100644 --- a/graphene_django/tests/test_types.py +++ b/graphene_django/tests/test_types.py @@ -4,7 +4,7 @@ from graphene import Interface, ObjectType, Schema, Connection, String from graphene.relay import Node from .. import registry -from ..types import DjangoObjectType +from ..types import DjangoObjectType, DjangoObjectTypeOptions from .models import Article as ArticleModel from .models import Reporter as ReporterModel @@ -67,6 +67,26 @@ def test_django_objecttype_with_node_have_correct_fields(): assert list(fields.keys()) == ['id', 'headline', 'pub_date', 'reporter', 'editor', 'lang', 'importance'] +def test_django_objecttype_with_custom_meta(): + class ArticleTypeOptions(DjangoObjectTypeOptions): + '''Article Type Options''' + + class ArticleType(DjangoObjectType): + class Meta: + abstract = True + + @classmethod + def __init_subclass_with_meta__(cls, _meta=None, **options): + _meta = ArticleTypeOptions(cls) + super().__init_subclass_with_meta__(_meta=_meta, **options) + + class Article(ArticleType): + class Meta: + model = ArticleModel + + assert isinstance(Article._meta, ArticleTypeOptions) + + def test_schema_representation(): expected = """ schema {