Fix tests

This commit is contained in:
Jonathan Kim 2020-06-25 10:57:18 +01:00
parent c30d8d0231
commit 3327ca47c2
2 changed files with 12 additions and 9 deletions

View File

@ -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)

View File

@ -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
}
''' '''
) )