def test_download_path(self): conn = MockVirConnect(vms=self._vms) def connect(uri, username, password): return conn with MonkeyPatchScope([ (libvirtconnection, 'open_connection', connect), ]), make_env() as env: args = [ 'kvm2ovirt', '--uri', 'qemu+tcp://domain', '--username', 'user', '--password-file', env.password, '--source', '/fake/source', '--dest', env.destination, '--storage-type', 'path', '--vm-name', self._vms[0].name() ] kvm2ovirt.main(args) with open(env.destination) as f: actual = f.read() self.assertEqual(actual, FakeVolume().data())
def test_common_download_file_username(self, username, passwd): conn = MockVirConnect(vms=self._vms) def connect(uri, username, password): return conn with MonkeyPatchScope([ (libvirtconnection, 'open_connection', connect), ]), make_env() as env: vmInfo = {'vmName': self._vms[0].name()} kvm = v2v.KVMCommand('qemu+tcp://domain', username, passwd, vmInfo, uuid.uuid4(), None) if passwd: kvm._passwd_file = env.password kvm._source_images = lambda: (['/fake/source'], ['file']) kvm._dest_images = lambda: [env.destination] kvm2ovirt.main(kvm._command()) with open(env.destination) as f: actual = f.read() self.assertEqual(actual, FakeVolume().data())