'Test create volume with ImageCopyFailure
This exception should not trigger rescheduling and allocated_capacity
should be incremented so we\'re having assert for that here.'

@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_volume_from_image_copy_exception_rescheduling(self, mock_qemu_info):

    image_info = imageutils.QemuImgInfo()
    image_info.virtual_size = '1073741824'
    mock_qemu_info.return_value = image_info
    def fake_copy_image_to_volume(context, volume, image_service, image_id):
        raise exception.ImageCopyFailure()
    self.mock_object(self.volume.driver, 'copy_image_to_volume', fake_copy_image_to_volume)
    mock_delete = self.mock_object(self.volume.driver, 'delete_volume')
    self.assertRaises(exception.ImageCopyFailure, self._create_volume_from_image)
    self.assertDictEqual(self.volume.stats['pools'], {'_pool0': {'allocated_capacity_gb': 1}})
    self.assertFalse(mock_delete.called)
