mirror of
https://github.com/graphql-python/graphene.git
synced 2025-02-02 12:44:15 +03:00
added tests for when bad input is passed into date/datetime/time fields
This commit is contained in:
parent
2a67ffeb35
commit
9973fd314f
|
@ -2,6 +2,8 @@ import datetime
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
|
from graphql import GraphQLError
|
||||||
|
|
||||||
from ..datetime import DateTime, Date, Time
|
from ..datetime import DateTime, Date, Time
|
||||||
from ..objecttype import ObjectType
|
from ..objecttype import ObjectType
|
||||||
from ..schema import Schema
|
from ..schema import Schema
|
||||||
|
@ -53,6 +55,32 @@ def test_time_query():
|
||||||
assert not result.errors
|
assert not result.errors
|
||||||
assert result.data == {'time': isoformat}
|
assert result.data == {'time': isoformat}
|
||||||
|
|
||||||
|
def test_bad_datetime_query():
|
||||||
|
not_a_date = "Some string that's not a date"
|
||||||
|
|
||||||
|
result = schema.execute('''{ datetime(in: "%s") }''' % not_a_date)
|
||||||
|
|
||||||
|
assert len(result.errors) == 1
|
||||||
|
assert isinstance(result.errors[0], GraphQLError)
|
||||||
|
assert result.data == None
|
||||||
|
|
||||||
|
def test_bad_date_query():
|
||||||
|
not_a_date = "Some string that's not a date"
|
||||||
|
|
||||||
|
result = schema.execute('''{ date(in: "%s") }''' % not_a_date)
|
||||||
|
|
||||||
|
assert len(result.errors) == 1
|
||||||
|
assert isinstance(result.errors[0], GraphQLError)
|
||||||
|
assert result.data == None
|
||||||
|
|
||||||
|
def test_bad_time_query():
|
||||||
|
not_a_date = "Some string that's not a date"
|
||||||
|
|
||||||
|
result = schema.execute('''{ time(at: "%s") }''' % not_a_date)
|
||||||
|
|
||||||
|
assert len(result.errors) == 1
|
||||||
|
assert isinstance(result.errors[0], GraphQLError)
|
||||||
|
assert result.data == None
|
||||||
|
|
||||||
def test_datetime_query_variable():
|
def test_datetime_query_variable():
|
||||||
now = datetime.datetime.now().replace(tzinfo=pytz.utc)
|
now = datetime.datetime.now().replace(tzinfo=pytz.utc)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user