'Test volume can be created from a snapshot.'

@mock.patch('cinder.volume.drivers.lvm.LVMVolumeDriver.create_volume_from_snapshot')
def test_create_volume_from_snapshot(self, mock_create_from_snap):

    volume_src = tests_utils.create_volume(self.context, **self.volume_params)
    self.volume.create_volume(self.context, volume_src)
    snapshot_id = create_snapshot(volume_src['id'], size=volume_src['size'])['id']
    snapshot_obj = objects.Snapshot.get_by_id(self.context, snapshot_id)
    self.volume.create_snapshot(self.context, snapshot_obj)
    volume_dst = tests_utils.create_volume(self.context, snapshot_id=snapshot_id, **self.volume_params)
    self.volume.create_volume(self.context, volume_dst)
    self.assertEqual(volume_dst['id'], db.volume_get(context.get_admin_context(), volume_dst['id']).id)
    self.assertEqual(snapshot_id, db.volume_get(context.get_admin_context(), volume_dst['id']).snapshot_id)
    self.volume.delete_volume(self.context, volume_dst)
    self.volume.delete_snapshot(self.context, snapshot_obj)
    self.volume.delete_volume(self.context, volume_src)
