'Tests the confirm_migration method on vmops.'

@mock.patch.object(ds_util, 'disk_delete')
@mock.patch.object(ds_util, 'file_exists', return_value=True)
@mock.patch.object(vmops.VMwareVMOps, '_get_ds_browser', return_value='fake-browser')
@mock.patch.object(vm_util, 'get_vm_ref', return_value='fake-ref')
def test_confirm_migration(self, fake_get_vm_ref, fake_get_browser, fake_original_exists, fake_disk_delete):

    datastore = ds_obj.Datastore(ref='fake-ref', name='fake')
    device = vmwareapi_fake.DataObject()
    backing = vmwareapi_fake.DataObject()
    backing.datastore = datastore.ref
    device.backing = backing
    vmdk = vm_util.VmdkInfo('[fake]    uuid/root.vmdk', 'fake-adapter', 'fake-disk', 'fake-capacity', device)
    dc_info = ds_util.DcInfo(ref='fake_ref', name='fake', vmFolder='fake_folder')
    with test.nested(mock.patch.object(self._vmops, 'get_datacenter_ref_and_name', return_value=dc_info), mock.patch.object(vm_util, 'get_vmdk_info', return_value=vmdk)) as (fake_get_dc_ref_and_name, fake_get_vmdk_info):
        self._vmops.confirm_migration(None, self._instance, None)
        fake_get_vm_ref.assert_called_once_with(self._session, self._instance)
        fake_get_vmdk_info.assert_called_once_with(self._session, 'fake-ref', uuid=self._instance.uuid)
        fake_get_browser.assert_called_once_with('fake-ref')
        fake_original_exists.assert_called_once_with(self._session, 'fake-browser', ds_obj.DatastorePath(datastore.name, 'uuid'), 'original.vmdk')
        fake_disk_delete.assert_called_once_with(self._session, dc_info.ref, '[fake]    uuid/original.vmdk')
