Skip to content

Commit f2549d8

Browse files
Fixes : MSCOLAB File Import Abort Error (Open-MSS#2635)
1 parent 7d597f2 commit f2549d8

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

mslib/msui/msui_mainwindow.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -671,14 +671,15 @@ def handle_import_local(self, extension, function, pickertype):
671671
self.last_save_directory,
672672
f"Flight Track (*.{extension});;All files (*.*)",
673673
pickertype=pickertype)
674+
if filenames is None:
675+
return
674676
if self.local_active:
675-
if filenames is not None:
676-
activate = True
677-
if len(filenames) > 1:
678-
activate = False
679-
for name in filenames:
680-
self.create_new_flight_track(filename=name, function=function, activate=activate)
681-
self.last_save_directory = fs.path.dirname(name)
677+
activate = True
678+
if len(filenames) > 1:
679+
activate = False
680+
for name in filenames:
681+
self.create_new_flight_track(filename=name, function=function, activate=activate)
682+
self.last_save_directory = fs.path.dirname(name)
682683
else:
683684
for name in filenames:
684685
self.mscolab.handle_import_msc(name, extension, function, pickertype)

tests/_test_msui/test_mscolab.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,22 @@ def test_import_file(self, name, qtbot):
596596
imported_wp = self.window.mscolab.waypoints_model
597597
assert len(imported_wp.waypoints) == name[2]
598598

599+
def test_none_import_file(self, qtbot):
600+
with mock.patch("mslib.msui.msui_mainwindow.get_open_filenames", return_value=None) as mockopen:
601+
self._connect_to_mscolab(qtbot)
602+
modify_config_file({"MSS_auth": {self.url: self.userdata[0]}})
603+
self._login(qtbot, emailid=self.userdata[0], password=self.userdata[2])
604+
self._activate_operation_at_index(0)
605+
wp = self.window.mscolab.waypoints_model
606+
assert len(wp.waypoints) == 2
607+
for action in self.window.menuImportFlightTrack.actions():
608+
if action.objectName() == "actionImportFlightTrackFTML":
609+
action.trigger()
610+
break
611+
assert mockopen.call_count == 1
612+
imported_wp = self.window.mscolab.waypoints_model
613+
assert len(imported_wp.waypoints) == 2
614+
599615
def test_work_locally_toggle(self, qtbot):
600616
self._connect_to_mscolab(qtbot)
601617
modify_config_file({"MSS_auth": {self.url: self.userdata[0]}})

0 commit comments

Comments
 (0)