mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-08 23:50:38 +03:00
Fixed Flake issues
This commit is contained in:
parent
3fbc3281a2
commit
f1624af08a
|
@ -12,6 +12,7 @@ class Query(graphene.ObjectType):
|
|||
def resolve_me(self, args, context, info):
|
||||
return context['user']
|
||||
|
||||
|
||||
schema = graphene.Schema(query=Query)
|
||||
query = '''
|
||||
query something{
|
||||
|
|
|
@ -14,6 +14,7 @@ class Query(graphene.ObjectType):
|
|||
def resolve_patron(self, args, context, info):
|
||||
return Patron(id=1, name='Syrus', age=27)
|
||||
|
||||
|
||||
schema = graphene.Schema(query=Query)
|
||||
query = '''
|
||||
query something{
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from graphene.test import Client
|
||||
|
||||
from ..data import setup
|
||||
from ..schema import schema
|
||||
|
||||
|
@ -6,6 +7,7 @@ setup()
|
|||
|
||||
client = Client(schema)
|
||||
|
||||
|
||||
def test_hero_name_query(snapshot):
|
||||
query = '''
|
||||
query HeroNameQuery {
|
||||
|
@ -15,7 +17,6 @@ def test_hero_name_query(snapshot):
|
|||
}
|
||||
'''
|
||||
snapshot.assert_match(client.execute(query))
|
||||
|
||||
|
||||
|
||||
def test_hero_name_and_friends_query(snapshot):
|
||||
|
|
|
@ -18,6 +18,7 @@ class Ship(graphene.ObjectType):
|
|||
|
||||
|
||||
class ShipConnection(relay.Connection):
|
||||
|
||||
class Meta:
|
||||
node = Ship
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from graphene.test import Client
|
||||
|
||||
from ..data import setup
|
||||
from ..schema import schema
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from graphene.test import Client
|
||||
|
||||
from ..data import setup
|
||||
from ..schema import schema
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from graphene.test import Client
|
||||
|
||||
from ..data import setup
|
||||
from ..schema import schema
|
||||
|
||||
|
|
|
@ -74,4 +74,7 @@ if not __SETUP__:
|
|||
'ConnectionField',
|
||||
'PageInfo',
|
||||
'lazy_import',
|
||||
|
||||
# Deprecated
|
||||
'AbstractType',
|
||||
]
|
||||
|
|
|
@ -21,6 +21,7 @@ def test__is_dunder():
|
|||
for name in non_dunder_names:
|
||||
assert _is_dunder(name) is False
|
||||
|
||||
|
||||
def test__is_sunder():
|
||||
sunder_names = [
|
||||
'_i_',
|
||||
|
|
|
@ -2,16 +2,13 @@ import re
|
|||
from collections import Iterable, OrderedDict
|
||||
from functools import partial
|
||||
|
||||
import six
|
||||
|
||||
from graphql_relay import connection_from_list
|
||||
from promise import Promise, is_thenable
|
||||
|
||||
from ..types import (Boolean, Enum, Int, Interface, List, NonNull, Scalar, String,
|
||||
Union)
|
||||
from ..types import (Boolean, Enum, Int, Interface, List, NonNull, Scalar,
|
||||
String, Union)
|
||||
from ..types.field import Field
|
||||
from ..types.objecttype import ObjectType, ObjectTypeOptions
|
||||
from ..utils.props import props
|
||||
from .node import is_node
|
||||
|
||||
|
||||
|
@ -44,8 +41,10 @@ class ConnectionOptions(ObjectTypeOptions):
|
|||
|
||||
|
||||
class Connection(ObjectType):
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
@classmethod
|
||||
def __init_subclass_with_meta__(cls, node=None, name=None, **options):
|
||||
_meta = ConnectionOptions(cls)
|
||||
|
@ -60,6 +59,7 @@ class Connection(ObjectType):
|
|||
|
||||
edge_class = getattr(cls, 'Edge', None)
|
||||
_node = node
|
||||
|
||||
class EdgeBase(object):
|
||||
node = Field(_node, description='The item at the end of the edge')
|
||||
cursor = String(required=True, description='A cursor for use in pagination')
|
||||
|
|
|
@ -3,12 +3,12 @@ from collections import OrderedDict
|
|||
|
||||
from promise import Promise
|
||||
|
||||
from ..types import Field, AbstractType, Argument, InputObjectType, String, Field
|
||||
from ..types.mutation import Mutation, MutationOptions
|
||||
from ..utils.props import props
|
||||
from ..types import Field, InputObjectType, String
|
||||
from ..types.mutation import Mutation
|
||||
|
||||
|
||||
class ClientIDMutation(Mutation):
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
@ -17,7 +17,7 @@ class ClientIDMutation(Mutation):
|
|||
input_class = getattr(cls, 'Input', None)
|
||||
name = name or cls.__name__
|
||||
base_name = re.sub('Payload$', '', name)
|
||||
|
||||
|
||||
assert not output, "Can't specify any output"
|
||||
assert not arguments, "Can't specify any arguments"
|
||||
|
||||
|
@ -28,8 +28,8 @@ class ClientIDMutation(Mutation):
|
|||
cls.Input = type('{}Input'.format(base_name),
|
||||
bases, {
|
||||
'client_mutation_id': String(name='clientMutationId')
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
arguments = OrderedDict(
|
||||
input=cls.Input(required=True)
|
||||
# 'client_mutation_id': String(name='clientMutationId')
|
||||
|
@ -39,7 +39,7 @@ class ClientIDMutation(Mutation):
|
|||
assert mutate_and_get_payload, (
|
||||
"{name}.mutate_and_get_payload method is required"
|
||||
" in a ClientIDMutation.").format(name=name)
|
||||
|
||||
|
||||
if not name:
|
||||
name = '{}Payload'.format(base_name)
|
||||
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
from collections import OrderedDict
|
||||
from functools import partial
|
||||
|
||||
import six
|
||||
|
||||
from graphql_relay import from_global_id, to_global_id
|
||||
|
||||
from ..types import ID, Field, Interface, ObjectType
|
||||
from ..types.utils import get_type
|
||||
from ..types.interface import InterfaceOptions
|
||||
from ..types.utils import get_type
|
||||
|
||||
|
||||
def is_node(objecttype):
|
||||
|
@ -60,6 +58,7 @@ class NodeField(Field):
|
|||
|
||||
|
||||
class AbstractNode(Interface):
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
from ...types import Field, List, NonNull, ObjectType, String, Argument, Int
|
||||
from ..connection import Connection, PageInfo, ConnectionField
|
||||
from ...types import Argument, Field, Int, List, NonNull, ObjectType, String
|
||||
from ..connection import Connection, ConnectionField, PageInfo
|
||||
from ..node import Node
|
||||
|
||||
|
||||
|
@ -104,6 +104,7 @@ def test_pageinfo():
|
|||
|
||||
def test_connectionfield():
|
||||
class MyObjectConnection(Connection):
|
||||
|
||||
class Meta:
|
||||
node = MyObject
|
||||
|
||||
|
@ -118,6 +119,7 @@ def test_connectionfield():
|
|||
|
||||
def test_connectionfield_custom_args():
|
||||
class MyObjectConnection(Connection):
|
||||
|
||||
class Meta:
|
||||
node = MyObject
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class Letter(ObjectType):
|
|||
|
||||
|
||||
class LetterConnection(Connection):
|
||||
|
||||
class Meta:
|
||||
node = Letter
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from graphql_relay import to_global_id
|
||||
|
||||
from ..node import Node, GlobalID
|
||||
from ...types import NonNull, ID, ObjectType, String
|
||||
from ...types import ID, NonNull, ObjectType, String
|
||||
from ...types.definitions import GrapheneObjectType
|
||||
from ..node import GlobalID, Node
|
||||
|
||||
|
||||
class CustomNode(Node):
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import pytest
|
||||
|
||||
from ...types import ( Argument, Field, InputField, ID,
|
||||
InputObjectType, NonNull, ObjectType, Schema)
|
||||
from promise import Promise
|
||||
|
||||
from ...types import (ID, Argument, Field, InputField, InputObjectType,
|
||||
NonNull, ObjectType, Schema)
|
||||
from ...types.scalars import String
|
||||
from ..mutation import ClientIDMutation
|
||||
from ..node import Node
|
||||
from promise import Promise
|
||||
|
||||
|
||||
class SharedFields(object):
|
||||
|
@ -20,6 +20,7 @@ class MyNode(ObjectType):
|
|||
|
||||
|
||||
class SaySomething(ClientIDMutation):
|
||||
|
||||
class Input:
|
||||
what = String()
|
||||
|
||||
|
@ -32,6 +33,7 @@ class SaySomething(ClientIDMutation):
|
|||
|
||||
|
||||
class SaySomethingPromise(ClientIDMutation):
|
||||
|
||||
class Input:
|
||||
what = String()
|
||||
|
||||
|
@ -50,6 +52,7 @@ class MyEdge(ObjectType):
|
|||
|
||||
|
||||
class OtherMutation(ClientIDMutation):
|
||||
|
||||
class Input(SharedFields):
|
||||
additional_field = String()
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ from collections import OrderedDict
|
|||
from graphql_relay import to_global_id
|
||||
|
||||
from ...types import ObjectType, Schema, String
|
||||
from ..connection import Connection
|
||||
from ..node import Node
|
||||
|
||||
|
||||
|
@ -105,7 +104,7 @@ def test_node_field_only_type_wrong():
|
|||
)
|
||||
assert len(executed.errors) == 1
|
||||
assert str(executed.errors[0]) == 'Must receive an MyOtherNode id.'
|
||||
assert executed.data == { 'onlyNode': None }
|
||||
assert executed.data == {'onlyNode': None}
|
||||
|
||||
|
||||
def test_node_field_only_lazy_type():
|
||||
|
@ -122,7 +121,7 @@ def test_node_field_only_lazy_type_wrong():
|
|||
)
|
||||
assert len(executed.errors) == 1
|
||||
assert str(executed.errors[0]) == 'Must receive an MyOtherNode id.'
|
||||
assert executed.data == { 'onlyNodeLazy': None }
|
||||
assert executed.data == {'onlyNodeLazy': None}
|
||||
|
||||
|
||||
def test_str_schema():
|
||||
|
|
|
@ -29,6 +29,7 @@ def format_execution_result(execution_result, format_error):
|
|||
|
||||
|
||||
class Client(object):
|
||||
|
||||
def __init__(self, schema, format_error=None, **execute_options):
|
||||
assert isinstance(schema, Schema)
|
||||
self.schema = schema
|
||||
|
|
|
@ -3,9 +3,11 @@
|
|||
import graphene
|
||||
from graphene import resolve_only_args
|
||||
|
||||
|
||||
class Query(graphene.ObjectType):
|
||||
rand = graphene.String()
|
||||
|
||||
|
||||
class Success(graphene.ObjectType):
|
||||
yeah = graphene.String()
|
||||
|
||||
|
@ -15,11 +17,13 @@ class Error(graphene.ObjectType):
|
|||
|
||||
|
||||
class CreatePostResult(graphene.Union):
|
||||
|
||||
class Meta:
|
||||
types = [Success, Error]
|
||||
|
||||
|
||||
class CreatePost(graphene.Mutation):
|
||||
|
||||
class Input:
|
||||
text = graphene.String(required=True)
|
||||
|
||||
|
@ -37,6 +41,7 @@ class Mutations(graphene.ObjectType):
|
|||
|
||||
# tests.py
|
||||
|
||||
|
||||
def test_create_post():
|
||||
query_string = '''
|
||||
mutation {
|
||||
|
@ -52,4 +57,4 @@ def test_create_post():
|
|||
result = schema.execute(query_string)
|
||||
|
||||
assert not result.errors
|
||||
assert result.data['createPost']['result']['__typename'] == 'Success'
|
||||
assert result.data['createPost']['result']['__typename'] == 'Success'
|
||||
|
|
|
@ -1,19 +1,25 @@
|
|||
# https://github.com/graphql-python/graphene/issues/356
|
||||
|
||||
import pytest
|
||||
|
||||
import graphene
|
||||
from graphene import relay
|
||||
|
||||
|
||||
class SomeTypeOne(graphene.ObjectType):
|
||||
pass
|
||||
|
||||
|
||||
class SomeTypeTwo(graphene.ObjectType):
|
||||
pass
|
||||
|
||||
|
||||
class MyUnion(graphene.Union):
|
||||
|
||||
class Meta:
|
||||
types = (SomeTypeOne, SomeTypeTwo)
|
||||
|
||||
|
||||
def test_issue():
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
class Query(graphene.ObjectType):
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
# https://github.com/graphql-python/graphene/issues/425
|
||||
# Adapted for Graphene 2.0
|
||||
import six
|
||||
|
||||
from graphene.types.objecttype import ObjectType, ObjectTypeOptions
|
||||
|
||||
|
||||
class SpecialOptions(ObjectTypeOptions):
|
||||
other_attr = None
|
||||
|
||||
|
||||
class SpecialObjectType(ObjectType):
|
||||
|
||||
@classmethod
|
||||
def __init_subclass_with_meta__(cls, other_attr='default', **options):
|
||||
_meta = SpecialOptions(cls)
|
||||
_meta.other_attr = other_attr
|
||||
super(SpecialObjectType, cls).__init_subclass_with_meta__(_meta=_meta, **options)
|
||||
|
||||
|
||||
|
||||
def test_special_objecttype_could_be_subclassed():
|
||||
class MyType(SpecialObjectType):
|
||||
|
||||
class Meta:
|
||||
other_attr = 'yeah!'
|
||||
|
||||
|
@ -36,5 +38,5 @@ def test_special_objecttype_inherit_meta_options():
|
|||
pass
|
||||
|
||||
assert MyType._meta.name == 'MyType'
|
||||
assert MyType._meta.default_resolver == None
|
||||
assert MyType._meta.default_resolver is None
|
||||
assert MyType._meta.interfaces == ()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# https://github.com/graphql-python/graphene/issues/313
|
||||
|
||||
import graphene
|
||||
from graphene import resolve_only_args
|
||||
|
||||
|
||||
class Query(graphene.ObjectType):
|
||||
|
|
|
@ -38,4 +38,7 @@ __all__ = [
|
|||
'Argument',
|
||||
'Dynamic',
|
||||
'Union',
|
||||
|
||||
# Deprecated
|
||||
'AbstractType',
|
||||
]
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from collections import OrderedDict
|
||||
from itertools import chain
|
||||
|
||||
from .dynamic import Dynamic
|
||||
from .mountedtype import MountedType
|
||||
from .structures import NonNull
|
||||
from .dynamic import Dynamic
|
||||
from .utils import get_type
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ class BaseOptions(object):
|
|||
|
||||
def freeze(self):
|
||||
self._frozen = True
|
||||
|
||||
|
||||
def __setattr__(self, name, value):
|
||||
if not self._frozen:
|
||||
super(BaseOptions, self).__setattr__(name, value)
|
||||
|
@ -25,6 +25,7 @@ class BaseOptions(object):
|
|||
|
||||
|
||||
class BaseType(SubclassWithMeta):
|
||||
|
||||
@classmethod
|
||||
def __init_subclass_with_meta__(cls, name=None, description=None, _meta=None):
|
||||
assert "_meta" not in cls.__dict__, "Can't assign directly meta"
|
||||
|
|
|
@ -2,10 +2,10 @@ from collections import OrderedDict
|
|||
|
||||
import six
|
||||
|
||||
from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta
|
||||
|
||||
from .base import BaseOptions, BaseType
|
||||
from .unmountedtype import UnmountedType
|
||||
from graphene.pyutils.init_subclass import InitSubclassMeta
|
||||
from graphene.utils.subclass_with_meta import SubclassWithMeta_Meta
|
||||
|
||||
try:
|
||||
from enum import Enum as PyEnum
|
||||
|
@ -27,6 +27,7 @@ class EnumOptions(BaseOptions):
|
|||
|
||||
|
||||
class EnumMeta(SubclassWithMeta_Meta):
|
||||
|
||||
def __new__(cls, name, bases, classdict, **options):
|
||||
enum = PyEnum(cls.__name__, OrderedDict(classdict, __eq__=eq_enum))
|
||||
return SubclassWithMeta_Meta.__new__(cls, name, bases, OrderedDict(classdict, __enum__=enum), **options)
|
||||
|
@ -53,6 +54,7 @@ class EnumMeta(SubclassWithMeta_Meta):
|
|||
|
||||
|
||||
class Enum(six.with_metaclass(EnumMeta, UnmountedType, BaseType)):
|
||||
|
||||
@classmethod
|
||||
def __init_subclass_with_meta__(cls, enum=None, **options):
|
||||
_meta = EnumOptions(cls)
|
||||
|
|
|
@ -8,7 +8,6 @@ from .structures import NonNull
|
|||
from .unmountedtype import UnmountedType
|
||||
from .utils import get_type
|
||||
|
||||
|
||||
base_type = type
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from graphene.types.scalars import MAX_INT, MIN_INT
|
||||
from graphql.language.ast import (BooleanValue, FloatValue, IntValue,
|
||||
StringValue, ListValue, ObjectValue)
|
||||
ListValue, ObjectValue, StringValue)
|
||||
|
||||
from graphene.types.scalars import MIN_INT, MAX_INT
|
||||
from .scalars import Scalar
|
||||
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
from .base import BaseOptions, BaseType
|
||||
from .inputfield import InputField
|
||||
from .unmountedtype import UnmountedType
|
||||
from .utils import yank_fields_from_attrs
|
||||
|
||||
from .base import BaseOptions, BaseType
|
||||
|
||||
|
||||
class InputObjectTypeOptions(BaseOptions):
|
||||
fields = None # type: Dict[str, Field]
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
from .field import Field
|
||||
from .utils import yank_fields_from_attrs
|
||||
from collections import OrderedDict
|
||||
|
||||
from .base import BaseOptions, BaseType
|
||||
from .field import Field
|
||||
from .utils import yank_fields_from_attrs
|
||||
|
||||
|
||||
class InterfaceOptions(BaseOptions):
|
||||
|
@ -30,7 +30,7 @@ class Interface(BaseType):
|
|||
fields.update(
|
||||
yank_fields_from_attrs(base.__dict__, _as=Field)
|
||||
)
|
||||
|
||||
|
||||
if _meta.fields:
|
||||
_meta.fields.update(fields)
|
||||
else:
|
||||
|
|
|
@ -3,10 +3,8 @@ from collections import OrderedDict
|
|||
from ..utils.get_unbound_function import get_unbound_function
|
||||
from ..utils.props import props
|
||||
from .field import Field
|
||||
from .utils import yank_fields_from_attrs
|
||||
from .objecttype import ObjectType, ObjectTypeOptions
|
||||
|
||||
from .base import BaseOptions, BaseType
|
||||
from .utils import yank_fields_from_attrs
|
||||
|
||||
|
||||
class MutationOptions(ObjectTypeOptions):
|
||||
|
@ -20,7 +18,8 @@ class Mutation(ObjectType):
|
|||
Mutation Type Definition
|
||||
'''
|
||||
@classmethod
|
||||
def __init_subclass_with_meta__(cls, resolver=None, output=None, arguments=None, _meta=None, abstract=False, **options):
|
||||
def __init_subclass_with_meta__(cls, resolver=None, output=None, arguments=None,
|
||||
_meta=None, abstract=False, **options):
|
||||
if abstract:
|
||||
return
|
||||
if not _meta:
|
||||
|
@ -36,7 +35,7 @@ class Mutation(ObjectType):
|
|||
yank_fields_from_attrs(base.__dict__, _as=Field)
|
||||
)
|
||||
output = cls
|
||||
|
||||
|
||||
if not arguments:
|
||||
input_class = getattr(cls, 'Arguments', None)
|
||||
if not input_class:
|
||||
|
@ -64,7 +63,7 @@ class Mutation(ObjectType):
|
|||
_meta.arguments = arguments
|
||||
|
||||
super(Mutation, cls).__init_subclass_with_meta__(_meta=_meta, **options)
|
||||
|
||||
|
||||
@classmethod
|
||||
def Field(cls, *args, **kwargs):
|
||||
return Field(
|
||||
|
|
|
@ -1,15 +1,14 @@
|
|||
from collections import OrderedDict
|
||||
|
||||
from .base import BaseOptions, BaseType
|
||||
from .field import Field
|
||||
from .interface import Interface
|
||||
from .utils import yank_fields_from_attrs
|
||||
|
||||
from .base import BaseOptions, BaseType
|
||||
|
||||
|
||||
class ObjectTypeOptions(BaseOptions):
|
||||
fields = None # type: Dict[str, Field]
|
||||
interfaces = () # type: List[Type[Interface]]
|
||||
interfaces = () # type: List[Type[Interface]]
|
||||
|
||||
|
||||
class ObjectType(BaseType):
|
||||
|
@ -20,7 +19,10 @@ class ObjectType(BaseType):
|
|||
have a name, but most importantly describe their fields.
|
||||
'''
|
||||
@classmethod
|
||||
def __init_subclass_with_meta__(cls, interfaces=(), possible_types=(), default_resolver=None, _meta=None, abstract=False, **options):
|
||||
def __init_subclass_with_meta__(
|
||||
cls, interfaces=(),
|
||||
possible_types=(),
|
||||
default_resolver=None, _meta=None, abstract=False, **options):
|
||||
if abstract:
|
||||
return
|
||||
if not _meta:
|
||||
|
@ -31,7 +33,7 @@ class ObjectType(BaseType):
|
|||
for interface in interfaces:
|
||||
assert issubclass(interface, Interface), (
|
||||
'All interfaces of {} must be a subclass of Interface. Received "{}".'
|
||||
).format(name, interface)
|
||||
).format(cls.__name__, interface)
|
||||
fields.update(interface._meta.fields)
|
||||
|
||||
for base in reversed(cls.__mro__):
|
||||
|
|
|
@ -3,8 +3,8 @@ import six
|
|||
from graphql.language.ast import (BooleanValue, FloatValue, IntValue,
|
||||
StringValue)
|
||||
|
||||
from .unmountedtype import UnmountedType
|
||||
from .base import BaseOptions, BaseType
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
class ScalarOptions(BaseOptions):
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import pytest
|
||||
from functools import partial
|
||||
|
||||
import pytest
|
||||
|
||||
from ..argument import Argument, to_arguments
|
||||
from ..field import Field
|
||||
from ..inputfield import InputField
|
||||
from ..structures import NonNull
|
||||
from ..scalars import String
|
||||
from ..structures import NonNull
|
||||
|
||||
|
||||
def test_argument():
|
||||
|
@ -73,4 +74,4 @@ def test_argument_with_lazy_type():
|
|||
def test_argument_with_lazy_partial_type():
|
||||
MyType = object()
|
||||
arg = Argument(partial(lambda: MyType))
|
||||
assert arg.type == MyType
|
||||
assert arg.type == MyType
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import datetime
|
||||
|
||||
import pytz
|
||||
|
||||
from ..datetime import DateTime, Time
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from ..structures import List, NonNull
|
||||
from ..scalars import String
|
||||
from ..dynamic import Dynamic
|
||||
from ..scalars import String
|
||||
from ..structures import List, NonNull
|
||||
|
||||
|
||||
def test_dynamic():
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from ..argument import Argument
|
||||
from ..enum import Enum, PyEnum
|
||||
from ..field import Field
|
||||
from ..inputfield import InputField
|
||||
from ..argument import Argument
|
||||
|
||||
|
||||
def test_enum_construction():
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import pytest
|
||||
from functools import partial
|
||||
|
||||
import pytest
|
||||
|
||||
from ..argument import Argument
|
||||
from ..field import Field
|
||||
from ..structures import NonNull
|
||||
from ..scalars import String
|
||||
from ..structures import NonNull
|
||||
from .utils import MyLazyType
|
||||
|
||||
|
||||
|
@ -22,7 +23,7 @@ def test_field_basic():
|
|||
resolver = lambda: None
|
||||
deprecation_reason = 'Deprecated now'
|
||||
description = 'My Field'
|
||||
my_default='something'
|
||||
my_default = 'something'
|
||||
field = Field(
|
||||
MyType,
|
||||
name='name',
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import pytest
|
||||
from functools import partial
|
||||
|
||||
from ..inputfield import InputField
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
from ..field import Field
|
||||
from ..argument import Argument
|
||||
from ..field import Field
|
||||
from ..inputfield import InputField
|
||||
from ..objecttype import ObjectType
|
||||
from ..inputobjecttype import InputObjectType
|
||||
from ..objecttype import ObjectType
|
||||
from ..unmountedtype import UnmountedType
|
||||
|
||||
|
||||
|
@ -68,7 +68,7 @@ def test_generate_inputobjecttype_as_argument():
|
|||
|
||||
class MyObjectType(ObjectType):
|
||||
field = Field(MyType, input=MyInputObjectType())
|
||||
|
||||
|
||||
assert 'field' in MyObjectType._meta.fields
|
||||
field = MyObjectType._meta.fields['field']
|
||||
assert isinstance(field, Field)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import json
|
||||
|
||||
from ..json import JSONString
|
||||
from ..objecttype import ObjectType
|
||||
|
@ -19,7 +18,7 @@ def test_jsonstring_query():
|
|||
json_value = '{"key": "value"}'
|
||||
|
||||
json_value_quoted = json_value.replace('"', '\\"')
|
||||
result = schema.execute('''{ json(input: "%s") }'''%json_value_quoted)
|
||||
result = schema.execute('''{ json(input: "%s") }''' % json_value_quoted)
|
||||
assert not result.errors
|
||||
assert result.data == {
|
||||
'json': json_value
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import pytest
|
||||
|
||||
from ..mountedtype import MountedType
|
||||
from ..field import Field
|
||||
from ..scalars import String
|
||||
|
||||
|
||||
class CustomField(Field):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.metadata = kwargs.pop('metadata', None)
|
||||
super(CustomField, self).__init__(*args, **kwargs)
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import pytest
|
||||
|
||||
from ..argument import Argument
|
||||
from ..dynamic import Dynamic
|
||||
from ..mutation import Mutation
|
||||
from ..objecttype import ObjectType
|
||||
from ..schema import Schema
|
||||
from ..argument import Argument
|
||||
from ..scalars import String
|
||||
from ..dynamic import Dynamic
|
||||
from ..schema import Schema
|
||||
|
||||
|
||||
def test_generate_mutation_no_args():
|
||||
|
@ -24,6 +24,7 @@ def test_generate_mutation_no_args():
|
|||
|
||||
def test_generate_mutation_with_meta():
|
||||
class MyMutation(Mutation):
|
||||
|
||||
class Meta:
|
||||
name = 'MyOtherMutation'
|
||||
description = 'Documentation'
|
||||
|
@ -52,6 +53,7 @@ def test_mutation_custom_output_type():
|
|||
name = String()
|
||||
|
||||
class CreateUser(Mutation):
|
||||
|
||||
class Input:
|
||||
name = String()
|
||||
|
||||
|
@ -70,6 +72,7 @@ def test_mutation_custom_output_type():
|
|||
|
||||
def test_mutation_execution():
|
||||
class CreateUser(Mutation):
|
||||
|
||||
class Input:
|
||||
name = String()
|
||||
dynamic = Dynamic(lambda: String())
|
||||
|
|
|
@ -187,6 +187,7 @@ def test_generate_objecttype_description():
|
|||
|
||||
def test_objecttype_with_possible_types():
|
||||
class MyObjectType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
possible_types = (dict, )
|
||||
|
||||
|
@ -196,6 +197,7 @@ def test_objecttype_with_possible_types():
|
|||
def test_objecttype_with_possible_types_and_is_type_of_should_raise():
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
class MyObjectType(ObjectType):
|
||||
|
||||
class Meta:
|
||||
possible_types = (dict, )
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
import json
|
||||
from functools import partial
|
||||
|
||||
from graphql import Source, execute, parse, GraphQLError
|
||||
from graphql import GraphQLError, Source, execute, parse
|
||||
|
||||
from ..dynamic import Dynamic
|
||||
from ..field import Field
|
||||
from ..interface import Interface
|
||||
from ..inputfield import InputField
|
||||
from ..inputobjecttype import InputObjectType
|
||||
from ..interface import Interface
|
||||
from ..objecttype import ObjectType
|
||||
from ..scalars import Int, String
|
||||
from ..schema import Schema
|
||||
from ..structures import List
|
||||
from ..union import Union
|
||||
from ..dynamic import Dynamic
|
||||
|
||||
|
||||
def test_query():
|
||||
|
@ -48,6 +48,7 @@ def test_query_union():
|
|||
return isinstance(root, two_object)
|
||||
|
||||
class MyUnion(Union):
|
||||
|
||||
class Meta:
|
||||
types = (One, Two)
|
||||
|
||||
|
@ -81,6 +82,7 @@ def test_query_interface():
|
|||
base = String()
|
||||
|
||||
class One(ObjectType):
|
||||
|
||||
class Meta:
|
||||
interfaces = (MyInterface, )
|
||||
|
||||
|
@ -91,6 +93,7 @@ def test_query_interface():
|
|||
return isinstance(root, one_object)
|
||||
|
||||
class Two(ObjectType):
|
||||
|
||||
class Meta:
|
||||
interfaces = (MyInterface, )
|
||||
|
||||
|
@ -268,6 +271,7 @@ def test_query_middlewares():
|
|||
|
||||
def test_objecttype_on_instances():
|
||||
class Ship:
|
||||
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import pytest
|
||||
|
||||
from ..resolver import attr_resolver, dict_resolver, get_default_resolver, set_default_resolver
|
||||
from ..resolver import (attr_resolver, dict_resolver, get_default_resolver,
|
||||
set_default_resolver)
|
||||
|
||||
args = {}
|
||||
context = None
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import pytest
|
||||
|
||||
from ..scalars import Scalar
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import pytest
|
||||
|
||||
from ..schema import Schema
|
||||
from ..field import Field
|
||||
from ..objecttype import ObjectType
|
||||
from ..scalars import String
|
||||
from ..field import Field
|
||||
from ..schema import Schema
|
||||
|
||||
|
||||
class MyOtherType(ObjectType):
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import pytest
|
||||
from functools import partial
|
||||
|
||||
from ..structures import List, NonNull
|
||||
import pytest
|
||||
|
||||
from ..scalars import String
|
||||
from ..structures import List, NonNull
|
||||
from .utils import MyLazyType
|
||||
|
||||
|
||||
|
@ -15,7 +16,7 @@ def test_list():
|
|||
def test_list_with_unmounted_type():
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
List(String())
|
||||
|
||||
|
||||
assert str(exc_info.value) == 'List could not have a mounted String() as inner type. Try with List(String).'
|
||||
|
||||
|
||||
|
@ -80,14 +81,14 @@ def test_nonnull_inherited_works_list():
|
|||
def test_nonnull_inherited_dont_work_nonnull():
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
NonNull(NonNull(String))
|
||||
|
||||
|
||||
assert str(exc_info.value) == 'Can only create NonNull of a Nullable GraphQLType but got: String!.'
|
||||
|
||||
|
||||
def test_nonnull_with_unmounted_type():
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
NonNull(String())
|
||||
|
||||
|
||||
assert str(exc_info.value) == 'NonNull could not have a mounted String() as inner type. Try with NonNull(String).'
|
||||
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ def test_generate_union_with_no_types():
|
|||
|
||||
def test_union_can_be_mounted():
|
||||
class MyUnion(Union):
|
||||
|
||||
class Meta:
|
||||
types = (MyObjectType1, MyObjectType2)
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ from graphql.type.typemap import GraphQLTypeMap
|
|||
|
||||
from ..utils.get_unbound_function import get_unbound_function
|
||||
from ..utils.str_converters import to_camel_case
|
||||
from .definitions import (GrapheneEnumType, GrapheneInputObjectType,
|
||||
GrapheneInterfaceType, GrapheneObjectType,
|
||||
GrapheneScalarType, GrapheneUnionType,
|
||||
GrapheneGraphQLType)
|
||||
from .definitions import (GrapheneEnumType, GrapheneGraphQLType,
|
||||
GrapheneInputObjectType, GrapheneInterfaceType,
|
||||
GrapheneObjectType, GrapheneScalarType,
|
||||
GrapheneUnionType)
|
||||
from .dynamic import Dynamic
|
||||
from .enum import Enum
|
||||
from .field import Field
|
||||
|
@ -59,6 +59,7 @@ def is_type_of_from_possible_types(possible_types, root, context, info):
|
|||
|
||||
|
||||
class TypeMap(GraphQLTypeMap):
|
||||
|
||||
def __init__(self, types, auto_camelcase=True, schema=None):
|
||||
self.auto_camelcase = auto_camelcase
|
||||
self.schema = schema
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
from .unmountedtype import UnmountedType
|
||||
from .objecttype import ObjectType
|
||||
|
||||
from .base import BaseOptions, BaseType
|
||||
from .unmountedtype import UnmountedType
|
||||
|
||||
|
||||
class UnionOptions(BaseOptions):
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import inspect
|
||||
from collections import OrderedDict
|
||||
from functools import partial
|
||||
|
||||
from six import string_types
|
||||
|
||||
from ..utils.module_loading import import_string
|
||||
|
@ -40,6 +41,6 @@ def yank_fields_from_attrs(attrs, _as=None, sort=True):
|
|||
def get_type(_type):
|
||||
if isinstance(_type, string_types):
|
||||
return import_string(_type)
|
||||
if inspect.isfunction(_type) or type(_type) is partial:
|
||||
if inspect.isfunction(_type) or isinstance(_type, partial):
|
||||
return _type()
|
||||
return _type
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import six
|
||||
|
||||
from .props import props
|
||||
from ..pyutils.init_subclass import InitSubclassMeta
|
||||
from .props import props
|
||||
|
||||
|
||||
class SubclassWithMeta_Meta(InitSubclassMeta):
|
||||
|
||||
def __repr__(cls):
|
||||
return cls._meta.name
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from pytest import raises
|
||||
|
||||
from graphene import String, ObjectType
|
||||
from ..module_loading import lazy_import, import_string
|
||||
from graphene import ObjectType, String
|
||||
|
||||
from ..module_loading import import_string, lazy_import
|
||||
|
||||
|
||||
def test_import_string():
|
||||
|
|
|
@ -9,11 +9,10 @@ def test_trim_docstring():
|
|||
|
||||
Multiple paragraphs too
|
||||
"""
|
||||
pass
|
||||
|
||||
assert (trim_docstring(WellDocumentedObject.__doc__) ==
|
||||
"This object is very well-documented. It has multiple lines in its\n"
|
||||
"description.\n\nMultiple paragraphs too")
|
||||
"This object is very well-documented. It has multiple lines in its\n"
|
||||
"description.\n\nMultiple paragraphs too")
|
||||
|
||||
class UndocumentedObject(object):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue
Block a user