tests: avoid 'xrandr' call

Don't rely on tool existence, nor on a specific monitor layout in test
env.
This commit is contained in:
Marek Marczykowski-Górecki 2020-12-02 03:56:07 +01:00
parent 2266e432bf
commit 25a6a305c8
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -231,7 +231,11 @@ global: {
'no-monitor-layout', None)] = \ 'no-monitor-layout', None)] = \
b'2\x00QubesFeatureNotFoundError\x00\x00Feature not set\x00' b'2\x00QubesFeatureNotFoundError\x00\x00Feature not set\x00'
with unittest.mock.patch.object(self.launcher, 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( loop.run_until_complete(self.launcher.start_gui_for_vm(
self.app.domains['test-vm'])) self.app.domains['test-vm']))
# common arguments dropped for simplicity # common arguments dropped for simplicity
@ -268,7 +272,11 @@ global: {
'no-monitor-layout', None)] = \ 'no-monitor-layout', None)] = \
b'2\x00QubesFeatureNotFoundError\x00\x00Feature not set\x00' b'2\x00QubesFeatureNotFoundError\x00\x00Feature not set\x00'
with unittest.mock.patch.object(self.launcher, 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( loop.run_until_complete(self.launcher.start_gui_for_vm(
self.app.domains['test-vm'])) self.app.domains['test-vm']))
# common arguments dropped for simplicity # common arguments dropped for simplicity
@ -309,6 +317,10 @@ global: {
self.addCleanup(pidfile.close) self.addCleanup(pidfile.close)
patch_proc = asynctest.patch('asyncio.create_subprocess_exec') 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, patch_args = unittest.mock.patch.object(self.launcher,
'common_guid_args', 'common_guid_args',
lambda vm: []) lambda vm: [])
@ -319,6 +331,7 @@ global: {
mock_proc = patch_proc.start() mock_proc = patch_proc.start()
patch_args.start() patch_args.start()
patch_pidfile.start() patch_pidfile.start()
patch_monitor_layout.start()
loop.run_until_complete(self.launcher.start_gui_for_vm( loop.run_until_complete(self.launcher.start_gui_for_vm(
self.app.domains['test-vm'])) self.app.domains['test-vm']))
# common arguments dropped for simplicity # common arguments dropped for simplicity