mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
Merge pull request #12 from jhgg/graphql-python/features/resolver_tags
Test resolver tags w/ tag_resolver and resolver_has_tag function.
This commit is contained in:
commit
e26c303911
|
@ -1,24 +1,24 @@
|
||||||
from py.test import raises
|
from py.test import raises
|
||||||
from collections import namedtuple
|
|
||||||
from pytest import raises
|
from pytest import raises
|
||||||
from graphene.core.fields import (
|
from graphene.core.fields import (
|
||||||
Field,
|
|
||||||
IntField,
|
IntField,
|
||||||
StringField,
|
StringField,
|
||||||
)
|
)
|
||||||
|
from graphql.core.execution.middlewares.utils import (
|
||||||
|
tag_resolver,
|
||||||
|
resolver_has_tag
|
||||||
|
)
|
||||||
from graphql.core.type import (
|
from graphql.core.type import (
|
||||||
GraphQLObjectType,
|
GraphQLObjectType,
|
||||||
GraphQLInterfaceType
|
GraphQLInterfaceType
|
||||||
)
|
)
|
||||||
|
|
||||||
from graphene.core.types import (
|
from graphene.core.types import (
|
||||||
Interface,
|
Interface
|
||||||
ObjectType
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class Character(Interface):
|
class Character(Interface):
|
||||||
|
|
||||||
'''Character description'''
|
'''Character description'''
|
||||||
name = StringField()
|
name = StringField()
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ class Character(Interface):
|
||||||
|
|
||||||
|
|
||||||
class Human(Character):
|
class Human(Character):
|
||||||
|
|
||||||
'''Human description'''
|
'''Human description'''
|
||||||
friends = StringField()
|
friends = StringField()
|
||||||
|
|
||||||
|
@ -68,6 +67,7 @@ def test_field_clashes():
|
||||||
with raises(Exception) as excinfo:
|
with raises(Exception) as excinfo:
|
||||||
class Droid(Character):
|
class Droid(Character):
|
||||||
name = IntField()
|
name = IntField()
|
||||||
|
|
||||||
assert 'clashes' in str(excinfo.value)
|
assert 'clashes' in str(excinfo.value)
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,7 +77,8 @@ def test_field_mantain_resolver_tags():
|
||||||
|
|
||||||
def resolve_name(self, *args):
|
def resolve_name(self, *args):
|
||||||
return 'My Droid'
|
return 'My Droid'
|
||||||
resolve_name.custom_tag = True
|
|
||||||
|
tag_resolver(resolve_name, 'test')
|
||||||
|
|
||||||
field = Droid._meta.fields_map['name'].internal_field(schema)
|
field = Droid._meta.fields_map['name'].internal_field(schema)
|
||||||
assert field.resolver.custom_tag
|
assert resolver_has_tag(field.resolver, 'test')
|
Loading…
Reference in New Issue
Block a user