mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-22 13:59:51 +03:00
Make tests work with GraphQL-core 3.2.0rc2
This fix aligns to some changes in GraphQL-core 3.2 which reflect changes in GraphQL.js 16: - type resolvers must return only names - doesn't print trailing newlines any more - different wording of some error messages
This commit is contained in:
parent
0a54094f59
commit
989970f893
|
@ -9,7 +9,7 @@ client = Client(schema)
|
||||||
|
|
||||||
|
|
||||||
def test_str_schema(snapshot):
|
def test_str_schema(snapshot):
|
||||||
snapshot.assert_match(str(schema))
|
snapshot.assert_match(str(schema).rstrip() + "\n")
|
||||||
|
|
||||||
|
|
||||||
def test_correctly_fetches_id_name_rebels(snapshot):
|
def test_correctly_fetches_id_name_rebels(snapshot):
|
||||||
|
|
|
@ -171,7 +171,7 @@ def test_node_field_only_lazy_type_wrong():
|
||||||
|
|
||||||
|
|
||||||
def test_str_schema():
|
def test_str_schema():
|
||||||
assert str(schema) == dedent(
|
assert str(schema).rstrip() + "\n" == dedent(
|
||||||
'''
|
'''
|
||||||
schema {
|
schema {
|
||||||
query: RootQuery
|
query: RootQuery
|
||||||
|
|
|
@ -54,7 +54,7 @@ graphql_schema = schema.graphql_schema
|
||||||
|
|
||||||
|
|
||||||
def test_str_schema_correct():
|
def test_str_schema_correct():
|
||||||
assert str(schema) == dedent(
|
assert str(schema).rstrip() + "\n" == dedent(
|
||||||
'''
|
'''
|
||||||
schema {
|
schema {
|
||||||
query: RootQuery
|
query: RootQuery
|
||||||
|
|
|
@ -381,12 +381,7 @@ class TypeMap(dict):
|
||||||
return default_type_resolver(root, info, return_type)
|
return default_type_resolver(root, info, return_type)
|
||||||
|
|
||||||
if inspect.isclass(type_) and issubclass(type_, ObjectType):
|
if inspect.isclass(type_) and issubclass(type_, ObjectType):
|
||||||
graphql_type = self.get(type_._meta.name)
|
return type_._meta.name
|
||||||
assert graphql_type, f"Can't find type {type_._meta.name} in schema"
|
|
||||||
assert (
|
|
||||||
graphql_type.graphene_type == type_
|
|
||||||
), f"The type {type_} does not match with the associated graphene type {graphql_type.graphene_type}."
|
|
||||||
return graphql_type
|
|
||||||
|
|
||||||
return type_
|
return type_
|
||||||
|
|
||||||
|
|
|
@ -251,7 +251,7 @@ def test_enum_types():
|
||||||
|
|
||||||
schema = Schema(query=Query)
|
schema = Schema(query=Query)
|
||||||
|
|
||||||
assert str(schema) == dedent(
|
assert str(schema).rstrip() + "\n" == dedent(
|
||||||
'''\
|
'''\
|
||||||
type Query {
|
type Query {
|
||||||
color: Color!
|
color: Color!
|
||||||
|
@ -345,10 +345,8 @@ def test_enum_resolver_invalid():
|
||||||
|
|
||||||
results = schema.execute("query { color }")
|
results = schema.execute("query { color }")
|
||||||
assert results.errors
|
assert results.errors
|
||||||
assert (
|
message = results.errors[0].message
|
||||||
results.errors[0].message
|
assert "Expected" in message and "Color" in message and "BLACK" in message
|
||||||
== "Expected a value of type 'Color' but received: 'BLACK'"
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def test_field_enum_argument():
|
def test_field_enum_argument():
|
||||||
|
|
|
@ -43,7 +43,7 @@ def test_schema_get_type_error():
|
||||||
|
|
||||||
def test_schema_str():
|
def test_schema_str():
|
||||||
schema = Schema(Query)
|
schema = Schema(Query)
|
||||||
assert str(schema) == dedent(
|
assert str(schema).rstrip() + "\n" == dedent(
|
||||||
"""
|
"""
|
||||||
type Query {
|
type Query {
|
||||||
inner: MyOtherType
|
inner: MyOtherType
|
||||||
|
|
|
@ -72,4 +72,4 @@ class Union(UnmountedType, BaseType):
|
||||||
from .objecttype import ObjectType # NOQA
|
from .objecttype import ObjectType # NOQA
|
||||||
|
|
||||||
if isinstance(instance, ObjectType):
|
if isinstance(instance, ObjectType):
|
||||||
return type(instance)
|
return instance._meta.name
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -82,7 +82,7 @@ setup(
|
||||||
keywords="api graphql protocol rest relay graphene",
|
keywords="api graphql protocol rest relay graphene",
|
||||||
packages=find_packages(exclude=["examples*"]),
|
packages=find_packages(exclude=["examples*"]),
|
||||||
install_requires=[
|
install_requires=[
|
||||||
"graphql-core~=3.1.2",
|
"graphql-core>=3.1.2,<3.3",
|
||||||
"graphql-relay>=3.0,<4",
|
"graphql-relay>=3.0,<4",
|
||||||
"aniso8601>=8,<10",
|
"aniso8601>=8,<10",
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue
Block a user