tests: make libvirt mockup more robust
If not in offline_mode, return actual mock for libvirt connection object instead of always raising exception.
This commit is contained in:
parent
05e48748d2
commit
c5aaf3abd9
@ -32,8 +32,14 @@ class TestVMM(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def libvirt_conn(self):
|
def libvirt_conn(self):
|
||||||
import libvirt
|
if self.offline_mode:
|
||||||
raise libvirt.libvirtError('phony error')
|
import libvirt
|
||||||
|
raise libvirt.libvirtError('phony error')
|
||||||
|
else:
|
||||||
|
libvirt_mock = unittest.mock.Mock()
|
||||||
|
vm_mock = libvirt_mock.lookupByUUID.return_value
|
||||||
|
vm_mock.isActive.return_value = False
|
||||||
|
return libvirt_mock
|
||||||
|
|
||||||
class TestHost(object):
|
class TestHost(object):
|
||||||
# pylint: disable=too-few-public-methods
|
# pylint: disable=too-few-public-methods
|
||||||
|
Loading…
Reference in New Issue
Block a user