Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test added for updating multiple flightpath docking widget for new operations (enabled signals and slots) #2358

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mslib/msui/mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ class MSUIMscolab(QtCore.QObject):
signal_operation_removed = QtCore.pyqtSignal(int, name="signal_operation_removed")
signal_login_mscolab = QtCore.pyqtSignal(str, str, name="signal_login_mscolab")
signal_logout_mscolab = QtCore.pyqtSignal(name="signal_logout_mscolab")
signal_reload_operation = QtCore.pyqtSignal(name="signal_reload_operation")
signal_listFlighttrack_doubleClicked = QtCore.pyqtSignal()
signal_permission_revoked = QtCore.pyqtSignal(int)
signal_render_new_permission = QtCore.pyqtSignal(int, str)
Expand Down Expand Up @@ -1917,6 +1918,7 @@ def reload_operations(self):
index = self.ui.filterCategoryCb.findText(selected_category, QtCore.Qt.MatchFixedString)
if index >= 0:
self.ui.filterCategoryCb.setCurrentIndex(index)
self.signal_reload_operation.emit()

def reload_wps_from_server(self):
if self.active_op_id is None:
Expand Down
6 changes: 6 additions & 0 deletions mslib/msui/msui_mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ class MSUIMainWindow(QtWidgets.QMainWindow, ui.Ui_MSUIMainWindow):
signal_activate_operation = QtCore.pyqtSignal(int, name="signal_activate_operation")
signal_operation_added = QtCore.pyqtSignal(int, str, name="signal_operation_added")
signal_operation_removed = QtCore.pyqtSignal(int, name="signal_operation_removed")
signal_reload_operation = QtCore.pyqtSignal(name="signal_reload_operation")
signal_login_mscolab = QtCore.pyqtSignal(str, str, name="signal_login_mscolab")
signal_logout_mscolab = QtCore.pyqtSignal(name="signal_logout_mscolab")
signal_listFlighttrack_doubleClicked = QtCore.pyqtSignal()
Expand Down Expand Up @@ -524,6 +525,7 @@ def __init__(self, mscolab_data_dir=None, tutorial_mode=False, *args):
self.mscolab.signal_unarchive_operation.connect(self.activate_operation_slot)
self.mscolab.signal_operation_added.connect(self.add_operation_slot)
self.mscolab.signal_operation_removed.connect(self.remove_operation_slot)
self.mscolab.signal_reload_operation.connect(self.reload_operation_slot)
self.mscolab.signal_login_mscolab.connect(lambda d, t: self.signal_login_mscolab.emit(d, t))
self.mscolab.signal_logout_mscolab.connect(lambda: self.signal_logout_mscolab.emit())
self.mscolab.signal_listFlighttrack_doubleClicked.connect(
Expand Down Expand Up @@ -572,6 +574,10 @@ def add_operation_slot(self, op_id, path):
def remove_operation_slot(self, op_id):
self.signal_operation_removed.emit(op_id)

@QtCore.pyqtSlot()
def reload_operation_slot(self):
self.signal_reload_operation.emit()

def add_plugin_submenu(self, name, extension, function, pickertype, plugin_type="Import"):
if plugin_type == "Import":
menu = self.menuImportFlightTrack
Expand Down
15 changes: 14 additions & 1 deletion mslib/msui/multiple_flightpath_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,14 @@ def connect_mscolab_server(self):
self.list_operation_track,
self.active_op_id,
self.listOperationsMSC, self.view)
self.obb.append(self.operations)
self.obb = [self.operations]

self.ui.signal_permission_revoked.connect(lambda op_id: self.operations.permission_revoked(op_id))
self.ui.signal_render_new_permission.connect(lambda op_id, path: self.operations.render_permission(op_id, path))
# Signal emitted, on activation of operation from MSUI
self.ui.signal_activate_operation.connect(self.update_op_id)
self.ui.signal_operation_added.connect(self.add_operation_slot)
self.ui.signal_reload_operation.connect(self.reload_operation)
self.ui.signal_operation_removed.connect(self.remove_operation_slot)

# deactivate vice versa selection of Operation or Flight Track
Expand All @@ -223,6 +224,18 @@ def connect_mscolab_server(self):
# Mscolab Server logout
self.ui.signal_logout_mscolab.connect(self.logout)

@QtCore.pyqtSlot()
def reload_operation(self):
# reload operation is important
# because it is triggerd when you are invited into an operation or access is revoked
# Idey:
# cleanup old list, see logout
# fetch mainwindow.listOperationsMSC, this is always recent etc
# call similiar to connect_mscolab_server MultipleFlightpathOperations
# set self.obb
# ToDo we need access to the mainwindow
pass

def update(self):
for entry in self.dict_flighttrack.values():
entry["patch"].update()
Expand Down
3 changes: 3 additions & 0 deletions mslib/msui/topview.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class MSUITopViewWindow(MSUIMplViewWindow, ui.Ui_TopViewWindow):
signal_ft_vertices_color_change = QtCore.pyqtSignal(tuple)
signal_operation_added = QtCore.pyqtSignal(int, str)
signal_operation_removed = QtCore.pyqtSignal(int)
signal_reload_operation = QtCore.pyqtSignal()
signal_login_mscolab = QtCore.pyqtSignal(str, str)
signal_logout_mscolab = QtCore.pyqtSignal()
signal_listFlighttrack_doubleClicked = QtCore.pyqtSignal()
Expand All @@ -199,6 +200,7 @@ def __init__(self, parent=None, mainwindow=None, model=None, _id=None,
self.mainwindow_signal_listFlighttrack_doubleClicked = mainwindow.signal_listFlighttrack_doubleClicked
self.mainwindow_signal_activate_operation = mainwindow.signal_activate_operation
self.mainwindow_signal_permission_revoked = mainwindow.signal_permission_revoked
self.mainwindow_signal_reload_operation = mainwindow.signal_reload_operation
self.mainwindow_signal_render_new_permission = mainwindow.signal_render_new_permission
self.mainwindow_signal_activate_flighttrack = mainwindow.signal_activate_flighttrack
self.mainwindow_listFlightTracks = mainwindow.listFlightTracks
Expand Down Expand Up @@ -361,6 +363,7 @@ def openTool(self, index):
token=self.token)

self.mainwindow_signal_logout_mscolab.connect(self.signal_logout_mscolab.emit)
self.mainwindow_signal_reload_operation.connect(self.signal_reload_operation.emit)
self.mainwindow_signal_listFlighttrack_doubleClicked.connect(
lambda: self.signal_listFlighttrack_doubleClicked.emit())
self.mainwindow_signal_permission_revoked.connect(
Expand Down
51 changes: 51 additions & 0 deletions tests/_test_msui/test_mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,55 @@ def assert_dock_loaded():
listItem = list_flighttrack.item(i)
assert listItem.font().bold() is False

def test_multiple_flight_path_operations_gets_updates_of_new_operations(self, qtbot):
"""
checks start with flightpathes and the multiple flightpath dockingwidget and updates the mscolab list
in the widget after a login by adding new operations
"""
pytest.xfail("ToDo: needs a refactoring for accessing mainwindow from the docking widget")
self.window.actionTopView.trigger()

def assert_active_views():
# check 1 view opened
assert len(self.window.get_active_views()) == 1
qtbot.wait_until(assert_active_views)

topview_0 = self.window.listViews.item(0)
assert topview_0.window.tv_window_exists is True
# open multiple flightpath first window
topview_0.window.cbTools.currentIndexChanged.emit(6)

def assert_dock_loaded():
assert topview_0.window.docks[5] is not None
qtbot.wait_until(assert_dock_loaded)
# we don't have an operation loaded
assert topview_0.window.active_op_id is None

list_flighttrack = topview_0.window.docks[5].widget().list_flighttrack
assert list_flighttrack.item(0).font().bold() is True
list_operation_track = topview_0.window.docks[5].widget().list_operation_track
assert list_operation_track.item(0) is None

self._connect_to_mscolab(qtbot)
modify_config_file({"MSS_auth": {self.url: self.userdata[0]}})
self._login(qtbot, emailid=self.userdata[0], password=self.userdata[2])

assert self.window.listOperationsMSC.model().rowCount() == 1
# test after activating operation
self._activate_operation_at_index(0)
list_operation_track = topview_0.window.docks[5].widget().list_operation_track
assert list_operation_track.count() == 1
# more operations for the user
for op_name in ["second", "third"]:
assert add_operation(op_name, "description")
assert add_user_to_operation(path=op_name, emailid=self.userdata[0])
# add_operation is working on the database, we need manually reload users operations
self.window.mscolab.reload_operations()
assert self.window.listOperationsMSC.model().rowCount() == 3
list_operation_track = topview_0.window.docks[5].widget().list_operation_track
# This is for now the description of the problem
assert list_operation_track.count() == 3

def test_correct_active_op_id_in_topview(self, qtbot):
"""
checks that active_op_id is set
Expand Down Expand Up @@ -902,6 +951,8 @@ def test_profile_dialog(self, qtbot):
assert not self.window.mscolab.profile_dialog.gravatarLabel.pixmap().isNull()

def _connect_to_mscolab(self, qtbot):
# The main window must be on top
self.window.activateWindow()
self.connect_window = mscolab.MSColab_ConnectDialog(parent=self.window, mscolab=self.window.mscolab)
self.window.mscolab.connect_window = self.connect_window
self.connect_window.urlCb.setEditText(self.url)
Expand Down