'Tests that all queued images may be deleted at once'

@skip_if_disabled
def test_cache_manage_delete_queued_images(self):

    self.cleanup()
    self.start_servers(**self.__dict__.copy())
    self.verify_no_images()
    ids = {}
    NUM_IMAGES = 4
    for x in range(NUM_IMAGES):
        ids[x] = self.add_image(('Image%s' % str(x)))
        path = ('http://%s:%d/v1/queued_images/%s' % ('127.0.0.1', self.api_port, ids[x]))
        http = httplib2.Http()
        (response, content) = http.request(path, 'PUT')
        self.assertEqual(http_client.OK, response.status)
    path = ('http://%s:%d/v1/queued_images' % ('127.0.0.1', self.api_port))
    http = httplib2.Http()
    (response, content) = http.request(path, 'DELETE')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)
    num_deleted = data['num_deleted']
    self.assertEqual(NUM_IMAGES, num_deleted)
    path = ('http://%s:%d/v1/queued_images' % ('127.0.0.1', self.api_port))
    http = httplib2.Http()
    (response, content) = http.request(path, 'DELETE')
    self.assertEqual(http_client.OK, response.status)
    data = jsonutils.loads(content)
    num_deleted = data['num_deleted']
    self.assertEqual(0, num_deleted)
    self.stop_servers()
