'Test that the min and max time uuid functions work as expected'

@execute_count(8)
def test_success_case(self):

    pk = uuid4()
    startpoint = datetime.utcnow()
    TimeUUIDQueryModel.create(partition=pk, time=uuid_from_time((startpoint + timedelta(seconds=1))), data='1')
    TimeUUIDQueryModel.create(partition=pk, time=uuid_from_time((startpoint + timedelta(seconds=2))), data='2')
    midpoint = (startpoint + timedelta(seconds=3))
    TimeUUIDQueryModel.create(partition=pk, time=uuid_from_time((startpoint + timedelta(seconds=4))), data='3')
    TimeUUIDQueryModel.create(partition=pk, time=uuid_from_time((startpoint + timedelta(seconds=5))), data='4')
    q = TimeUUIDQueryModel.filter(partition=pk, time__lte=functions.MaxTimeUUID(midpoint))
    q = [d for d in q]
    self.assertEqual(len(q), 2, msg=('Got:    %s' % q))
    datas = [d.data for d in q]
    assert ('1' in datas)
    assert ('2' in datas)
    q = TimeUUIDQueryModel.filter(partition=pk, time__gte=functions.MinTimeUUID(midpoint))
    assert (len(q) == 2)
    datas = [d.data for d in q]
    assert ('3' in datas)
    assert ('4' in datas)
    q = TimeUUIDQueryModel.filter((TimeUUIDQueryModel.partition == pk), (TimeUUIDQueryModel.time <= functions.MaxTimeUUID(midpoint)))
    q = [d for d in q]
    assert (len(q) == 2)
    datas = [d.data for d in q]
    assert ('1' in datas)
    assert ('2' in datas)
    q = TimeUUIDQueryModel.filter((TimeUUIDQueryModel.partition == pk), (TimeUUIDQueryModel.time >= functions.MinTimeUUID(midpoint)))
    assert (len(q) == 2)
    datas = [d.data for d in q]
    assert ('3' in datas)
    assert ('4' in datas)
