mirror of
https://github.com/graphql-python/graphene.git
synced 2025-09-21 11:22:33 +03:00
added tests for meta assignment
cleaned up _meta assignment slightly
This commit is contained in:
parent
f4d5603ad3
commit
2709007f83
|
@ -51,8 +51,7 @@ class Connection(ObjectType):
|
|||
|
||||
@classmethod
|
||||
def __init_subclass_with_meta__(cls, node=None, name=None, _meta=None, **options):
|
||||
if not _meta:
|
||||
_meta = ConnectionOptions(cls)
|
||||
_meta = _meta or ConnectionOptions(cls)
|
||||
assert node, "You have to provide a node in {}.Meta".format(cls.__name__)
|
||||
assert isinstance(node, NonNull) or issubclass(
|
||||
node, (Scalar, Enum, ObjectType, Interface, Union, NonNull)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import pytest
|
||||
|
||||
from ...types import Argument, Field, Int, List, NonNull, ObjectType, Schema, String
|
||||
from ..connection import Connection, ConnectionField, PageInfo
|
||||
from ..connection import Connection, ConnectionField, PageInfo, ConnectionOptions
|
||||
from ..node import Node
|
||||
|
||||
|
||||
|
@ -51,6 +51,25 @@ def test_connection_inherit_abstracttype():
|
|||
assert list(fields.keys()) == ["page_info", "edges", "extra"]
|
||||
|
||||
|
||||
def test_connection_meta_assignment():
|
||||
meta = ConnectionOptions(Connection)
|
||||
|
||||
class BaseConnection(object):
|
||||
extra = String()
|
||||
|
||||
class MyObjectConnection(BaseConnection, Connection):
|
||||
class Meta:
|
||||
node = MyObject
|
||||
|
||||
@classmethod
|
||||
def __init_subclass_with_meta__(cls, node=None, name=None, **options):
|
||||
return super(MyObjectConnection, cls).__init_subclass_with_meta__(
|
||||
_meta=meta, node=node, name=name, **options
|
||||
)
|
||||
|
||||
assert id(MyObjectConnection._meta) == id(meta)
|
||||
|
||||
|
||||
def test_connection_name():
|
||||
custom_name = "MyObjectCustomNameConnection"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user