diff --git a/tests/_test_msui/test_mscolab.py b/tests/_test_msui/test_mscolab.py index 02b280afd..55f828520 100644 --- a/tests/_test_msui/test_mscolab.py +++ b/tests/_test_msui/test_mscolab.py @@ -32,6 +32,7 @@ import requests.exceptions import mock import pytest +import random import mslib.utils.auth from mslib.mscolab.conf import mscolab_settings @@ -411,6 +412,69 @@ def assert_logout_text(): qtbot.wait_until(assert_label_text) # ToDo verify all operations disabled again without a visual check + def test_operation_while_switching_error(self, qtbot): + """Test that operation switching trigger the KeyError""" + + # 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 + # topview_0.window.setAttribute(QtCore.Qt.WA_DeleteOnClose) + + # def assert_attribute(): + # assert topview_0.window.testAttribute(QtCore.Qt.WA_DeleteOnClose) + # qtbot.wait_until(assert_attribute) + + # open multiple flightpath + 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) + + # 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]) + + # activate all operation, this enables them in the docking widget too + for _ in range(6): + self._activate_operation_at_index(random.randint(0, 2)) + self._activate_flight_track_at_index(0) + + # # Create the new operation + # op_name = "fourth" + # assert add_operation(op_name, "description") + # assert add_user_to_operation(path=op_name, emailid=self.userdata[0]) + # + # for _ in range(4): + # self._activate_operation_at_index(random.randint(0, 3)) + # self._activate_flight_track_at_index(0) + + with mock.patch("PyQt5.QtWidgets.QMessageBox.warning", return_value=QtWidgets.QMessageBox.Yes): + topview_0.window.close() + + def assert_window_closed(): + assert topview_0.window.tv_window_exists is False + qtbot.wait_until(assert_window_closed) + + self.window.mscolab.logout() + + def assert_logout_text(): + assert self.window.usernameLabel.text() == "User" + qtbot.wait_until(assert_logout_text) + def test_multiple_flightpath_switching_to_flighttrack_and_logout(self, qtbot): """ checks that we can switch in topviews with the multiple flightpath dockingwidget