'Test that cache index command works'

def test_cache_index(self):

    self.cleanup()
    self.start_servers(**self.__dict__.copy())
    api_port = self.api_port
    exe_cmd = ('%s    -m    glance.cmd.cache_manage' % sys.executable)
    cmd = ('%s    --port=%d    list-cached' % (exe_cmd, api_port))
    (exitcode, out, err) = execute(cmd)
    self.assertEqual(0, exitcode)
    self.assertIn('No    cached    images', out.strip())
    ids = {}
    for x in range(4):
        ids[x] = self.add_image(('Image%s' % x))
    path = ('http://%s:%d/v1/images/%s' % ('127.0.0.1', api_port, ids[1]))
    http = httplib2.Http()
    (response, content) = http.request(path, 'GET')
    self.assertEqual(http_client.OK, response.status)
    self.assertTrue(self.is_image_cached(ids[1]), ('%s    is    not    cached.' % ids[1]))
    self.assertTrue(self.iso_date(ids[1]))
    self.stop_servers()
