Nir Soffer has posted comments on this change.
Change subject: tests: v2v: add test for commit fb4c72a ......................................................................
Patch Set 2:
(2 comments)
Suggested way to simplify the mock.
https://gerrit.ovirt.org/#/c/47364/2/tests/v2vTests.py File tests/v2vTests.py:
Line 88: Line 89: def storageVolLookupByPath(self, name): Line 90: if self._storage_lookup_fail: Line 91: e = fake.Error(libvirt.VIR_ERR_INTERNAL_ERROR) Line 92: raise e
raise fakeError(...)?
Introducing flags such as _storage_lookup_fail is more complicated then needed. We can override this method in the specific test - see bellow. Line 93: return LibvirtMock.Volume() Line 94: Line 95: class Volume(object): Line 96: def info(self):
Line 212: if not v2v.supported(): Line 213: raise SkipTest('v2v is not supported current os version') Line 214: Line 215: def _connect(uri, username, passwd): Line 216: return LibvirtMock(storage_lookup_fail=True) We can do it in a simpler way:
connection = LibvirtMock() def internal_error(name): raise fake.Error(...) connection.storageVolLookupByPath = internal_error Line 217: Line 218: with MonkeyPatchScope([(libvirtconnection, 'open_connection', Line 219: _connect)]): Line 220: vms = v2v.get_external_vms('esx://mydomain', 'user',