'Delete an image in a queued state
Bug #747799 demonstrated that trying to DELETE an image
that had had its save process killed manually results in failure
because the location attribute is None.
Bug #1048851 demonstrated that the status was not properly
being updated to \'deleted\' from \'queued\'.'

def test_delete_queued_image(self):

    fixture_headers = {'x-image-meta-store': 'file', 'x-image-meta-disk-format': 'vhd', 'x-image-meta-container-format': 'ovf', 'x-image-meta-name': 'fake    image    #3'}
    req = webob.Request.blank('/images')
    req.method = 'POST'
    for (k, v) in six.iteritems(fixture_headers):
        req.headers[k] = v
    res = req.get_response(self.api)
    self.assertEqual(http_client.CREATED, res.status_int)
    res_body = jsonutils.loads(res.body)['image']
    self.assertEqual('queued', res_body['status'])
    req = webob.Request.blank(('/images/%s' % res_body['id']))
    req.method = 'DELETE'
    res = req.get_response(self.api)
    self.assertEqual(http_client.OK, res.status_int)
    req = webob.Request.blank(('/images/%s' % res_body['id']))
    req.method = 'HEAD'
    res = req.get_response(self.api)
    self.assertEqual(http_client.OK, res.status_int)
    self.assertEqual('True', res.headers['x-image-meta-deleted'])
    self.assertEqual('deleted', res.headers['x-image-meta-status'])
