mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-06-17 03:53:12 +03:00
Test DjangoObjectType with custom meta #364
This commit is contained in:
parent
167d0a3964
commit
b81e961c86
|
@ -4,7 +4,7 @@ from graphene import Interface, ObjectType, Schema, Connection, String
|
||||||
from graphene.relay import Node
|
from graphene.relay import Node
|
||||||
|
|
||||||
from .. import registry
|
from .. import registry
|
||||||
from ..types import DjangoObjectType
|
from ..types import DjangoObjectType, DjangoObjectTypeOptions
|
||||||
from .models import Article as ArticleModel
|
from .models import Article as ArticleModel
|
||||||
from .models import Reporter as ReporterModel
|
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']
|
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():
|
def test_schema_representation():
|
||||||
expected = """
|
expected = """
|
||||||
schema {
|
schema {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user