|
1 | 1 | # Test methods with long descriptive names can omit docstrings |
2 | 2 | # pylint: disable=missing-docstring |
3 | | -from os import path, remove |
| 3 | +from os import path, remove, getcwd |
4 | 4 | from unittest.mock import Mock, patch |
5 | 5 | import pickle |
6 | 6 | import tempfile |
|
27 | 27 | from Orange.widgets.utils.domaineditor import ComboDelegate, VarTypeDelegate, VarTableModel |
28 | 28 |
|
29 | 29 | TITANIC_PATH = path.join(path.dirname(Orange.__file__), 'datasets', 'titanic.tab') |
| 30 | +orig_path_exists = path.exists |
30 | 31 |
|
31 | 32 |
|
32 | 33 | class FailedSheetsFormat(FileFormat): |
@@ -440,3 +441,22 @@ def test_adds_origin(self): |
440 | 441 | attrs = data1.domain["image"].attributes |
441 | 442 | self.assertIn("origin", attrs) |
442 | 443 | self.assertIn("origin1", attrs["origin"]) |
| 444 | + |
| 445 | + @patch("Orange.widgets.widget.OWWidget.workflowEnv", |
| 446 | + Mock(return_value={"basedir": getcwd()})) |
| 447 | + def test_open_moved_workflow(self): |
| 448 | + """Test opening workflow that has been moved to another location |
| 449 | + (i.e. sent by email), considering data file is stored in the same |
| 450 | + directory as the workflow. |
| 451 | + """ |
| 452 | + recent_path = RecentPath( |
| 453 | + "Users/temp/datasets/test.tab", "", "datasets/test.tab" |
| 454 | + ) |
| 455 | + stored_settings = {"recent_paths": [recent_path]} |
| 456 | + f = open("test.tab", 'w') |
| 457 | + f.close() |
| 458 | + w = self.create_widget(OWFile, stored_settings=stored_settings) |
| 459 | + w.load_data() |
| 460 | + self.assertEqual(w.file_combo.count(), 1) |
| 461 | + self.assertFalse(w.Error.file_not_found.is_shown()) |
| 462 | + remove("test.tab") |
0 commit comments