import datetime
import pytz

from ..datetime import DateTime
from ..objecttype import ObjectType
from ..schema import Schema


class Query(ObjectType):
    datetime = DateTime(_in=DateTime(name='in'))

    def resolve_datetime(self, args, context, info):
        _in = args.get('in')
        return _in

schema = Schema(query=Query)


def test_datetime_query():
    now = datetime.datetime.now().replace(tzinfo=pytz.utc)
    isoformat = now.isoformat()

    result = schema.execute('''{ datetime(in: "%s") }'''%isoformat)
    assert not result.errors
    assert result.data == {
        'datetime': isoformat
    }


def test_datetime_query_variable():
    now = datetime.datetime.now().replace(tzinfo=pytz.utc)
    isoformat = now.isoformat()

    result = schema.execute(
        '''query Test($date: DateTime){ datetime(in: $date) }''',
        variable_values={'date': isoformat}
    )
    assert not result.errors
    assert result.data == {
        'datetime': isoformat
    }

@@ -53,17 +53,23 @@
 DateTime
+, Time
 %0A
-
 from ..o
@@ -199,16 +199,53 @@
 e='in'))
+%0A    time = Time(_at=Time(name='at'))
 %0A%0A    de
@@ -340,16 +340,96 @@
 rn _in%0A%0A
+    def resolve_time(self, args, context, info):%0A        return args.get('at')%0A%0A
 schema =
@@ -733,16 +733,374 @@
     %7D%0A%0A%0A
+def test_time_query():%0A    now = datetime.datetime.now().replace(tzinfo=pytz.utc)%0A    time = datetime.time(now.hour, now.minute, now.second, now.microsecond, now.tzinfo)%0A    isoformat = time.isoformat()%0A%0A    result = schema.execute('''%7B time(at: %22%25s%22) %7D'''%25isoformat)%0A    assert not result.errors%0A    assert result.data == %7B%0A        'time': isoformat%0A    %7D%0A%0A
 def test

add time query test