Skip to content

Commit

Permalink
Fixed tests for keyboard layout
Browse files Browse the repository at this point in the history
  • Loading branch information
marmarta committed Oct 9, 2020
1 parent b5daca5 commit b813998
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions qubesmanager/tests/test_qube_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ def test_203_vm_open_apps(self, mock_window):
selected_vm, qapp=self.qtapp, init_page="applications",
qubesapp=self.qapp)

def test_204_vm_keyboard(self):
@unittest.mock.patch('PyQt5.QtWidgets.QMessageBox.warning')
def test_204_vm_keyboard(self, mock_message):
selected_vm = self._select_non_admin_vm(running=True)
self.assertIsNotNone(selected_vm, "No valid non-admin VM found")
widget = self.dialog.toolbar.widgetForAction(
Expand All @@ -318,8 +319,11 @@ def test_204_vm_keyboard(self):
QtTest.QTest.mouseClick(widget,
QtCore.Qt.LeftButton)
mock_run.assert_called_once_with("qubes-change-keyboard-layout")
self.assertEqual(mock_message.call_count, 0,
"VM does not support new layout change")

def test_205_vm_keyboard_not_running(self):
@unittest.mock.patch('PyQt5.QtWidgets.QMessageBox.warning')
def test_205_vm_keyboard_not_running(self, mock_message):
selected_vm = self._select_non_admin_vm(running=False)
self.assertIsNotNone(selected_vm, "No valid non-admin VM found")
widget = self.dialog.toolbar.widgetForAction(
Expand All @@ -329,10 +333,12 @@ def test_205_vm_keyboard_not_running(self):
QtCore.Qt.LeftButton)
self.assertEqual(mock_run.call_count, 0,
"Keyboard change called on a halted VM")
self.assertEqual(mock_message.call_count, 0,
"Keyboard change called on a halted VM with"
" obsolete keyboard-layout handling")

def test_206_dom0_keyboard(self):
self._select_admin_vm()

self.assertFalse(self.dialog.action_set_keyboard_layout.isEnabled())

@unittest.mock.patch("PyQt5.QtWidgets.QMessageBox.question",
Expand Down

0 comments on commit b813998

Please sign in to comment.