Commit a558f928 authored by Stephen's avatar Stephen Committed by Peterson, Peter
Browse files

Fix failing unit tests

parent fbede83e
......@@ -341,7 +341,7 @@ class SliceViewerTest(unittest.TestCase):
data_view_mock.enable_tool_button.assert_called_once_with(ToolItemText.NONORTHOGONAL_AXES)
@patch("sip.isdeleted", return_value=False)
@mock.patch("mantidqt.widgets.sliceviewer.peaksviewer.presenter.TableWorkspaceDataPresenter")
@mock.patch("mantidqt.widgets.sliceviewer.peaksviewer.presenter.TableWorkspaceDataPresenterStandard")
@mock.patch("mantidqt.widgets.sliceviewer.presenter.PeaksViewerCollectionPresenter",
spec=PeaksViewerCollectionPresenter)
def test_overlay_peaks_workspaces_attaches_view_and_draws_peaks(self, mock_peaks_presenter, *_):
......
......@@ -57,7 +57,7 @@ class TableWorkspaceDisplayDecoder(TableWorkspaceDisplayAttributes):
related_y_column=y_err["relatedY"]))
pres.model.marked_columns.as_y_err = error_columns
pres.update_column_headers()
pres.presenter.update_column_headers()
return pres.container
......
......@@ -250,7 +250,7 @@ class TableWorkspaceDisplay(ObservingPresenter, DataCopier):
if col != selected_column:
self.presenter.model.set_column_type(int(col), 0)
self.presenter.model.set_column_type(selected_column, 5, related_y_column)
self.update_column_headers()
self.presenter.update_column_headers()
def action_set_as_none(self):
self._action_set_as(self.presenter.model.marked_columns.remove, 0)
......
......@@ -767,7 +767,7 @@ class TableWorkspaceDisplayPresenterTest(unittest.TestCase):
@with_mock_presenter()
def test_replace_incorrect_workspace(self, ws, view, presenter):
with patch(
'mantidqt.widgets.workspacedisplay.table.presenter.TableWorkspaceDisplay.load_data'
'mantidqt.widgets.workspacedisplay.table.presenter.TableWorkspaceDataPresenterStandard.load_data'
) as mock_load_data:
presenter.replace_workspace(ws.TEST_NAME + "123", ws)
self.assertNotCalled(mock_load_data)
......@@ -778,7 +778,7 @@ class TableWorkspaceDisplayPresenterTest(unittest.TestCase):
# patch this out after the constructor of the presenter has finished,
# so that we reset any calls it might have made
with patch(
'mantidqt.widgets.workspacedisplay.table.presenter.TableWorkspaceDisplay.load_data'
'mantidqt.widgets.workspacedisplay.table.presenter.TableWorkspaceDataPresenterStandard.load_data'
) as mock_load_data:
presenter.replace_workspace(ws.TEST_NAME, ws)
mock_load_data.assert_called_once_with(view)
......
......@@ -49,42 +49,67 @@ class TableWorkspaceDisplayViewQtTest(unittest.TestCase, QtWidgetFinder):
@start_qapplication
class TableWorkspaceDisplayViewTest(unittest.TestCase):
def test_gui_updated_when_row_added_from_dictionary(self):
def test_gui_updated_when_row_added_from_dictionary_standard(self):
ws = CreateEmptyTableWorkspace()
ws.addColumn("double", "test_col")
presenter = TableWorkspaceDisplay(ws)
presenter = TableWorkspaceDisplay(ws, batch=False)
current_rows = presenter.view.rowCount()
ws.addRow({'test_col': 1.0})
self.assertEqual(current_rows + 1, presenter.view.model().max_rows())
self.assertEqual(current_rows + 1, presenter.view.model().rowCount())
presenter.force_close()
def test_gui_updated_when_row_added_from_sequence(self):
def test_gui_updated_when_row_added_from_sequence_standard(self):
ws = CreateEmptyTableWorkspace()
ws.addColumn("double", "l")
presenter = TableWorkspaceDisplay(ws)
presenter = TableWorkspaceDisplay(ws, batch=False)
current_rows = presenter.view.rowCount()
ws.addRow([1.0])
self.assertEqual(current_rows + 1, presenter.view.model().rowCount())
presenter.force_close()
def test_gui_updated_when_column_removed_batch(self):
ws = CreateEmptyTableWorkspace()
ws.addColumn("double", "test_col")
presenter = TableWorkspaceDisplay(ws, batch=True)
ws.removeColumn('test_col')
self.assertEqual(0, presenter.view.columnCount())
presenter.force_close()
def test_gui_updated_when_row_added_from_dictionary_batch(self):
ws = CreateEmptyTableWorkspace()
ws.addColumn("double", "test_col")
presenter = TableWorkspaceDisplay(ws, batch=True)
current_rows = presenter.view.rowCount()
ws.addRow({'test_col': 1.0})
self.assertEqual(current_rows + 1, presenter.view.model().max_rows())
presenter.force_close()
def test_correct_number_of_rows_fetched_initially(self):
def test_correct_number_of_rows_fetched_initially_batch(self):
ws = CreateEmptyTableWorkspace()
ws.addColumn("double", "l")
presenter = TableWorkspaceDisplay(ws)
list(map(ws.addRow, ([i] for i in range(5*BATCH_SIZE))))
presenter = TableWorkspaceDisplay(ws, batch=True)
list(map(ws.addRow, ([i] for i in range(5 * BATCH_SIZE))))
# fetch more starting at index 0,0
index = presenter.view.model().index(0, 0)
presenter.view.model().fetchMore(index)
self.assertEqual(5*BATCH_SIZE, presenter.view.model().max_rows())
self.assertEqual(5 * BATCH_SIZE, presenter.view.model().max_rows())
self.assertEqual(BATCH_SIZE, presenter.view.model().rowCount())
presenter.force_close()
def test_scrolling_updates_number_of_rows_fetched(self):
def test_scrolling_updates_number_of_rows_fetched_batch(self):
ws = CreateEmptyTableWorkspace()
ws.addColumn("double", "l")
presenter = TableWorkspaceDisplay(ws)
list(map(ws.addRow, ([i] for i in range(5*BATCH_SIZE))))
presenter = TableWorkspaceDisplay(ws, batch=True)
list(map(ws.addRow, ([i] for i in range(5 * BATCH_SIZE))))
# fetch more starting at index 0,0
index = presenter.view.model().index(0, 0)
presenter.view.model().fetchMore(index)
......@@ -92,15 +117,7 @@ class TableWorkspaceDisplayViewTest(unittest.TestCase):
# scrolling should update our batch size to 2*BATCH_SIZE
presenter.view.scrollToBottom()
self.assertEqual(2 * BATCH_SIZE, presenter.view.model().rowCount())
def test_gui_updated_when_column_removed(self):
ws = CreateEmptyTableWorkspace()
ws.addColumn("double", "test_col")
presenter = TableWorkspaceDisplay(ws)
ws.removeColumn('test_col')
self.assertEqual(0, presenter.view.columnCount())
presenter.force_close()
if __name__ == '__main__':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment