tests: fix AdminVM test

Since it is no longer child of QubesVM, constructor do not take 'qid'
and 'name' arguments.
Also:
- remove other dropped properties tests (netvm, storage related)
- make the test working in non-dom0
This commit is contained in:
Marek Marczykowski-Górecki 2017-07-25 05:48:43 +02:00
parent a9934316c1
commit 5d9bc00885
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -20,6 +20,7 @@
# #
import unittest import unittest
import unittest.mock
import qubes import qubes
import qubes.exc import qubes.exc
@ -28,14 +29,13 @@ import qubes.vm.adminvm
import qubes.tests import qubes.tests
@qubes.tests.skipUnlessDom0
class TC_00_AdminVM(qubes.tests.QubesTestCase): class TC_00_AdminVM(qubes.tests.QubesTestCase):
def setUp(self): def setUp(self):
super().setUp() super().setUp()
try: try:
self.app = qubes.tests.vm.TestApp() self.app = qubes.tests.vm.TestApp()
self.vm = qubes.vm.adminvm.AdminVM(self.app, self.vm = qubes.vm.adminvm.AdminVM(self.app,
xml=None, qid=0, name='dom0') xml=None)
except: # pylint: disable=bare-except except: # pylint: disable=bare-except
if self.id().endswith('.test_000_init'): if self.id().endswith('.test_000_init'):
raise raise
@ -48,10 +48,11 @@ class TC_00_AdminVM(qubes.tests.QubesTestCase):
self.assertEqual(self.vm.xid, 0) self.assertEqual(self.vm.xid, 0)
def test_101_libvirt_domain(self): def test_101_libvirt_domain(self):
self.assertIs(self.vm.libvirt_domain, None) with unittest.mock.patch.object(self.app, 'vmm') as mock_vmm:
self.assertIsNotNone(self.vm.libvirt_domain)
def test_200_libvirt_netvm(self): self.assertEqual(mock_vmm.mock_calls, [
self.assertIs(self.vm.netvm, None) ('libvirt_conn.lookupByID', (0,), {}),
])
def test_300_is_running(self): def test_300_is_running(self):
self.assertTrue(self.vm.is_running()) self.assertTrue(self.vm.is_running())
@ -66,21 +67,6 @@ class TC_00_AdminVM(qubes.tests.QubesTestCase):
def test_303_get_mem_static_max(self): def test_303_get_mem_static_max(self):
self.assertGreater(self.vm.get_mem_static_max(), 0) self.assertGreater(self.vm.get_mem_static_max(), 0)
def test_304_get_disk_utilization(self):
self.assertEqual(self.vm.storage.get_disk_utilization(), 0)
def test_305_has_no_private_volume(self):
with self.assertRaises(KeyError):
self.vm.volumes['private']
def test_306_has_no_root_volume(self):
with self.assertRaises(KeyError):
self.vm.volumes['root']
def test_307_has_no_volatile_volume(self):
with self.assertRaises(KeyError):
self.vm.volumes['volatile']
def test_310_start(self): def test_310_start(self):
with self.assertRaises(qubes.exc.QubesException): with self.assertRaises(qubes.exc.QubesException):
self.vm.start() self.vm.start()