From 73df1b8ea7e45d4b0a0e2bdf6936b3020656245e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Thu, 13 Apr 2017 14:39:45 +0200 Subject: [PATCH] tests: VM lifecycle methods tests QubesOS/qubes-issues#2622 --- qubes/tests/mgmt.py | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/qubes/tests/mgmt.py b/qubes/tests/mgmt.py index d55f907a..bb7453d1 100644 --- a/qubes/tests/mgmt.py +++ b/qubes/tests/mgmt.py @@ -786,6 +786,56 @@ class TC_00_VMs(MgmtTestCase): self.assertEqual(self.app.labels.mock_calls, []) self.assertFalse(self.app.save.called) + def test_220_start(self): + func_mock = unittest.mock.Mock() + @asyncio.coroutine + def coroutine_mock(*args, **kwargs): + return func_mock(*args, **kwargs) + self.vm.start = coroutine_mock + value = self.call_mgmt_func(b'mgmt.vm.Start', b'test-vm1') + self.assertIsNone(value) + func_mock.assert_called_once_with() + + def test_230_shutdown(self): + func_mock = unittest.mock.Mock() + @asyncio.coroutine + def coroutine_mock(*args, **kwargs): + return func_mock(*args, **kwargs) + self.vm.shutdown = coroutine_mock + value = self.call_mgmt_func(b'mgmt.vm.Shutdown', b'test-vm1') + self.assertIsNone(value) + func_mock.assert_called_once_with() + + def test_240_pause(self): + func_mock = unittest.mock.Mock() + @asyncio.coroutine + def coroutine_mock(*args, **kwargs): + return func_mock(*args, **kwargs) + self.vm.pause = coroutine_mock + value = self.call_mgmt_func(b'mgmt.vm.Pause', b'test-vm1') + self.assertIsNone(value) + func_mock.assert_called_once_with() + + def test_250_unpause(self): + func_mock = unittest.mock.Mock() + @asyncio.coroutine + def coroutine_mock(*args, **kwargs): + return func_mock(*args, **kwargs) + self.vm.unpause = coroutine_mock + value = self.call_mgmt_func(b'mgmt.vm.Unpause', b'test-vm1') + self.assertIsNone(value) + func_mock.assert_called_once_with() + + def test_260_kill(self): + func_mock = unittest.mock.Mock() + @asyncio.coroutine + def coroutine_mock(*args, **kwargs): + return func_mock(*args, **kwargs) + self.vm.kill = coroutine_mock + value = self.call_mgmt_func(b'mgmt.vm.Kill', b'test-vm1') + self.assertIsNone(value) + func_mock.assert_called_once_with() + def test_990_vm_unexpected_payload(self): methods_with_no_payload = [ b'mgmt.vm.List',