|
2 | 2 |
|
3 | 3 | import pytz
|
4 | 4 |
|
| 5 | +from graphql import GraphQLError |
| 6 | + |
5 | 7 | from ..datetime import DateTime, Date, Time
|
6 | 8 | from ..objecttype import ObjectType
|
7 | 9 | from ..schema import Schema
|
@@ -53,6 +55,32 @@ def test_time_query():
|
53 | 55 | assert not result.errors
|
54 | 56 | assert result.data == {'time': isoformat}
|
55 | 57 |
|
| 58 | +def test_bad_datetime_query(): |
| 59 | + not_a_date = "Some string that's not a date" |
| 60 | + |
| 61 | + result = schema.execute('''{ datetime(in: "%s") }''' % not_a_date) |
| 62 | + |
| 63 | + assert len(result.errors) == 1 |
| 64 | + assert isinstance(result.errors[0], GraphQLError) |
| 65 | + assert result.data == None |
| 66 | + |
| 67 | +def test_bad_date_query(): |
| 68 | + not_a_date = "Some string that's not a date" |
| 69 | + |
| 70 | + result = schema.execute('''{ date(in: "%s") }''' % not_a_date) |
| 71 | + |
| 72 | + assert len(result.errors) == 1 |
| 73 | + assert isinstance(result.errors[0], GraphQLError) |
| 74 | + assert result.data == None |
| 75 | + |
| 76 | +def test_bad_time_query(): |
| 77 | + not_a_date = "Some string that's not a date" |
| 78 | + |
| 79 | + result = schema.execute('''{ time(at: "%s") }''' % not_a_date) |
| 80 | + |
| 81 | + assert len(result.errors) == 1 |
| 82 | + assert isinstance(result.errors[0], GraphQLError) |
| 83 | + assert result.data == None |
56 | 84 |
|
57 | 85 | def test_datetime_query_variable():
|
58 | 86 | now = datetime.datetime.now().replace(tzinfo=pytz.utc)
|
|
0 commit comments