Skip to content

Commit b81e961

Browse files
author
mongkok
committed
Test DjangoObjectType with custom meta #364
1 parent 167d0a3 commit b81e961

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

graphene_django/tests/test_types.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from graphene.relay import Node
55

66
from .. import registry
7-
from ..types import DjangoObjectType
7+
from ..types import DjangoObjectType, DjangoObjectTypeOptions
88
from .models import Article as ArticleModel
99
from .models import Reporter as ReporterModel
1010

@@ -67,6 +67,26 @@ def test_django_objecttype_with_node_have_correct_fields():
6767
assert list(fields.keys()) == ['id', 'headline', 'pub_date', 'reporter', 'editor', 'lang', 'importance']
6868

6969

70+
def test_django_objecttype_with_custom_meta():
71+
class ArticleTypeOptions(DjangoObjectTypeOptions):
72+
'''Article Type Options'''
73+
74+
class ArticleType(DjangoObjectType):
75+
class Meta:
76+
abstract = True
77+
78+
@classmethod
79+
def __init_subclass_with_meta__(cls, _meta=None, **options):
80+
_meta = ArticleTypeOptions(cls)
81+
super().__init_subclass_with_meta__(_meta=_meta, **options)
82+
83+
class Article(ArticleType):
84+
class Meta:
85+
model = ArticleModel
86+
87+
assert isinstance(Article._meta, ArticleTypeOptions)
88+
89+
7090
def test_schema_representation():
7191
expected = """
7292
schema {

0 commit comments

Comments
 (0)