'Test that pruning the cache works as expected...'

@skip_if_disabled
def test_prune(self):

    self.assertEqual(0, self.cache.get_cache_size())
    for x in range(10):
        FIXTURE_FILE = six.BytesIO(FIXTURE_DATA)
        self.assertTrue(self.cache.cache_image_file(x, FIXTURE_FILE))
    self.assertEqual((10 * units.Ki), self.cache.get_cache_size())
    for x in range(10):
        buff = six.BytesIO()
        with self.cache.open_for_read(x) as cache_file:
            for chunk in cache_file:
                buff.write(chunk)
    FIXTURE_FILE = six.BytesIO(FIXTURE_DATA)
    self.assertTrue(self.cache.cache_image_file(99, FIXTURE_FILE))
    self.cache.prune()
    self.assertEqual((5 * units.Ki), self.cache.get_cache_size())
    for x in range(0, 6):
        self.assertFalse(self.cache.is_cached(x), ('Image    %s    was    cached!' % x))
    for x in range(6, 10):
        self.assertTrue(self.cache.is_cached(x), ('Image    %s    was    not    cached!' % x))
    self.assertTrue(self.cache.is_cached(99), 'Image    99    was    not    cached!')
