'Verifies sort order with pagination.'

def test_volume_get_all_by_filters_sort_keys_paginate(self):

    test1_avail = db.volume_create(self.ctxt, {'display_name': 'test', 'size': 1, 'status': 'available'})
    test1_error = db.volume_create(self.ctxt, {'display_name': 'test', 'size': 1, 'status': 'error'})
    test1_error2 = db.volume_create(self.ctxt, {'display_name': 'test', 'size': 1, 'status': 'error'})
    test2_avail = db.volume_create(self.ctxt, {'display_name': 'test', 'size': 2, 'status': 'available'})
    test2_error = db.volume_create(self.ctxt, {'display_name': 'test', 'size': 2, 'status': 'error'})
    test2_error2 = db.volume_create(self.ctxt, {'display_name': 'test', 'size': 2, 'status': 'error'})
    db.volume_create(self.ctxt, {'display_name': 'other'})
    db.volume_create(self.ctxt, {'display_name': 'other'})
    filters = {'display_name': 'test'}
    sort_keys = ['size', 'status', 'created_at']
    sort_dirs = ['asc', 'desc', 'asc']
    correct_order = [test1_error, test1_error2, test1_avail, test2_error, test2_error2, test2_avail]
    for limit in range(1, 4):
        marker = None
        for i in range(0, 7, limit):
            if (i == len(correct_order)):
                correct = []
            else:
                correct = correct_order[i:(i + limit)]
            vols = self._assertEqualsVolumeOrderResult(correct, filters=filters, sort_keys=sort_keys, sort_dirs=sort_dirs, limit=limit, marker=marker)
            if correct:
                marker = vols[(-1)]['id']
                self.assertEqual(correct[(-1)]['id'], marker)
