mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-11 12:16:58 +03:00
add time query test
This commit is contained in:
parent
f089c78b99
commit
48b422e289
|
@ -1,18 +1,22 @@
|
||||||
import datetime
|
import datetime
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
from ..datetime import DateTime
|
from ..datetime import DateTime, Time
|
||||||
from ..objecttype import ObjectType
|
from ..objecttype import ObjectType
|
||||||
from ..schema import Schema
|
from ..schema import Schema
|
||||||
|
|
||||||
|
|
||||||
class Query(ObjectType):
|
class Query(ObjectType):
|
||||||
datetime = DateTime(_in=DateTime(name='in'))
|
datetime = DateTime(_in=DateTime(name='in'))
|
||||||
|
time = Time(_at=Time(name='at'))
|
||||||
|
|
||||||
def resolve_datetime(self, args, context, info):
|
def resolve_datetime(self, args, context, info):
|
||||||
_in = args.get('in')
|
_in = args.get('in')
|
||||||
return _in
|
return _in
|
||||||
|
|
||||||
|
def resolve_time(self, args, context, info):
|
||||||
|
return args.get('at')
|
||||||
|
|
||||||
schema = Schema(query=Query)
|
schema = Schema(query=Query)
|
||||||
|
|
||||||
|
|
||||||
|
@ -27,6 +31,17 @@ def test_datetime_query():
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def test_time_query():
|
||||||
|
now = datetime.datetime.now().replace(tzinfo=pytz.utc)
|
||||||
|
time = datetime.time(now.hour, now.minute, now.second, now.microsecond, now.tzinfo)
|
||||||
|
isoformat = time.isoformat()
|
||||||
|
|
||||||
|
result = schema.execute('''{ time(at: "%s") }'''%isoformat)
|
||||||
|
assert not result.errors
|
||||||
|
assert result.data == {
|
||||||
|
'time': isoformat
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
isoformat = now.isoformat()
|
isoformat = now.isoformat()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user