Skip to content

Commit

Permalink
tests: avoid 'xrandr' call
Browse files Browse the repository at this point in the history
Don't rely on tool existence, nor on a specific monitor layout in test
env.
  • Loading branch information
marmarek committed Dec 2, 2020
1 parent 2266e43 commit 25a6a30
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions qubesadmin/tests/tools/qvm_start_daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,11 @@ def test_020_start_gui_for_vm(self, proc_mock):
'no-monitor-layout', None)] = \
b'2\x00QubesFeatureNotFoundError\x00\x00Feature not set\x00'
with unittest.mock.patch.object(self.launcher,
'common_guid_args', lambda vm: []):
'common_guid_args', lambda vm: []), \
unittest.mock.patch.object(qubesadmin.tools.qvm_start_daemon,
'get_monitor_layout',
unittest.mock.Mock(
return_value=['1600 900 0 0\n'])):
loop.run_until_complete(self.launcher.start_gui_for_vm(
self.app.domains['test-vm']))
# common arguments dropped for simplicity
Expand Down Expand Up @@ -268,7 +272,11 @@ def test_021_start_gui_for_vm_hvm(self, proc_mock):
'no-monitor-layout', None)] = \
b'2\x00QubesFeatureNotFoundError\x00\x00Feature not set\x00'
with unittest.mock.patch.object(self.launcher,
'common_guid_args', lambda vm: []):
'common_guid_args', lambda vm: []), \
unittest.mock.patch.object(qubesadmin.tools.qvm_start_daemon,
'get_monitor_layout',
unittest.mock.Mock(
return_value=['1600 900 0 0\n'])):
loop.run_until_complete(self.launcher.start_gui_for_vm(
self.app.domains['test-vm']))
# common arguments dropped for simplicity
Expand Down Expand Up @@ -309,6 +317,10 @@ def test_022_start_gui_for_vm_hvm_stubdom(self):
self.addCleanup(pidfile.close)

patch_proc = asynctest.patch('asyncio.create_subprocess_exec')
patch_monitor_layout = unittest.mock.patch.object(
qubesadmin.tools.qvm_start_daemon,
'get_monitor_layout',
unittest.mock.Mock(return_value=['1600 900 0 0\n']))
patch_args = unittest.mock.patch.object(self.launcher,
'common_guid_args',
lambda vm: [])
Expand All @@ -319,6 +331,7 @@ def test_022_start_gui_for_vm_hvm_stubdom(self):
mock_proc = patch_proc.start()
patch_args.start()
patch_pidfile.start()
patch_monitor_layout.start()
loop.run_until_complete(self.launcher.start_gui_for_vm(
self.app.domains['test-vm']))
# common arguments dropped for simplicity
Expand Down

0 comments on commit 25a6a30

Please sign in to comment.