'create volume from snapshot.'

@mock.patch.object(eventlet, 'sleep')
@mock.patch.object(helper.DS8KCommonHelper, 'get_flashcopy')
def test_create_volume_from_snapshot(self, mock_get_flashcopy, mock_sleep):

    self.driver = FakeDS8KProxy(self.storage_info, self.logger, self.exception, self)
    self.driver.setup(self.ctxt)
    vol_type = volume_types.create(self.ctxt, 'VOL_TYPE', {})
    volume = self._create_volume(volume_type_id=vol_type.id)
    location = six.text_type({'vol_hex_id': '0002'})
    snap = self._create_snapshot(volume_id=volume.id, volume_type_id=vol_type.id, provider_location=location)
    vol = self._create_volume(volume_type_id=vol_type.id)
    mock_get_flashcopy.side_effect = [[TEST_FLASHCOPY], {}]
    volume_update = self.driver.create_volume_from_snapshot(vol, snap)
    self.assertEqual(TEST_VOLUME_ID, ast.literal_eval(volume_update['provider_location'])['vol_hex_id'])
