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:
Marek Marczykowski-Górecki 2019-09-10 03:34:11 +02:00
parent 05e48748d2
commit c5aaf3abd9
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -32,8 +32,14 @@ class TestVMM(object):
@property
def libvirt_conn(self):
import libvirt
raise libvirt.libvirtError('phony error')
if self.offline_mode:
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):
# pylint: disable=too-few-public-methods