mirror of
https://github.com/graphql-python/graphene.git
synced 2025-09-21 11:22:33 +03:00
Added test to ensure fields can be defined on meta
This commit is contained in:
parent
cffa3b3b2d
commit
f3ca2cc932
|
@ -1,5 +1,8 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
import pytest
|
||||
|
||||
import graphene
|
||||
from ...types import Argument, Field, Int, List, NonNull, ObjectType, Schema, String
|
||||
from ..connection import Connection, ConnectionField, PageInfo, ConnectionOptions
|
||||
from ..node import Node
|
||||
|
@ -74,6 +77,33 @@ def test_connection_meta_assignment():
|
|||
assert id(MyObjectConnection._meta) == id(meta)
|
||||
|
||||
|
||||
def test_connection_meta_can_have_fields():
|
||||
meta = ConnectionOptions(Connection)
|
||||
meta.fields = OrderedDict([
|
||||
("test", graphene.String())
|
||||
])
|
||||
|
||||
class BaseConnection(object):
|
||||
extra = String()
|
||||
|
||||
class InheritedConnection(Connection):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
@classmethod
|
||||
def __init_subclass_with_meta__(cls, node=None, name=None, **options):
|
||||
return super(InheritedConnection, cls).__init_subclass_with_meta__(
|
||||
_meta=meta, node=node, name=name, **options
|
||||
)
|
||||
|
||||
class MyObjectConnection(BaseConnection, InheritedConnection):
|
||||
class Meta:
|
||||
node = MyObject
|
||||
|
||||
fields = MyObjectConnection._meta.fields
|
||||
assert list(fields.keys()) == ["test", "page_info", "edges", "extra"]
|
||||
|
||||
|
||||
def test_connection_name():
|
||||
custom_name = "MyObjectCustomNameConnection"
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user