|
23 | 23 | class MainWindowViewTest(unittest.TestCase):
|
24 | 24 | def setUp(self) -> None:
|
25 | 25 | with mock.patch("mantidimaging.gui.windows.main.view.WelcomeScreenPresenter"):
|
26 |
| - self.view = MainWindowView() |
| 26 | + with mock.patch("mantidimaging.gui.windows.main.view.has_other_shared_arrays", return_value=False): |
| 27 | + self.view = MainWindowView() |
27 | 28 | self.presenter = mock.MagicMock()
|
28 | 29 | self.view.presenter = self.presenter
|
29 | 30 |
|
@@ -306,3 +307,34 @@ def test_get_images_from_stack_uuid(self):
|
306 | 307 |
|
307 | 308 | self.presenter.get_stack_visualiser.assert_called_once_with(uuid)
|
308 | 309 | self.assertEqual(images, return_value)
|
| 310 | + |
| 311 | + @mock.patch("mantidimaging.gui.windows.main.view.has_other_shared_arrays") |
| 312 | + @mock.patch("mantidimaging.gui.windows.main.view.free_all") |
| 313 | + @mock.patch("mantidimaging.gui.windows.main.view.QMessageBox") |
| 314 | + def test_ask_user_to_free_data(self, QMessageBox: Mock, free_all: Mock, has_other_shared_arrays: Mock): |
| 315 | + has_other_shared_arrays.return_value = True |
| 316 | + # makes the clickedButton the same return value mock as the addButton return |
| 317 | + QMessageBox.return_value.clickedButton.return_value = QMessageBox.return_value.addButton.return_value |
| 318 | + |
| 319 | + self.view.ask_user_to_free_data() |
| 320 | + |
| 321 | + QMessageBox.return_value.setWindowTitle.assert_called_once() |
| 322 | + QMessageBox.return_value.setText.assert_called_once() |
| 323 | + self.assertEquals(QMessageBox.return_value.addButton.call_count, 2) |
| 324 | + QMessageBox.return_value.exec.assert_called_once() |
| 325 | + free_all.assert_called_once() |
| 326 | + |
| 327 | + @mock.patch("mantidimaging.gui.windows.main.view.has_other_shared_arrays") |
| 328 | + @mock.patch("mantidimaging.gui.windows.main.view.free_all") |
| 329 | + @mock.patch("mantidimaging.gui.windows.main.view.QMessageBox") |
| 330 | + def test_ask_user_to_free_data_ignore_pressed(self, QMessageBox: Mock, free_all: Mock, |
| 331 | + has_other_shared_arrays: Mock): |
| 332 | + has_other_shared_arrays.return_value = True |
| 333 | + |
| 334 | + self.view.ask_user_to_free_data() |
| 335 | + |
| 336 | + QMessageBox.return_value.setWindowTitle.assert_called_once() |
| 337 | + QMessageBox.return_value.setText.assert_called_once() |
| 338 | + self.assertEquals(QMessageBox.return_value.addButton.call_count, 2) |
| 339 | + QMessageBox.return_value.exec.assert_called_once() |
| 340 | + free_all.assert_not_called() |
0 commit comments