Change in vdsm[master]: v2v: tests: refactor v2vTests
shavivi at redhat.com
shavivi at redhat.com
Tue Jan 12 10:18:39 UTC 2016
Shahar Havivi has uploaded a new change for review.
Change subject: v2v: tests: refactor v2vTests
......................................................................
v2v: tests: refactor v2vTests
1. move _VM_SPECS to the module scope and rename to VM_SPECS
2. set _VMS in setup and not as class variable to protect it from
altering but each test
Change-Id: I97d40bf1d14b81c436fbd152e4f0dfd62db6b628
Signed-off-by: Shahar Havivi <shaharh at redhat.com>
---
M tests/v2vTests.py
1 file changed, 14 insertions(+), 14 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/03/51703/1
diff --git a/tests/v2vTests.py b/tests/v2vTests.py
index 336614e..ab3db75 100644
--- a/tests/v2vTests.py
+++ b/tests/v2vTests.py
@@ -43,6 +43,12 @@
VmSpec = namedtuple('VmSpec', ['name', 'uuid'])
+VM_SPECS = (
+ VmSpec("RHEL_0", str(uuid.uuid4())),
+ VmSpec("RHEL_1", str(uuid.uuid4())),
+ VmSpec("RHEL_2", str(uuid.uuid4()))
+)
+
FAKE_VIRT_V2V = CommandPath('fake-virt-v2v',
os.path.abspath('fake-virt-v2v'))
@@ -192,14 +198,6 @@
class v2vTests(TestCaseBase):
- _VM_SPECS = (
- VmSpec("RHEL_0", str(uuid.uuid4())),
- VmSpec("RHEL_1", str(uuid.uuid4())),
- VmSpec("RHEL_2", str(uuid.uuid4()))
- )
-
- _VMS = [MockVirDomain(*spec) for spec in _VM_SPECS]
-
def setUp(self):
'''
We are testing the output of fake-virt-v2v with vminfo input
@@ -225,6 +223,8 @@
{'imageID': self.image_id_b,
'volumeID': self.volume_id_b}]}
+ self._vms = [MockVirDomain(*spec) for spec in VM_SPECS]
+
def tearDown(self):
v2v._jobs.clear()
@@ -233,21 +233,21 @@
raise SkipTest('v2v is not supported current os version')
def _connect(uri, username, passwd):
- return MockVirConnect(vms=self._VMS)
+ return MockVirConnect(vms=self._vms)
with MonkeyPatchScope([(libvirtconnection, 'open_connection',
_connect)]):
vms = v2v.get_external_vms('esx://mydomain', 'user',
ProtectedPassword('password'))['vmList']
- self.assertEqual(len(vms), len(self._VM_SPECS))
+ self.assertEqual(len(vms), len(VM_SPECS))
- for vm, spec in zip(vms, self._VM_SPECS):
+ for vm, spec in zip(vms, VM_SPECS):
self._assertVmMatchesSpec(vm, spec)
self._assertVmDisksMatchSpec(vm, spec)
def testGetExternalVMsWithXMLDescFailure(self):
- specs = list(self._VM_SPECS)
+ specs = list(VM_SPECS)
def internal_error(flags=0):
raise fake.Error(libvirt.VIR_ERR_INTERNAL_ERROR)
@@ -305,7 +305,7 @@
raise fake.Error(libvirt.VIR_ERR_INTERNAL_ERROR)
# we need a sequence of just one vm
- mock = MockVirConnect(vms=self._VMS[:1])
+ mock = MockVirConnect(vms=self._vms[:1])
mock.storageVolLookupByPath = internal_error
def _connect(uri, username, passwd):
@@ -316,7 +316,7 @@
vms = v2v.get_external_vms('esx://mydomain', 'user',
ProtectedPassword('password'))['vmList']
self.assertEquals(len(vms), 1)
- self._assertVmMatchesSpec(vms[0], self._VM_SPECS[0])
+ self._assertVmMatchesSpec(vms[0], VM_SPECS[0])
for disk in vms[0]['disks']:
self.assertNotIn('capacity', disk)
self.assertNotIn('allocation', disk)
--
To view, visit https://gerrit.ovirt.org/51703
To unsubscribe, visit https://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I97d40bf1d14b81c436fbd152e4f0dfd62db6b628
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <shavivi at redhat.com>
More information about the vdsm-patches
mailing list