'Test to see if the caching iterator interacts properly with the driver
When the iterator completes going through the data the driver should
have closed the image and placed it correctly'

def test_caching_iterator(self):

    def consume(image_id):
        data = ['a', 'b', 'c', 'd', 'e', 'f']
        checksum = None
        caching_iter = self.cache.get_caching_iter(image_id, checksum, iter(data))
        self.assertEqual(data, list(caching_iter))
    image_id = '1'
    self.assertFalse(self.cache.is_cached(image_id))
    consume(image_id)
    self.assertTrue(self.cache.is_cached(image_id), ('Image    %s    was    NOT    cached!' % image_id))
    incomplete_file_path = os.path.join(self.cache_dir, 'incomplete', image_id)
    invalid_file_path = os.path.join(self.cache_dir, 'invalid', image_id)
    self.assertFalse(os.path.exists(incomplete_file_path))
    self.assertFalse(os.path.exists(invalid_file_path))
