def test_add_cleanup_on_read_failure(self):
        ChunkedFile.CHUNKSIZE = units.Ki
        image_id = str(uuid.uuid4())
        file_size = 5 * units.Ki  # 5K
        file_contents = b"*" * file_size
        path = os.path.join(self.test_dir, image_id)
        image_file = six.BytesIO(file_contents)

        def fake_Error(size):
            raise AttributeError()

        with mock.patch.object(image_file, 'read') as mock_read:
            mock_read.side_effect = fake_Error

            self.assertRaises(AttributeError,
                              self.store.add,
                              image_id, image_file, 0)
            self.assertFalse(os.path.exists(path))
Tests the partial image file is cleaned up after a read
dataset/ETHPy150Open openstack/glance_store/glance_store/tests/unit/test_filesystem_store.py/TestStore.test_add_cleanup_on_read_failure