mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-22 13:59:51 +03:00
Fix tests
This commit is contained in:
parent
c30d8d0231
commit
3327ca47c2
|
@ -7,6 +7,7 @@ from graphql import (
|
||||||
GraphQLObjectType,
|
GraphQLObjectType,
|
||||||
GraphQLScalarType,
|
GraphQLScalarType,
|
||||||
GraphQLUnionType,
|
GraphQLUnionType,
|
||||||
|
Undefined,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ class GrapheneEnumType(GrapheneGraphQLType, GraphQLEnumType):
|
||||||
try:
|
try:
|
||||||
value = enum[value]
|
value = enum[value]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
value = None
|
return Undefined
|
||||||
return super(GrapheneEnumType, self).serialize(value)
|
return super(GrapheneEnumType, self).serialize(value)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -234,8 +234,10 @@ def test_enum_types():
|
||||||
from enum import Enum as PyEnum
|
from enum import Enum as PyEnum
|
||||||
|
|
||||||
class Color(PyEnum):
|
class Color(PyEnum):
|
||||||
|
"""Primary colors"""
|
||||||
|
|
||||||
RED = 1
|
RED = 1
|
||||||
GREEN = 2
|
YELLOW = 2
|
||||||
BLUE = 3
|
BLUE = 3
|
||||||
|
|
||||||
GColor = Enum.from_enum(Color)
|
GColor = Enum.from_enum(Color)
|
||||||
|
@ -250,16 +252,16 @@ def test_enum_types():
|
||||||
|
|
||||||
assert str(schema) == dedent(
|
assert str(schema) == dedent(
|
||||||
'''\
|
'''\
|
||||||
"""An enumeration."""
|
|
||||||
enum Color {
|
|
||||||
RED
|
|
||||||
GREEN
|
|
||||||
BLUE
|
|
||||||
}
|
|
||||||
|
|
||||||
type Query {
|
type Query {
|
||||||
color: Color!
|
color: Color!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"""Primary colors"""
|
||||||
|
enum Color {
|
||||||
|
RED
|
||||||
|
YELLOW
|
||||||
|
BLUE
|
||||||
|
}
|
||||||
'''
|
'''
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user