mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 20:54:16 +03:00
Fixed List, NonNull accessors as functions instead of properties
This commit is contained in:
parent
ee19445290
commit
2f6fb89f23
|
@ -1,5 +1,6 @@
|
|||
import copy
|
||||
import inspect
|
||||
from functools import partial
|
||||
from collections import OrderedDict
|
||||
|
||||
import six
|
||||
|
@ -48,8 +49,8 @@ class ClassTypeMeta(type):
|
|||
|
||||
if not cls._meta.abstract:
|
||||
from ..types import List, NonNull
|
||||
setattr(cls, 'NonNull', NonNull(cls))
|
||||
setattr(cls, 'List', List(cls))
|
||||
setattr(cls, 'NonNull', partial(NonNull, cls))
|
||||
setattr(cls, 'List', partial(List, cls))
|
||||
|
||||
return cls
|
||||
|
||||
|
|
|
@ -23,15 +23,26 @@ def test_classtype_advanced():
|
|||
def test_classtype_definition_list():
|
||||
class Character(ClassType):
|
||||
'''Character description'''
|
||||
assert isinstance(Character.List, List)
|
||||
assert Character.List.of_type == Character
|
||||
assert isinstance(Character.List(), List)
|
||||
assert Character.List().of_type == Character
|
||||
|
||||
|
||||
def test_classtype_definition_nonnull():
|
||||
class Character(ClassType):
|
||||
'''Character description'''
|
||||
assert isinstance(Character.NonNull, NonNull)
|
||||
assert Character.NonNull.of_type == Character
|
||||
assert isinstance(Character.NonNull(), NonNull)
|
||||
assert Character.NonNull().of_type == Character
|
||||
|
||||
|
||||
def test_fieldsclasstype_definition_order():
|
||||
class Character(ClassType):
|
||||
'''Character description'''
|
||||
|
||||
class Query(FieldsClassType):
|
||||
name = String()
|
||||
char = Character.NonNull()
|
||||
|
||||
assert list(Query._meta.fields_map.keys()) == ['name', 'char']
|
||||
|
||||
|
||||
def test_fieldsclasstype():
|
||||
|
|
Loading…
Reference in New Issue
Block a user