Skip to content

Commit

Permalink
owcsvimport: Non-eager start
Browse files Browse the repository at this point in the history
  • Loading branch information
ales-erjavec committed Jul 1, 2020
1 parent 8c2ed75 commit 095556d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 7 additions & 3 deletions Orange/widgets/data/owcsvimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ def update_buttons(cbindex):
self._restoreState()
item = self.current_item()
if item is not None:
self.set_selected_file(item.path(), item.options())
self._invalidate()

def workflowEnvChanged(self, key, value, oldvalue):
super().workflowEnvChanged(key, value, oldvalue)
Expand Down Expand Up @@ -1262,8 +1262,12 @@ def _restoreState(self):

if currentpath:
idx = self.recent_combo.findData(currentpath, ImportItem.PathRole)
if idx != -1:
self.recent_combo.setCurrentIndex(idx)
elif model.data(model.index(0, 0), ImportItem.IsSessionItemRole):
# restore last (current) session item
idx = 0
else:
idx = -1
self.recent_combo.setCurrentIndex(idx)

@classmethod
def migrate_settings(cls, settings, version):
Expand Down
16 changes: 13 additions & 3 deletions Orange/widgets/data/tests/test_owcsvimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

from AnyQt.QtCore import QSettings

from orangewidget.tests.utils import simulate

from Orange.data import DiscreteVariable, TimeVariable, ContinuousVariable, \
StringVariable
from Orange.tests import named_file
Expand All @@ -20,6 +22,7 @@
from Orange.widgets.data.owcsvimport import (
pandas_to_table, ColumnType, RowSpec
)
from Orange.widgets.utils.pathutils import PathItem
from Orange.widgets.utils.settings import QSettings_writeArray
from Orange.widgets.utils.state_summary import format_summary_details

Expand Down Expand Up @@ -101,12 +104,19 @@ def test_restore_from_local(self):
owcsvimport.OWCSVFileImport,
)
item = w.current_item()
self.assertIsNone(item)
simulate.combobox_activate_index(w.recent_combo, 0)
item = w.current_item()
self.assertEqual(item.path(), path)
self.assertEqual(item.options(), self.data_regions_options)
data = w.settingsHandler.pack_data(w)
self.assertEqual(
w._session_items, [(path, self.data_regions_options.as_dict())],
"local settings item must be recorded in _session_items when "
"activated in __init__",
data['_session_items_v2'], [
(PathItem.AbsPath(path).as_dict(),
self.data_regions_options.as_dict())
],
"local settings item must be recorded in _session_items_v2 when "
"activated",
)
self._check_data_regions(self.get_output("Data", w))

Expand Down

0 comments on commit 095556d

Please sign in to comment.