-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test [1293]: regression test print schema with InputObjectType with D…
…ateTime field with default_value
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# https://github.com/graphql-python/graphene/issues/1293 | ||
|
||
import datetime | ||
|
||
import graphene | ||
from graphql.utilities import print_schema | ||
|
||
|
||
class Filters(graphene.InputObjectType): | ||
datetime_after = graphene.DateTime( | ||
required=False, | ||
default_value=datetime.datetime.utcfromtimestamp(1434549820776 / 1000), | ||
) | ||
datetime_before = graphene.DateTime( | ||
required=False, | ||
default_value=datetime.datetime.utcfromtimestamp(1444549820776 / 1000), | ||
) | ||
|
||
|
||
class SetDatetime(graphene.Mutation): | ||
class Arguments: | ||
filters = Filters(required=True) | ||
|
||
ok = graphene.Boolean() | ||
|
||
def mutate(root, info, filters): | ||
return SetDatetime(ok=True) | ||
|
||
|
||
class Query(graphene.ObjectType): | ||
goodbye = graphene.String() | ||
|
||
|
||
class Mutations(graphene.ObjectType): | ||
set_datetime = SetDatetime.Field() | ||
|
||
|
||
def test_print_schema(): | ||
schema = graphene.Schema(query=Query, mutation=Mutations) | ||
schema_str = print_schema(schema.graphql_schema) | ||
assert schema_str, "non-empty schema printed" |