Skip to content

Commit 99f0103

Browse files
ransomwerikwrede
andauthored
test: print schema with InputObjectType with DateTime field with default_value (#1293) (#1513)
* test [1293]: regression test print schema with InputObjectType with DateTime field with default_value * chore: clarify test title and assertion --------- Co-authored-by: Erik Wrede <[email protected]>
1 parent 03cf2e1 commit 99f0103

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

graphene/tests/issues/test_1293.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# https://github.com/graphql-python/graphene/issues/1293
2+
3+
import datetime
4+
5+
import graphene
6+
from graphql.utilities import print_schema
7+
8+
9+
class Filters(graphene.InputObjectType):
10+
datetime_after = graphene.DateTime(
11+
required=False,
12+
default_value=datetime.datetime.utcfromtimestamp(1434549820776 / 1000),
13+
)
14+
datetime_before = graphene.DateTime(
15+
required=False,
16+
default_value=datetime.datetime.utcfromtimestamp(1444549820776 / 1000),
17+
)
18+
19+
20+
class SetDatetime(graphene.Mutation):
21+
class Arguments:
22+
filters = Filters(required=True)
23+
24+
ok = graphene.Boolean()
25+
26+
def mutate(root, info, filters):
27+
return SetDatetime(ok=True)
28+
29+
30+
class Query(graphene.ObjectType):
31+
goodbye = graphene.String()
32+
33+
34+
class Mutations(graphene.ObjectType):
35+
set_datetime = SetDatetime.Field()
36+
37+
38+
def test_schema_printable_with_default_datetime_value():
39+
schema = graphene.Schema(query=Query, mutation=Mutations)
40+
schema_str = print_schema(schema.graphql_schema)
41+
assert schema_str, "empty schema printed"

0 commit comments

Comments
 (0)