Update tests to mock admin.vm.CurrentState

This commit is contained in:
Pawel Marczewski 2020-01-15 17:27:49 +01:00
parent 0659e372ee
commit e5612592d4
No known key found for this signature in database
GPG Key ID: DE42EE9B14F96465
8 changed files with 134 additions and 134 deletions

View File

@ -916,11 +916,11 @@ class TC_30_QubesRemote(unittest.TestCase):
@mock.patch('os.isatty', lambda fd: fd == 2)
def test_014_run_service_no_autostart1(self):
self.set_proc_stdout( b'0\x00some-vm class=AppVM state=Running\n')
self.set_proc_stdout( b'0\x00power_state=Running')
self.app.run_service('some-vm', 'service.name', autostart=False)
self.proc_mock.assert_has_calls([
call([qubesadmin.config.QREXEC_CLIENT_VM,
'some-vm', 'admin.vm.List'],
'some-vm', 'admin.vm.CurrentState'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE),
call().communicate(None),
@ -932,11 +932,11 @@ class TC_30_QubesRemote(unittest.TestCase):
@mock.patch('os.isatty', lambda fd: fd == 2)
def test_015_run_service_no_autostart2(self):
self.set_proc_stdout( b'0\x00some-vm class=AppVM state=Halted\n')
self.set_proc_stdout( b'0\x00power_state=Halted')
with self.assertRaises(qubesadmin.exc.QubesVMNotRunningError):
self.app.run_service('some-vm', 'service.name', autostart=False)
self.proc_mock.assert_called_once_with([
qubesadmin.config.QREXEC_CLIENT_VM,
'some-vm', 'admin.vm.List'],
'some-vm', 'admin.vm.CurrentState'],
stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)

View File

@ -1,4 +1,4 @@
# -*- encoding: utf8 -*-
# -*- encoding: utf-8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
@ -71,8 +71,8 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase):
b'some-vm2 class=AppVM state=Running\n' \
b'some-vm3 class=AppVM state=Halted\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
with self.assertLogs() as logger:
self.assertEqual(
qubesadmin.tools.qvm_check.main(['--running', 'some-vm'],
@ -87,11 +87,11 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase):
b'some-vm2 class=AppVM state=Running\n' \
b'some-vm3 class=AppVM state=Halted\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('some-vm2', 'admin.vm.List', None, None)] = \
b'0\x00some-vm2 class=AppVM state=Running\n'
('some-vm2', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
with self.assertLogs() as logger:
self.assertEqual(qubesadmin.tools.qvm_check.main(
['--running', 'some-vm', 'some-vm2'], app=self.app), 0)
@ -107,14 +107,14 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase):
b'some-vm2 class=AppVM state=Running\n' \
b'some-vm3 class=AppVM state=Halted\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('some-vm2', 'admin.vm.List', None, None)] = \
b'0\x00some-vm2 class=AppVM state=Running\n'
('some-vm2', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('some-vm3', 'admin.vm.List', None, None)] = \
b'0\x00some-vm3 class=AppVM state=Halted\n'
('some-vm3', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
with self.assertLogs() as logger:
self.assertEqual(
qubesadmin.tools.qvm_check.main(['--running', '--all'],
@ -131,8 +131,8 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase):
b'some-vm2 class=AppVM state=Running\n' \
b'some-vm3 class=AppVM state=Halted\n'
self.app.expected_calls[
('some-vm3', 'admin.vm.List', None, None)] = \
b'0\x00some-vm3 class=AppVM state=Halted\n'
('some-vm3', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
with self.assertLogs() as logger:
self.assertEqual(
qubesadmin.tools.qvm_check.main(['--running', 'some-vm3'],
@ -148,8 +148,8 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase):
b'some-vm2 class=AppVM state=Paused\n' \
b'some-vm3 class=AppVM state=Halted\n'
self.app.expected_calls[
('some-vm2', 'admin.vm.List', None, None)] = \
b'0\x00some-vm2 class=AppVM state=Paused\n'
('some-vm2', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Paused'
with self.assertLogs() as logger:
self.assertEqual(
qubesadmin.tools.qvm_check.main(['--paused', 'some-vm2'],
@ -164,11 +164,11 @@ class TC_00_qvm_check(qubesadmin.tests.QubesTestCase):
b'some-vm2 class=AppVM state=Paused\n' \
b'some-vm3 class=AppVM state=Halted\n'
self.app.expected_calls[
('some-vm2', 'admin.vm.List', None, None)] = \
b'0\x00some-vm2 class=AppVM state=Paused\n'
('some-vm2', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Paused'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
with self.assertLogs() as logger:
self.assertEqual(qubesadmin.tools.qvm_check.main(
['--paused', 'some-vm2', 'some-vm'], app=self.app), 3)

View File

@ -270,14 +270,14 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
b'template1 class=TemplateVM state=Halted\n' \
b'sys-net class=AppVM state=Running\n'
self.app.expected_calls[
('vm1', 'admin.vm.List', None, None)] = \
b'0\x00vm1 class=AppVM state=Running\n'
('vm1', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('sys-net', 'admin.vm.List', None, None)] = \
b'0\x00sys-net class=AppVM state=Running\n'
('sys-net', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('template1', 'admin.vm.List', None, None)] = \
b'0\x00template1 class=TemplateVM state=Halted\n'
('template1', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
props = {
'label': b'type=label green',
'template': b'type=vm template1',
@ -322,11 +322,11 @@ class TC_90_List_with_qubesd_calls(qubesadmin.tests.QubesTestCase):
b'template1 class=TemplateVM state=Halted\n' \
b'sys-net class=AppVM state=Running\n'
self.app.expected_calls[
('vm1', 'admin.vm.List', None, None)] = \
b'0\x00vm1 class=AppVM state=Running\n'
('vm1', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('sys-net', 'admin.vm.List', None, None)] = \
b'0\x00sys-net class=AppVM state=Running\n'
('sys-net', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
props = {
'label': b'type=label green',
'template': b'type=vm template1',

View File

@ -1,4 +1,4 @@
# -*- encoding: utf8 -*-
# -*- encoding: utf-8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
@ -69,14 +69,14 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase):
b'test-vm2 class=AppVM state=Running\n' \
b'test-vm3 class=AppVM state=Halted\n'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm2', 'admin.vm.List', None, None)] = \
b'0\x00test-vm2 class=AppVM state=Running\n'
('test-vm2', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm3', 'admin.vm.List', None, None)] = \
b'0\x00test-vm3 class=AppVM state=Halted\n'
('test-vm3', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('test-vm', 'admin.vm.feature.CheckWithTemplate', 'os', None)] = \
b'2\x00QubesFeatureNotFoundError\x00\x00Feature \'os\' not set\x00'
@ -445,11 +445,11 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase):
b'test-vm2 class=AppVM state=Running\n' \
b'test-vm3 class=AppVM state=Halted\n'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm3', 'admin.vm.List', None, None)] = \
b'0\x00test-vm3 class=AppVM state=Halted\n'
('test-vm3', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('test-vm', 'admin.vm.feature.CheckWithTemplate', 'os', None)] = \
b'2\x00QubesFeatureNotFoundError\x00\x00Feature \'os\' not set\x00'
@ -474,8 +474,8 @@ class TC_00_qvm_run(qubesadmin.tests.QubesTestCase):
b'test-vm2 class=AppVM state=Running\n' \
b'test-vm3 class=AppVM state=Halted\n'
self.app.expected_calls[
('test-vm3', 'admin.vm.List', None, None)] = \
b'0\x00test-vm3 class=AppVM state=Halted\n'
('test-vm3', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
ret = qubesadmin.tools.qvm_run.main(
['--no-gui', '--no-autostart', 'test-vm3', 'command'],
app=self.app)

View File

@ -1,4 +1,4 @@
# -*- encoding: utf8 -*-
# -*- encoding: utf-8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
@ -101,9 +101,9 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase):
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
[b'0\x00some-vm class=AppVM state=Running\n'] + \
[b'0\x00some-vm class=AppVM state=Halted\n']
('some-vm', 'admin.vm.CurrentState', None, None)] = \
[b'0\x00power_state=Running'] + \
[b'0\x00power_state=Halted']
qubesadmin.tools.qvm_shutdown.main(['--wait', 'some-vm'], app=self.app)
self.assertAllCalled()
@ -141,14 +141,14 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase):
b'some-vm class=AppVM state=Running\n' \
b'other-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('other-vm', 'admin.vm.List', None, None)] = \
b'0\x00other-vm class=AppVM state=Halted\n'
('other-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('sys-net', 'admin.vm.List', None, None)] = \
b'0\x00sys-net class=AppVM state=Halted\n'
('sys-net', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
qubesadmin.tools.qvm_shutdown.main(['--wait', '--all'], app=self.app)
self.assertAllCalled()
@ -189,14 +189,14 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase):
b'some-vm class=AppVM state=Running\n' \
b'other-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('other-vm', 'admin.vm.List', None, None)] = \
b'0\x00other-vm class=AppVM state=Halted\n'
('other-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('sys-net', 'admin.vm.List', None, None)] = \
b'0\x00sys-net class=AppVM state=Halted\n'
('sys-net', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
qubesadmin.tools.qvm_shutdown.main(['--wait', '--all'], app=self.app)
self.assertAllCalled()
@ -222,20 +222,20 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase):
b'some-vm class=AppVM state=Running\n' \
b'other-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
[b'0\x00some-vm class=AppVM state=Running\n',
b'0\x00some-vm class=AppVM state=Halted\n',
b'0\x00some-vm class=AppVM state=Halted\n']
('some-vm', 'admin.vm.CurrentState', None, None)] = \
[b'0\x00power_state=Running',
b'0\x00power_state=Halted',
b'0\x00power_state=Halted']
self.app.expected_calls[
('other-vm', 'admin.vm.List', None, None)] = \
[b'0\x00other-vm class=AppVM state=Running\n',
b'0\x00other-vm class=AppVM state=Halted\n',
b'0\x00other-vm class=AppVM state=Halted\n']
('other-vm', 'admin.vm.CurrentState', None, None)] = \
[b'0\x00power_state=Running',
b'0\x00power_state=Halted',
b'0\x00power_state=Halted']
self.app.expected_calls[
('sys-net', 'admin.vm.List', None, None)] = \
[b'0\x00sys-net class=AppVM state=Running\n',
b'0\x00sys-net class=AppVM state=Halted\n',
b'0\x00sys-net class=AppVM state=Halted\n']
('sys-net', 'admin.vm.CurrentState', None, None)] = \
[b'0\x00power_state=Running',
b'0\x00power_state=Halted',
b'0\x00power_state=Halted']
with unittest.mock.patch('qubesadmin.tools.qvm_shutdown.have_events',
False):
qubesadmin.tools.qvm_shutdown.main(['--wait', '--all'], app=self.app)
@ -282,17 +282,17 @@ class TC_00_qvm_shutdown(qubesadmin.tests.QubesTestCase):
b'some-vm class=AppVM state=Running\n' \
b'other-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = [
b'0\x00some-vm class=AppVM state=Running\n',
('some-vm', 'admin.vm.CurrentState', None, None)] = [
b'0\x00power_state=Running',
]
self.app.expected_calls[
('other-vm', 'admin.vm.List', None, None)] = [
b'0\x00other-vm class=AppVM state=Running\n',
b'0\x00other-vm class=AppVM state=Running\n',
('other-vm', 'admin.vm.CurrentState', None, None)] = [
b'0\x00power_state=Running',
b'0\x00power_state=Running',
]
self.app.expected_calls[
('sys-net', 'admin.vm.List', None, None)] = \
b'0\x00sys-net class=AppVM state=Halted\n'
('sys-net', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
qubesadmin.tools.qvm_shutdown.main(
['--wait', '--all', '--timeout=1'], app=self.app)
self.assertAllCalled()

View File

@ -1,4 +1,4 @@
# -*- encoding: utf8 -*-
# -*- encoding: utf-8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
@ -33,8 +33,8 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('some-vm', 'admin.vm.Start', None, None)] = b'0\x00'
qubesadmin.tools.qvm_start.main(['some-vm'], app=self.app)
@ -63,8 +63,8 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Runnin\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Runnin'
self.assertEqual(
qubesadmin.tools.qvm_start.main(['some-vm'], app=self.app),
1)
@ -76,8 +76,8 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
b'0\x00dom0 class=AdminVM state=Running\n' \
b'some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('dom0', 'admin.vm.device.block.Available', None, None)] = \
b'0\x00sr0\n'
@ -99,8 +99,8 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
b'0\x00dom0 class=AdminVM state=Running\n' \
b'some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('dom0', 'admin.vm.device.block.Available', None, None)] = \
b'0\x00sdb1\n'
@ -122,8 +122,8 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
b'0\x00dom0 class=AdminVM state=Running\n' \
b'some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('dom0', 'admin.vm.device.block.Available', None, None)] = \
b'0\x00sdb1\n'
@ -146,8 +146,8 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
b'0\x00dom0 class=AdminVM state=Running\n' \
b'some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('dom0', 'admin.vm.device.block.Available', None, None)] = \
b'0\x00loop12\n'
@ -175,8 +175,8 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
b'other-vm class=AppVM state=Running\n' \
b'some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('other-vm', 'admin.vm.device.block.Available', None, None)] = \
b'0\x00loop7\n'
@ -208,8 +208,8 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
b'other-vm class=AppVM state=Running\n' \
b'some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('some-vm', 'admin.vm.device.block.Attach', 'other-vm+loop7',
b'devtype=cdrom persistent=True read-only=True')] = b'0\x00'
@ -232,8 +232,8 @@ class TC_00_qvm_start(qubesadmin.tests.QubesTestCase):
b'other-vm class=AppVM state=Running\n' \
b'some-vm class=AppVM state=Running\n'
self.app.expected_calls[
('some-vm', 'admin.vm.List', None, None)] = \
b'0\x00some-vm class=AppVM state=Halted\n'
('some-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('some-vm', 'admin.vm.device.block.Attach', 'other-vm+loop7',
b'devtype=cdrom persistent=True read-only=True')] = \

View File

@ -1,4 +1,4 @@
# -*- encoding: utf8 -*-
# -*- encoding: utf-8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
@ -184,8 +184,8 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase):
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm', 'admin.vm.property.Get', 'xid', None)] = \
b'0\x00default=False type=int 3000'
@ -215,8 +215,8 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase):
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm', 'admin.vm.property.Get', 'xid', None)] = \
b'0\x00default=False type=int 3000'
@ -251,8 +251,8 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase):
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm', 'admin.vm.property.Get', 'xid', None)] = \
b'0\x00default=False type=int 3000'
@ -377,8 +377,8 @@ class TC_00_qvm_start_gui(qubesadmin.tests.QubesTestCase):
b'0\x00test-vm class=AppVM state=Running\n' \
b'gui-vm class=AppVM state=Running'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm', 'admin.vm.feature.CheckWithTemplate', 'gui', None)] = \
b'0\x00True'
@ -506,8 +506,8 @@ HDMI1 connected 2560x1920+0+0 (normal left inverted right x axis y axis) 206mm x
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm', 'admin.vm.feature.CheckWithTemplate',
'no-monitor-layout', None)] = \
@ -562,8 +562,8 @@ HDMI1 connected 2560x1920+0+0 (normal left inverted right x axis y axis) 206mm x
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Halted\n'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Halted\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('test-vm', 'admin.vm.feature.CheckWithTemplate',
'no-monitor-layout', None)] = \
@ -591,8 +591,8 @@ HDMI1 connected 2560x1920+0+0 (normal left inverted right x axis y axis) 206mm x
('dom0', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm', 'admin.vm.property.Get', 'xid', None)] = \
b'0\x00default=False type=int 123'
@ -642,17 +642,17 @@ HDMI1 connected 2560x1920+0+0 (normal left inverted right x axis y axis) 206mm x
b'test-vm4 class=AppVM state=Halted\n' \
b'gui-vm class=AppVM state=Running'
self.app.expected_calls[
('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm2', 'admin.vm.List', None, None)] = \
b'0\x00test-vm2 class=AppVM state=Running\n'
('test-vm2', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm3', 'admin.vm.List', None, None)] = \
b'0\x00test-vm3 class=AppVM state=Running\n'
('test-vm3', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.app.expected_calls[
('test-vm4', 'admin.vm.List', None, None)] = \
b'0\x00test-vm4 class=AppVM state=Halted\n'
('test-vm4', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.app.expected_calls[
('test-vm', 'admin.vm.feature.CheckWithTemplate',
'gui', None)] = \

View File

@ -1,4 +1,4 @@
# -*- encoding: utf8 -*-
# -*- encoding: utf-8 -*-
#
# The Qubes OS Project, http://www.qubes-os.org
#
@ -213,32 +213,32 @@ class TC_01_SpecialCases(qubesadmin.tests.vm.VMTestCase):
self.assertAllCalled()
def test_010_power_state_running(self):
self.app.expected_calls[('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Running\n'
self.app.expected_calls[('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Running'
self.assertEqual(self.vm.get_power_state(), 'Running')
self.assertTrue(self.vm.is_running())
self.assertFalse(self.vm.is_halted())
self.assertFalse(self.vm.is_paused())
def test_011_power_state_paused(self):
self.app.expected_calls[('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Paused\n'
self.app.expected_calls[('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Paused'
self.assertEqual(self.vm.get_power_state(), 'Paused')
self.assertTrue(self.vm.is_running())
self.assertFalse(self.vm.is_halted())
self.assertTrue(self.vm.is_paused())
def test_012_power_state_halted(self):
self.app.expected_calls[('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Halted\n'
self.app.expected_calls[('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Halted'
self.assertEqual(self.vm.get_power_state(), 'Halted')
self.assertFalse(self.vm.is_running())
self.assertTrue(self.vm.is_halted())
self.assertFalse(self.vm.is_paused())
def test_012_power_state_transient(self):
self.app.expected_calls[('test-vm', 'admin.vm.List', None, None)] = \
b'0\x00test-vm class=AppVM state=Transient\n'
self.app.expected_calls[('test-vm', 'admin.vm.CurrentState', None, None)] = \
b'0\x00power_state=Transient'
self.assertEqual(self.vm.get_power_state(), 'Transient')
self.assertTrue(self.vm.is_running())
self.assertFalse(self.vm.is_halted())