Skip to content

Commit

Permalink
Catch errors raised by operations in the system tests (#2253)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackEAllen committed Jul 5, 2024
2 parents df9363b + 68cd1a6 commit 27975ce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/release_notes/next/dev-2250-catch-operations-errors
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#2250 : Make systems tests stricter to catch operations errors

15 changes: 14 additions & 1 deletion mantidimaging/gui/test/gui_system_operations_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
("Rotate Stack", []),
]

ALLOWED_ERRORS = [
'Negative values found in result preview for slice 0.',
'Flat-fielding completed. Slices containing negative values in IMAT_Flower_Tomo_000000: all slices.',
'Error applying filter for preview: could not broadcast input array from shape (1,80,80) into shape (1,90,90)'
]


@start_multiprocessing_pool
class TestGuiSystemOperations(GuiSystemBase):
Expand Down Expand Up @@ -96,7 +102,8 @@ def _get_operation_button_widget(form: QFormLayout, button_name: str) -> QWidget
raise ValueError(f"Could not find '{button_name}' in form")

@parameterized.expand(OP_LIST)
def test_run_operation_stack(self, op_name, params):
@mock.patch("mantidimaging.gui.windows.operations.FiltersWindowView.show_error_dialog")
def test_run_operation_stack(self, op_name, params, mock_error_dialog):
QTest.qWait(SHOW_DELAY)
index = self.op_window.filterSelector.findText(op_name)
self.assertGreaterEqual(index, 0, f'Operation "{op_name}" not found in filterSelector')
Expand All @@ -115,6 +122,12 @@ def test_run_operation_stack(self, op_name, params):
QTest.qWait(SHORT_DELAY)
wait_until(lambda: self.op_window.presenter.filter_is_running is False, max_retry=600)

caught_errors = mock_error_dialog.call_args_list
for caught_args in caught_errors:
caught_error = caught_args[0][0]
if caught_error not in ALLOWED_ERRORS:
raise AssertionError(f"Operation gave error: {caught_error}")

@parameterized.expand(product(OP_LIST[:3], ["new", "original"]))
def test_run_operation_stack_safe(self, op_info, keep_stack):
op_name, params = op_info
Expand Down

0 comments on commit 27975ce

Please sign in to comment.