'Clone non-raw image then verify volume is in available state.'

@mock.patch('cinder.image.image_utils.check_available_space')
@mock.patch.object(cinder.image.glance, 'get_default_image_service')
@mock.patch('cinder.image.image_utils.TemporaryImages.fetch')
@mock.patch('cinder.image.image_utils.qemu_img_info')
def test_create_vol_from_non_raw_image_status_available(self, mock_qemu_info, mock_fetch, mock_gdis, mock_check_space):

    def _mock_clone_image(context, volume, image_location, image_meta, image_service):
        return ({'provider_location': None}, False)
    image_info = imageutils.QemuImgInfo()
    image_info.virtual_size = '1073741824'
    mock_qemu_info.return_value = image_info
    mock_fetch.return_value = mock.MagicMock(spec=utils.get_file_spec())
    with mock.patch.object(self.volume.driver, 'clone_image') as mock_clone_image:
        mock_clone_image.side_effect = _mock_clone_image
        with mock.patch.object(self.volume.driver, 'create_volume') as mock_create:
            with mock.patch.object(create_volume.CreateVolumeFromSpecTask, '_copy_image_to_volume') as mock_copy:
                self._create_volume_from_image('available', raw=False)
                self.assertTrue(mock_copy.called)
            self.assertTrue(mock_clone_image.called)
            self.assertTrue(mock_create.called)
            self.assertTrue(mock_gdis.called)
