From 25a6a305c8602c0f02bca879472cec47c94524d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 2 Dec 2020 03:56:07 +0100 Subject: [PATCH] tests: avoid 'xrandr' call Don't rely on tool existence, nor on a specific monitor layout in test env. --- qubesadmin/tests/tools/qvm_start_daemon.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/qubesadmin/tests/tools/qvm_start_daemon.py b/qubesadmin/tests/tools/qvm_start_daemon.py index 43079c83..743c3d8e 100644 --- a/qubesadmin/tests/tools/qvm_start_daemon.py +++ b/qubesadmin/tests/tools/qvm_start_daemon.py @@ -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 @@ -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 @@ -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: []) @@ -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