'Tests that the registry API deletes the image'

def test_delete_image(self):

    req = webob.Request.blank('/rpc')
    req.method = 'POST'
    cmd = [{'command': 'image_get_all', 'kwargs': {'filters': {'deleted': False}}}]
    req.body = jsonutils.dump_as_bytes(cmd)
    res = req.get_response(self.api)
    res_dict = jsonutils.loads(res.body)[0]
    self.assertEqual(http.OK, res.status_int)
    orig_num_images = len(res_dict)
    cmd = [{'command': 'image_destroy', 'kwargs': {'image_id': UUID2}}]
    req.body = jsonutils.dump_as_bytes(cmd)
    res = req.get_response(self.api)
    self.assertEqual(http.OK, res.status_int)
    cmd = [{'command': 'image_get_all', 'kwargs': {'filters': {'deleted': False}}}]
    req.body = jsonutils.dump_as_bytes(cmd)
    res = req.get_response(self.api)
    res_dict = jsonutils.loads(res.body)[0]
    self.assertEqual(http.OK, res.status_int)
    new_num_images = len(res_dict)
    self.assertEqual(new_num_images, (orig_num_images - 1))
