@skip_if_disabled
    def test_cache_manage_delete_cached_images(self):
        """
        Tests that cached images may be deleted
        """
        self.cleanup()
        self.start_servers(**self.__dict__.copy())

        api_port = self.api_port
        registry_port = self.registry_port

        self.verify_no_images()

        ids = {}

        # Add a bunch of images...
        for x in xrange(0, 4):
            ids[x] = self.add_image(str(x) % "Image%s")

        # Verify no images in cached_images because no image has been hit
        # yet using a GET /images/<IMAGE_ID> ...
        self.verify_no_cached_images()

        # Grab the images, essentially caching them...
        for x in xrange(0, 4):
            path = "http://%s:%d/v1/images/%s" % ("0.0.0.0", self.api_port,
                                                  ids[x])
            http = httplib2.Http()
            response, content = http.request(path, 'GET')
            self.assertEqual(response.status, 200,
                             "Failed to find image %s" % ids[x])

        # Verify images now in cache
        path = "http://%s:%d/v1/cached_images" % ("0.0.0.0", self.api_port)
        http = httplib2.Http()
        response, content = http.request(path, 'GET')
        self.assertEqual(response.status, 200)

        data = json.loads(content)
        self.assertTrue('cached_images' in data)

        cached_images = data['cached_images']
        self.assertEqual(4, len(cached_images))

        for x in xrange(4, 0):  # Cached images returned last modified order
            self.assertEqual(ids[x], cached_images[x]['image_id'])
            self.assertEqual(0, cached_images[x]['hits'])

        # Delete third image of the cached images and verify no longer in cache
        path = "http://%s:%d/v1/cached_images/%s" % ("0.0.0.0", self.api_port,
                                                     ids[2])
        http = httplib2.Http()
        response, content = http.request(path, 'DELETE')
        self.assertEqual(response.status, 200)

        path = "http://%s:%d/v1/cached_images" % ("0.0.0.0", self.api_port)
        http = httplib2.Http()
        response, content = http.request(path, 'GET')
        self.assertEqual(response.status, 200)

        data = json.loads(content)
        self.assertTrue('cached_images' in data)

        cached_images = data['cached_images']
        self.assertEqual(3, len(cached_images))
        self.assertTrue(ids[2] not in [x['image_id'] for x in cached_images])

        # Delete all cached images and verify nothing in cache
        path = "http://%s:%d/v1/cached_images" % ("0.0.0.0", self.api_port)
        http = httplib2.Http()
        response, content = http.request(path, 'DELETE')
        self.assertEqual(response.status, 200)

        path = "http://%s:%d/v1/cached_images" % ("0.0.0.0", self.api_port)
        http = httplib2.Http()
        response, content = http.request(path, 'GET')
        self.assertEqual(response.status, 200)

        data = json.loads(content)
        self.assertTrue('cached_images' in data)

        cached_images = data['cached_images']
        self.assertEqual(0, len(cached_images))

        self.stop_servers()
dataset/ETHPy150Open rcbops/glance-buildpackage/glance/tests/functional/test_cache_middleware.py/BaseCacheManageMiddlewareTest.test_cache_manage_delete_cached_images/swapped operands of `%`