'Test that using timezone aware datetime instances works with the
MinTimeUUID/MaxTimeUUID functions.'

@execute_count(7)
def test_tzaware_datetime_support(self):

    pk = uuid4()
    midpoint_utc = datetime.utcnow().replace(tzinfo=TzOffset(0))
    midpoint_helsinki = midpoint_utc.astimezone(TzOffset(3))
    assert (midpoint_utc.utctimetuple() == midpoint_helsinki.utctimetuple())
    assert (midpoint_utc.timetuple() != midpoint_helsinki.timetuple())
    TimeUUIDQueryModel.create(partition=pk, time=uuid_from_time((midpoint_utc - timedelta(minutes=1))), data='1')
    TimeUUIDQueryModel.create(partition=pk, time=uuid_from_time(midpoint_utc), data='2')
    TimeUUIDQueryModel.create(partition=pk, time=uuid_from_time((midpoint_utc + timedelta(minutes=1))), data='3')
    assert (['1', '2'] == [o.data for o in TimeUUIDQueryModel.filter((TimeUUIDQueryModel.partition == pk), (TimeUUIDQueryModel.time <= functions.MaxTimeUUID(midpoint_utc)))])
    assert (['1', '2'] == [o.data for o in TimeUUIDQueryModel.filter((TimeUUIDQueryModel.partition == pk), (TimeUUIDQueryModel.time <= functions.MaxTimeUUID(midpoint_helsinki)))])
    assert (['2', '3'] == [o.data for o in TimeUUIDQueryModel.filter((TimeUUIDQueryModel.partition == pk), (TimeUUIDQueryModel.time >= functions.MinTimeUUID(midpoint_utc)))])
    assert (['2', '3'] == [o.data for o in TimeUUIDQueryModel.filter((TimeUUIDQueryModel.partition == pk), (TimeUUIDQueryModel.time >= functions.MinTimeUUID(midpoint_helsinki)))])
