'Test that when the backend fails, caching_iter does not continue trying
to consume data, and rolls back the cache.'

def test_caching_iterator_handles_backend_failure(self):

    def faulty_backend():
        data = ['a', 'b', 'c', 'Fail', 'd', 'e', 'f']
        for d in data:
            if (d == 'Fail'):
                raise exception.GlanceException('Backend    failure')
            (yield d)
    def consume(image_id):
        caching_iter = self.cache.get_caching_iter(image_id, None, faulty_backend())
        list(caching_iter)
    image_id = '1'
    self.assertRaises(exception.GlanceException, consume, image_id)
    self.assertFalse(self.cache.is_cached(image_id))
