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):
|
||||
snapshot.assert_match(str(schema))
|
||||
snapshot.assert_match(str(schema).rstrip() + "\n")
|
||||
|
||||
|
||||
def test_correctly_fetches_id_name_rebels(snapshot):
|
||||
|
|
|
@ -171,7 +171,7 @@ def test_node_field_only_lazy_type_wrong():
|
|||
|
||||
|
||||
def test_str_schema():
|
||||
assert str(schema) == dedent(
|
||||
assert str(schema).rstrip() + "\n" == dedent(
|
||||
'''
|
||||
schema {
|
||||
query: RootQuery
|
||||
|
|
|
@ -54,7 +54,7 @@ graphql_schema = schema.graphql_schema
|
|||
|
||||
|
||||
def test_str_schema_correct():
|
||||
assert str(schema) == dedent(
|
||||
assert str(schema).rstrip() + "\n" == dedent(
|
||||
'''
|
||||
schema {
|
||||
query: RootQuery
|
||||
|
|
|
@ -381,12 +381,7 @@ class TypeMap(dict):
|
|||
return default_type_resolver(root, info, return_type)
|
||||
|
||||
if inspect.isclass(type_) and issubclass(type_, ObjectType):
|
||||
graphql_type = self.get(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_._meta.name
|
||||
|
||||
return type_
|
||||
|
||||
|
|
|
@ -251,7 +251,7 @@ def test_enum_types():
|
|||
|
||||
schema = Schema(query=Query)
|
||||
|
||||
assert str(schema) == dedent(
|
||||
assert str(schema).rstrip() + "\n" == dedent(
|
||||
'''\
|
||||
type Query {
|
||||
color: Color!
|
||||
|
@ -345,10 +345,8 @@ def test_enum_resolver_invalid():
|
|||
|
||||
results = schema.execute("query { color }")
|
||||
assert results.errors
|
||||
assert (
|
||||
results.errors[0].message
|
||||
== "Expected a value of type 'Color' but received: 'BLACK'"
|
||||
)
|
||||
message = results.errors[0].message
|
||||
assert "Expected" in message and "Color" in message and "BLACK" in message
|
||||
|
||||
|
||||
def test_field_enum_argument():
|
||||
|
|
|
@ -43,7 +43,7 @@ def test_schema_get_type_error():
|
|||
|
||||
def test_schema_str():
|
||||
schema = Schema(Query)
|
||||
assert str(schema) == dedent(
|
||||
assert str(schema).rstrip() + "\n" == dedent(
|
||||
"""
|
||||
type Query {
|
||||
inner: MyOtherType
|
||||
|
|
|
@ -72,4 +72,4 @@ class Union(UnmountedType, BaseType):
|
|||
from .objecttype import ObjectType # NOQA
|
||||
|
||||
if isinstance(instance, ObjectType):
|
||||
return type(instance)
|
||||
return instance._meta.name
|
||||
|
|
Loading…
Reference in New Issue
Block a user