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

cycle login with multiple_flightpath_dockwidget #2278

Merged
merged 3 commits into from
Mar 21, 2024
Merged
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
16 changes: 8 additions & 8 deletions mslib/msui/multiple_flightpath_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,14 @@ def __init__(self, parent=None, view=None, listFlightTracks=None,
def logout(self):
if self.operations is not None:
self.operations.logout_mscolab()
self.ui.signal_listFlighttrack_doubleClicked.disconnect()
self.ui.signal_permission_revoked.disconnect()
self.ui.signal_render_new_permission.disconnect()
self.operations = None
self.flighttrack_list = True
self.operation_list = False
for idx in range(len(self.obb)):
del self.obb[idx]
self.ui.signal_listFlighttrack_doubleClicked.disconnect()
self.ui.signal_permission_revoked.disconnect()
self.ui.signal_render_new_permission.disconnect()
self.operations = None
self.flighttrack_list = True
self.operation_list = False
for idx in range(len(self.obb)):
del self.obb[idx]

@QtCore.pyqtSlot(str, str)
def login(self, url, token):
Expand Down
9 changes: 0 additions & 9 deletions mslib/msui/topview.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,21 +371,12 @@ def openTool(self, index):
lambda op_id, path: self.signal_render_new_permission.emit(op_id, path))
if self.active_op_id is not None:
self.signal_activate_operation.emit(self.active_op_id)
widget.signal_parent_closes.connect(self.closed)
else:
raise IndexError("invalid control index")

# Create the actual dock widget containing <widget>.
self.createDockWidget(index, title, widget)

def closed(self):
self.mainwindow_signal_login_mscolab.disconnect()
self.mainwindow_signal_logout_mscolab.disconnect()
self.mainwindow_signal_listFlighttrack_doubleClicked.disconnect()
self.mainwindow_signal_activate_operation.disconnect()
self.mainwindow_signal_permission_revoked.disconnect()
self.mainwindow_signal_render_new_permission.disconnect()

@QtCore.pyqtSlot()
def disable_cbs(self):
self.wms_connected = True
Expand Down
79 changes: 79 additions & 0 deletions tests/_test_msui/test_mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,82 @@ def test_view_open(self, qtbot):
assert tableview.btAddWayPointToFlightTrack.isEnabled()
assert any(action.text() == "Ins WP" and action.isEnabled() for action in topview.mpl.navbar.actions())

def test_multiple_views_and_multiple_flightpath(self, qtbot):
"""
checks that we can have multiple topviews with the multiple flightpath dockingwidget
and we are able to cycle a login/logout
"""
# 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])

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])

# test after activating operation
self._activate_operation_at_index(0)
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)

# next topview
self.window.actionTopView.trigger()
topview_1 = self.window.listViews.item(1)

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

# 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)

# activate all operation, this enables them in the docking widget too
self._activate_operation_at_index(1)
self._activate_operation_at_index(2)
self._activate_operation_at_index(0)
# ToDo refactor to be able to activate/deactivate by the docking widget and that it can be checked

# open multiple flightpath second window
topview_1.window.cbTools.currentIndexChanged.emit(6)

def assert_dock_loaded():
assert topview_1.window.docks[5] is not None
qtbot.wait_until(assert_dock_loaded)

# activate all operation, this enables them in the docking widget too
self._activate_operation_at_index(1)
self._activate_operation_at_index(2)
self._activate_operation_at_index(0)
# ToDo refactor to be able to activate/deactivate by the docking widget and that it can be checked

def assert_label_text():
# verify logged in
assert self.window.usernameLabel.text() == self.userdata[1]
qtbot.wait_until(assert_label_text)

self.window.mscolab.logout()
matrss marked this conversation as resolved.
Show resolved Hide resolved

def assert_logout_text():
assert self.window.usernameLabel.text() == "User"
qtbot.wait_until(assert_logout_text)

self._connect_to_mscolab(qtbot)
self._login(qtbot, emailid=self.userdata[0], password=self.userdata[2])
# verify logged in again
qtbot.wait_until(assert_label_text)
# ToDo verify all operations disabled again without a visual check

@mock.patch("PyQt5.QtWidgets.QFileDialog.getSaveFileName",
return_value=(fs.path.join(mscolab_settings.MSCOLAB_DATA_DIR, 'test_export.ftml'),
"Flight track (*.ftml)"))
Expand Down Expand Up @@ -737,6 +813,9 @@ def assert_operation_is_listed():
qtbot.wait_until(assert_operation_is_listed)

def _activate_operation_at_index(self, index):
# The main window must be on top
self.window.activateWindow()
# get the item by its index
item = self.window.listOperationsMSC.item(index)
point = self.window.listOperationsMSC.visualItemRect(item).center()
QtTest.QTest.mouseClick(self.window.listOperationsMSC.viewport(), QtCore.Qt.LeftButton, pos=point)
Expand Down