Fix for icon size for Qube Manager tests
Also contains a tiny fix to Qube Manager itself (bug found with tests!) And further fixes to qube manager tests for particularly slow days.
This commit is contained in:
parent
3e512bb7c3
commit
22823f6106
@ -248,6 +248,7 @@ class VmInfo():
|
|||||||
|
|
||||||
if not event or event.endswith(':label'):
|
if not event or event.endswith(':label'):
|
||||||
self.label = getattr(self.vm, 'label', None)
|
self.label = getattr(self.vm, 'label', None)
|
||||||
|
self.icon = getattr(self.vm, 'icon', 'appvm-black')
|
||||||
|
|
||||||
if not event or event.endswith(':template'):
|
if not event or event.endswith(':template'):
|
||||||
try:
|
try:
|
||||||
|
@ -38,7 +38,8 @@ import qubesmanager.qube_manager as qube_manager
|
|||||||
from qubesmanager.tests import init_qtapp
|
from qubesmanager.tests import init_qtapp
|
||||||
|
|
||||||
|
|
||||||
icon_size = QSize(24, 24)
|
icon_size = qube_manager.icon_size
|
||||||
|
|
||||||
|
|
||||||
class QubeManagerTest(unittest.TestCase):
|
class QubeManagerTest(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -208,10 +209,9 @@ class QubeManagerTest(unittest.TestCase):
|
|||||||
def test_011_is_label_correct(self):
|
def test_011_is_label_correct(self):
|
||||||
for row in range(self.dialog.table.model().rowCount()):
|
for row in range(self.dialog.table.model().rowCount()):
|
||||||
vm = self._get_table_vm(row)
|
vm = self._get_table_vm(row)
|
||||||
icon = QIcon.fromTheme(vm.label.icon)
|
icon = QIcon.fromTheme(getattr(vm, 'icon', 'appvm-black'))
|
||||||
icon = icon.pixmap(icon_size)
|
icon = icon.pixmap(icon_size)
|
||||||
|
|
||||||
|
|
||||||
label_pixmap = self._get_table_item(row, "Label", Qt.DecorationRole)
|
label_pixmap = self._get_table_item(row, "Label", Qt.DecorationRole)
|
||||||
|
|
||||||
self.assertEqual(label_pixmap.toImage(), icon.toImage())
|
self.assertEqual(label_pixmap.toImage(), icon.toImage())
|
||||||
@ -825,7 +825,8 @@ class QubeManagerTest(unittest.TestCase):
|
|||||||
# this requires very long timeout, because it takes time for the
|
# this requires very long timeout, because it takes time for the
|
||||||
# dispvm to vanish
|
# dispvm to vanish
|
||||||
self._run_command_and_process_events(
|
self._run_command_and_process_events(
|
||||||
["qvm-run", "--dispvm", dispvm_template, "true"], timeout=60)
|
["qvm-run", "--dispvm", dispvm_template, "true"], timeout=60,
|
||||||
|
additional_timeout=30)
|
||||||
|
|
||||||
final_vms = self._create_set_of_current_vms()
|
final_vms = self._create_set_of_current_vms()
|
||||||
|
|
||||||
@ -853,7 +854,8 @@ class QubeManagerTest(unittest.TestCase):
|
|||||||
["qvm-prefs", dispvm_template, "memory", "600000"])
|
["qvm-prefs", dispvm_template, "memory", "600000"])
|
||||||
|
|
||||||
self._run_command_and_process_events(
|
self._run_command_and_process_events(
|
||||||
["qvm-run", "--dispvm", dispvm_template, "true"], timeout=30)
|
["qvm-run", "--dispvm", dispvm_template, "true"], timeout=30,
|
||||||
|
additional_timeout=15)
|
||||||
|
|
||||||
final_vms = self._create_set_of_current_vms()
|
final_vms = self._create_set_of_current_vms()
|
||||||
|
|
||||||
@ -1170,13 +1172,15 @@ class QubeManagerTest(unittest.TestCase):
|
|||||||
result += 1
|
result += 1
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _run_command_and_process_events(self, command, timeout=5):
|
def _run_command_and_process_events(self, command, timeout=5,
|
||||||
|
additional_timeout=None):
|
||||||
"""
|
"""
|
||||||
helper function to run a given command and process eventsDispatcher
|
helper function to run a given command and process eventsDispatcher
|
||||||
events
|
events
|
||||||
:param command: list of strings, containing the command and all its
|
:param command: list of strings, containing the command and all its
|
||||||
parameters
|
parameters
|
||||||
:param timeout: default 5 seconds
|
:param timeout: default 5 seconds
|
||||||
|
:param additional_timeout: default none
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
asyncio.set_event_loop(self.loop)
|
asyncio.set_event_loop(self.loop)
|
||||||
@ -1187,6 +1191,13 @@ class QubeManagerTest(unittest.TestCase):
|
|||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
|
|
||||||
|
if additional_timeout:
|
||||||
|
(done, pending) = self.loop.run_until_complete(
|
||||||
|
asyncio.wait({future1, future2}, timeout=timeout,
|
||||||
|
return_when=asyncio.FIRST_COMPLETED))
|
||||||
|
(done, pending) = self.loop.run_until_complete(
|
||||||
|
asyncio.wait(pending, timeout=additional_timeout))
|
||||||
|
else:
|
||||||
(done, pending) = self.loop.run_until_complete(
|
(done, pending) = self.loop.run_until_complete(
|
||||||
asyncio.wait({future1, future2}, timeout=timeout))
|
asyncio.wait({future1, future2}, timeout=timeout))
|
||||||
|
|
||||||
@ -1275,6 +1286,7 @@ class QubeManagerTest(unittest.TestCase):
|
|||||||
column = self.dialog.qubes_model.columns_indices.index(column_name)
|
column = self.dialog.qubes_model.columns_indices.index(column_name)
|
||||||
return model.index(row, column).data(role)
|
return model.index(row, column).data(role)
|
||||||
|
|
||||||
|
|
||||||
class QubeManagerThreadTest(unittest.TestCase):
|
class QubeManagerThreadTest(unittest.TestCase):
|
||||||
def test_01_startvm_thread(self):
|
def test_01_startvm_thread(self):
|
||||||
vm = unittest.mock.Mock(spec=['start'])
|
vm = unittest.mock.Mock(spec=['start'])
|
||||||
|
Loading…
Reference in New Issue
Block a user