'Set up three test images and ensure each query param filter works'

def test_ordered_images(self):

    path = '/v1/images'
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    self.assertEqual('{"images":    []}', content)
    image_ids = []
    headers = {'Content-Type': 'application/octet-stream', 'X-Image-Meta-Name': 'Image1', 'X-Image-Meta-Status': 'active', 'X-Image-Meta-Container-Format': 'ovf', 'X-Image-Meta-Disk-Format': 'vdi', 'X-Image-Meta-Size': '19', 'X-Image-Meta-Is-Public': 'True'}
    path = '/v1/images'
    (response, content) = self.http.request(path, 'POST', headers=headers)
    self.assertEqual(http_client.CREATED, response.status)
    image_ids.append(jsonutils.loads(content)['image']['id'])
    headers = {'Content-Type': 'application/octet-stream', 'X-Image-Meta-Name': 'ASDF', 'X-Image-Meta-Status': 'active', 'X-Image-Meta-Container-Format': 'bare', 'X-Image-Meta-Disk-Format': 'iso', 'X-Image-Meta-Size': '2', 'X-Image-Meta-Is-Public': 'True'}
    path = '/v1/images'
    (response, content) = self.http.request(path, 'POST', headers=headers)
    self.assertEqual(http_client.CREATED, response.status)
    image_ids.append(jsonutils.loads(content)['image']['id'])
    headers = {'Content-Type': 'application/octet-stream', 'X-Image-Meta-Name': 'XYZ', 'X-Image-Meta-Status': 'saving', 'X-Image-Meta-Container-Format': 'ami', 'X-Image-Meta-Disk-Format': 'ami', 'X-Image-Meta-Size': '5', 'X-Image-Meta-Is-Public': 'True'}
    path = '/v1/images'
    (response, content) = self.http.request(path, 'POST', headers=headers)
    self.assertEqual(http_client.CREATED, response.status)
    image_ids.append(jsonutils.loads(content)['image']['id'])
    path = '/v1/images'
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)
    self.assertEqual(3, len(data['images']))
    self.assertEqual(image_ids[2], data['images'][0]['id'])
    self.assertEqual(image_ids[1], data['images'][1]['id'])
    self.assertEqual(image_ids[0], data['images'][2]['id'])
    params = 'sort_key=name&sort_dir=asc'
    path = ('/v1/images?%s' % params)
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)
    self.assertEqual(3, len(data['images']))
    self.assertEqual(image_ids[1], data['images'][0]['id'])
    self.assertEqual(image_ids[0], data['images'][1]['id'])
    self.assertEqual(image_ids[2], data['images'][2]['id'])
    params = 'sort_key=size&sort_dir=desc'
    path = ('/v1/images?%s' % params)
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)
    self.assertEqual(3, len(data['images']))
    self.assertEqual(image_ids[0], data['images'][0]['id'])
    self.assertEqual(image_ids[2], data['images'][1]['id'])
    self.assertEqual(image_ids[1], data['images'][2]['id'])
    params = ('sort_key=size&sort_dir=desc&marker=%s' % image_ids[0])
    path = ('/v1/images?%s' % params)
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)
    self.assertEqual(2, len(data['images']))
    self.assertEqual(image_ids[2], data['images'][0]['id'])
    self.assertEqual(image_ids[1], data['images'][1]['id'])
    params = ('sort_key=name&sort_dir=asc&marker=%s' % image_ids[2])
    path = ('/v1/images?%s' % params)
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)
    self.assertEqual(0, len(data['images']))
    for image_id in image_ids:
        path = ('/v1/images/%s' % image_id)
        (response, content) = self.http.request(path, 'DELETE')
        self.assertEqual(http_client.OK, response.status)
