add some more complicated tests

This commit is contained in:
mykyta 2021-09-11 13:05:17 +03:00
parent b7404ecf81
commit cc1e60c911

View File

@ -486,9 +486,6 @@ def test_enum_inheritance():
class Query(ObjectType): class Query(ObjectType):
color = ChildRGB(required=True) color = ChildRGB(required=True)
def resolve_color(_, info):
return ChildRGB.RED
schema = Schema(query=Query) schema = Schema(query=Query)
assert str(schema) == dedent( assert str(schema) == dedent(
'''\ '''\
@ -502,3 +499,49 @@ def test_enum_inheritance():
} }
''' '''
) )
def test_multiple_enum_inheritance():
class Parent1RGB(Enum):
RED = 1
class Parent2RGB(Enum):
BLUE = 2
class ChildRGB(Enum):
GREEN = 3
class Meta:
enums = (Parent1RGB, Parent2RGB,)
class Query(ObjectType):
color = ChildRGB(required=True)
schema = Schema(query=Query)
assert str(schema) == dedent(
'''\
type Query {
color: ChildRGB!
}
enum ChildRGB {
RED
BLUE
GREEN
}
'''
)
def test_override_enum_inheritance():
class ParentRGB(Enum):
RED = 1
BLUE = 2
class ChildRGB(Enum):
BLUE = 3
class Meta:
enums = (ParentRGB,)
assert ChildRGB.get(3) != ParentRGB.BLUE