'Ensure marker and limit query params work'

def test_limited_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 = minimal_headers('Image1')
    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 = minimal_headers('Image2')
    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 = minimal_headers('Image3')
    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)
    images = jsonutils.loads(content)['images']
    self.assertEqual(3, len(images))
    params = 'limit=2'
    path = ('/v1/images?%s' % params)
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)['images']
    self.assertEqual(2, len(data))
    self.assertEqual(images[0]['id'], data[0]['id'])
    self.assertEqual(images[1]['id'], data[1]['id'])
    params = ('marker=%s' % images[0]['id'])
    path = ('/v1/images?%s' % params)
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)['images']
    self.assertEqual(2, len(data))
    self.assertEqual(images[1]['id'], data[0]['id'])
    self.assertEqual(images[2]['id'], data[1]['id'])
    params = ('limit=1&marker=%s' % images[1]['id'])
    path = ('/v1/images?%s' % params)
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)['images']
    self.assertEqual(1, len(data))
    self.assertEqual(images[2]['id'], data[0]['id'])
    params = ('limit=1&marker=%s' % images[1]['id'])
    path = ('/v1/images?%s' % params)
    (response, content) = self.http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)['images']
    self.assertEqual(1, len(data))
    self.assertEqual(images[2]['id'], data[0]['id'])
    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)
