mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
test(launch_window): tests for default and plugin auto updates
This commit is contained in:
@ -330,7 +330,7 @@ class LaunchWindow(BECMainWindow):
|
|||||||
auto_update = self.tile_auto_update.selector.currentText()
|
auto_update = self.tile_auto_update.selector.currentText()
|
||||||
if auto_update == "Default":
|
if auto_update == "Default":
|
||||||
auto_update = None
|
auto_update = None
|
||||||
self.launch("auto_update", auto_update=auto_update)
|
return self.launch("auto_update", auto_update=auto_update)
|
||||||
|
|
||||||
@SafeSlot(popup_error=True)
|
@SafeSlot(popup_error=True)
|
||||||
def _open_custom_ui_file(self):
|
def _open_custom_ui_file(self):
|
||||||
|
@ -7,6 +7,7 @@ from bec_lib.endpoints import MessageEndpoints
|
|||||||
|
|
||||||
import bec_widgets
|
import bec_widgets
|
||||||
from bec_widgets.applications.launch_window import LaunchWindow
|
from bec_widgets.applications.launch_window import LaunchWindow
|
||||||
|
from bec_widgets.widgets.containers.auto_update.auto_updates import AutoUpdates
|
||||||
from bec_widgets.widgets.containers.main_window.main_window import BECMainWindow, UILaunchWindow
|
from bec_widgets.widgets.containers.main_window.main_window import BECMainWindow, UILaunchWindow
|
||||||
|
|
||||||
from .client_mocks import mocked_client
|
from .client_mocks import mocked_client
|
||||||
@ -58,3 +59,37 @@ def test_launch_window_launch_ui_file_raises_for_qmainwindow(bec_launch_window):
|
|||||||
bec_launch_window.launch("custom_ui_file", ui_file=ui_file_path)
|
bec_launch_window.launch("custom_ui_file", ui_file=ui_file_path)
|
||||||
|
|
||||||
assert "Loading a QMainWindow from a UI file is currently not supported." in str(excinfo.value)
|
assert "Loading a QMainWindow from a UI file is currently not supported." in str(excinfo.value)
|
||||||
|
|
||||||
|
|
||||||
|
def test_launch_window_launch_default_auto_update(bec_launch_window):
|
||||||
|
# Mock the auto update selection
|
||||||
|
bec_launch_window.tile_auto_update.selector.setCurrentText("Default")
|
||||||
|
|
||||||
|
# Call the method to launch the auto update
|
||||||
|
res = bec_launch_window._open_auto_update()
|
||||||
|
|
||||||
|
assert isinstance(res, AutoUpdates)
|
||||||
|
assert res.windowTitle() == "BEC - AutoUpdates"
|
||||||
|
|
||||||
|
# We need to manually close the launched window as it is not registered with qtbot.
|
||||||
|
# In real usage, the GUIServer would handle this in the sigint handler in case of a ctrl-c initiated shutdown.
|
||||||
|
res.close()
|
||||||
|
res.deleteLater()
|
||||||
|
|
||||||
|
|
||||||
|
def test_launch_window_launch_plugin_auto_update(bec_launch_window):
|
||||||
|
class PluginAutoUpdate(AutoUpdates): ...
|
||||||
|
|
||||||
|
bec_launch_window.available_auto_updates = {"PluginAutoUpdate": PluginAutoUpdate}
|
||||||
|
bec_launch_window.tile_auto_update.selector.clear()
|
||||||
|
bec_launch_window.tile_auto_update.selector.addItems(
|
||||||
|
list(bec_launch_window.available_auto_updates.keys()) + ["Default"]
|
||||||
|
)
|
||||||
|
bec_launch_window.tile_auto_update.selector.setCurrentText("PluginAutoUpdate")
|
||||||
|
res = bec_launch_window._open_auto_update()
|
||||||
|
assert isinstance(res, PluginAutoUpdate)
|
||||||
|
assert res.windowTitle() == "BEC - PluginAutoUpdate"
|
||||||
|
# We need to manually close the launched window as it is not registered with qtbot.
|
||||||
|
# In real usage, the GUIServer would handle this in the sigint handler in case of a ctrl-c initiated shutdown.
|
||||||
|
res.close()
|
||||||
|
res.deleteLater()
|
||||||
|
Reference in New Issue
Block a user