Skip to content

Commit

Permalink
active_op_id needs to be shared (#2326)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReimarBauer authored May 6, 2024
1 parent 3e0f74c commit afa3061
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 4 deletions.
11 changes: 8 additions & 3 deletions mslib/msui/multiple_flightpath_dockwidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ class MultipleFlightpathControlWidget(QtWidgets.QWidget, ui.Ui_MultipleViewWidge
signal_parent_closes = QtCore.pyqtSignal()

def __init__(self, parent=None, view=None, listFlightTracks=None,
listOperationsMSC=None, category=None, activeFlightTrack=None, mscolab_server_url=None, token=None):
listOperationsMSC=None, category=None, activeFlightTrack=None, active_op_id=None,
mscolab_server_url=None, token=None):
super().__init__(parent)
# ToDO: Remove all patches, on closing dockwidget.
self.ui = parent
Expand All @@ -124,6 +125,7 @@ def __init__(self, parent=None, view=None, listFlightTracks=None,
self.flight_path = None # flightpath object
self.dict_flighttrack = {} # Dictionary of flighttrack data: patch,color,wp_model
self.active_flight_track = activeFlightTrack
self.active_op_id = active_op_id
self.msc_category = category # object of active category
self.listOperationsMSC = listOperationsMSC
self.listFlightTracks = listFlightTracks
Expand Down Expand Up @@ -196,8 +198,11 @@ def login(self, url, token):
self.connect_mscolab_server()

def connect_mscolab_server(self):
if self.active_op_id is not None:
self.deactivate_all_flighttracks()
self.operations = MultipleFlightpathOperations(self, self.mscolab_server_url, self.token,
self.list_operation_track,
self.active_op_id,
self.listOperationsMSC, self.view)
self.obb.append(self.operations)

Expand Down Expand Up @@ -510,10 +515,10 @@ class MultipleFlightpathOperations:
on the TopView canvas.
"""

def __init__(self, parent, mscolab_server_url, token, list_operation_track, listOperationsMSC, view):
def __init__(self, parent, mscolab_server_url, token, list_operation_track, active_op_id, listOperationsMSC, view):
# Variables related to Mscolab Operations
self.parent = parent
self.active_op_id = None
self.active_op_id = active_op_id
self.mscolab_server_url = mscolab_server_url
self.token = token
self.view = view
Expand Down
3 changes: 2 additions & 1 deletion mslib/msui/topview.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def __init__(self, parent=None, mainwindow=None, model=None, _id=None,
self.active_flighttrack = active_flighttrack

# Stores active mscolab operation id
self.active_op_id = None
self.active_op_id = mainwindow.mscolab.active_op_id

# Mscolab Server Url and token
self.mscolab_server_url = mscolab_server_url
Expand Down Expand Up @@ -356,6 +356,7 @@ def openTool(self, index):
listOperationsMSC=self.mainwindow_listOperationsMSC,
category=self.mainwindow_filterCategoryCb,
activeFlightTrack=self.active_flighttrack,
active_op_id=self.active_op_id,
mscolab_server_url=self.mscolab_server_url,
token=self.token)

Expand Down
1 change: 1 addition & 0 deletions mslib/msui/viewwindows.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ def createDockWidget(self, index, title, widget):
# setWidget transfers the widget's ownership to Qt -- no setParent()
# call is necessary:
self.docks[index].setWidget(widget)

self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, self.docks[index])

# Check if another dock widget occupies the dock area. If yes,
Expand Down
71 changes: 71 additions & 0 deletions tests/_test_msui/test_mscolab.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,77 @@ def assert_logout_text():
qtbot.wait_until(assert_label_text)
# ToDo verify all operations disabled again without a visual check

def test_marked_bold_only_in_multiple_flight_path_operations_for_active_operation(self, qtbot):
"""
checks that when we use operations only the operations is bold marked not the flighttrack too
"""
# 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)
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)
assert topview_0.window.active_op_id is not None

list_flighttrack = topview_0.window.docks[5].widget().list_flighttrack
list_operation_track = topview_0.window.docks[5].widget().list_operation_track

for i in range(list_operation_track.count()):
listItem = list_operation_track.item(i)
if self.window.mscolab.active_op_id == listItem.op_id:
assert listItem.font().bold() is True
for i in range(list_flighttrack.count()):
listItem = list_flighttrack.item(i)
assert listItem.font().bold() is False

def test_correct_active_op_id_in_topview(self, qtbot):
"""
checks that active_op_id is set
"""
# 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])

assert self.window.mscolab.active_op_id is None
# test after activating operation
self._activate_operation_at_index(0)
assert self.window.mscolab.active_op_id is not None
selected_op_id = self.window.mscolab.active_op_id
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.active_op_id is not None
assert topview_0.window.active_op_id == selected_op_id

def test_multiple_flightpath_switching_to_flighttrack_and_logout(self, qtbot):
"""
checks that we can switch in topviews with the multiple flightpath dockingwidget
Expand Down

0 comments on commit afa3061

Please sign in to comment.