Change in vdsm[master]: v2v: tests: new testing class: MockVirConnectTests

nsoffer at redhat.com nsoffer at redhat.com
Tue Jan 12 23:11:20 UTC 2016


Nir Soffer has posted comments on this change.

Change subject: v2v: tests: new testing class: MockVirConnectTests
......................................................................


Patch Set 2:

(4 comments)

https://gerrit.ovirt.org/#/c/51704/2/tests/v2vTests.py
File tests/v2vTests.py:

Line 450: 
Line 451:     def testListDefinedDomains(self):
Line 452:         vms = self._mock.listDefinedDomains()
Line 453:         self.assertEqual(len(vms),
Line 454:                          len([vm for vm in self._vms if not vm.isActive()]))
This duplicate the actual code, better do something like:

    self.assertEqual(len(vms), 1)

Since we created the test data with one inacive vm. The downside of this is that changing the test data will break the test, but people do not change test data usually.
Line 455: 
Line 456:     def testListDomainsID(self):
Line 457:         vms = self._mock.listDomainsID()
Line 458:         self.assertEqual(len(vms),


Line 455: 
Line 456:     def testListDomainsID(self):
Line 457:         vms = self._mock.listDomainsID()
Line 458:         self.assertEqual(len(vms),
Line 459:                          len([vm for vm in self._vms if vm.isActive()]))
Same as previous test, do not duplicate the code.
Line 460: 
Line 461:     def testlookupByName(self):
Line 462:         self._mock.lookupByName('RHEL_0')
Line 463: 


Line 458:         self.assertEqual(len(vms),
Line 459:                          len([vm for vm in self._vms if vm.isActive()]))
Line 460: 
Line 461:     def testlookupByName(self):
Line 462:         self._mock.lookupByName('RHEL_0')
Nothing tested here, assert about the return value.
Line 463: 
Line 464:     def testlookupByNameFailed(self):
Line 465:         self.assertRaises(libvirt.libvirtError, self._mock.lookupByName,
Line 466:                           'fakename')


Line 468:     def testlookupById(self):
Line 469:         self.assertRaises(libvirt.libvirtError, self._mock.lookupByID, 99)
Line 470: 
Line 471:     def testlookupByIdFailed(self):
Line 472:         self._mock.lookupByID(0)
Again, assert about the return value.
Line 473: 
Line 474: 
Line 475: class TestGetOVAInfo(TestCaseBase):
Line 476:     def test_directory(self):


-- 
To view, visit https://gerrit.ovirt.org/51704
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: If8a204b80297d95d380f1458b90eed1214997721
Gerrit-PatchSet: 2
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shahar Havivi <shavivi at redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: Shahar Havivi <shavivi at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>
Gerrit-HasComments: Yes


More information about the vdsm-patches mailing list