def test_is_editable_column(self): ws = MockWorkspace() model = TableWorkspaceDisplayModel(ws) ws.isColumnReadOnly = StrictMock(return_value=False) self.assertTrue(model.is_editable_column(0)) ws.isColumnReadOnly = StrictMock(return_value=True) self.assertFalse(model.is_editable_column(0))
def test_initialise_marked_columns_multiple_y_before_yerr(self): ws = MockWorkspace() # add 5 columns as that is how many the default mock WS has mock_column_types = [ TableWorkspaceColumnTypeMapping.X, TableWorkspaceColumnTypeMapping.Y, TableWorkspaceColumnTypeMapping.YERR, TableWorkspaceColumnTypeMapping.Y, TableWorkspaceColumnTypeMapping.Y, TableWorkspaceColumnTypeMapping.YERR, TableWorkspaceColumnTypeMapping.YERR, TableWorkspaceColumnTypeMapping.X ] ws.columnCount = StrictMock(return_value=len(mock_column_types)) ws.getPlotType = lambda i: mock_column_types[i] ws.getLinkedYCol = StrictMock(side_effect=[1, 3, 4]) model = TableWorkspaceDisplayModel(ws) self.assertEqual(2, len(model.marked_columns.as_x)) self.assertEqual(3, len(model.marked_columns.as_y)) self.assertEqual(3, len(model.marked_columns.as_y_err)) self.assertEqual(1, model.marked_columns.as_y_err[0].related_y_column) self.assertEqual(3, model.marked_columns.as_y_err[1].related_y_column) self.assertEqual(4, model.marked_columns.as_y_err[2].related_y_column)
def __init__(self): self.clear = StrictMock() self.setHeaderLabel = StrictMock() self.addTopLevelItem = StrictMock() self.topLevelItemCount = Mock(return_value=3) self.topLevelItem = StrictMock( return_value=MockQTreeWidgetParentItem()) self.itemClicked = Mock() self.itemChanged = Mock()
def test_initialise_marked_columns_one_of_each_type(self): num_of_repeated_columns = 10 ws = MockWorkspace() # multiply by 3 to have 1 of each type ws.columnCount = StrictMock(return_value=num_of_repeated_columns * 3) # make 10 columns of each type mock_column_types = [ TableWorkspaceColumnTypeMapping.X, TableWorkspaceColumnTypeMapping.Y, TableWorkspaceColumnTypeMapping.YERR ] * num_of_repeated_columns ws.getPlotType = lambda i: mock_column_types[i] ws.getLinkedYCol = lambda i: i - 1 model = TableWorkspaceDisplayModel(ws) self.assertEqual(num_of_repeated_columns, len(model.marked_columns.as_x)) self.assertEqual(num_of_repeated_columns, len(model.marked_columns.as_y)) self.assertEqual(num_of_repeated_columns, len(model.marked_columns.as_y_err)) for i, col in enumerate(range(2, 30, 3)): self.assertEqual(col - 1, model.marked_columns.as_y_err[i].related_y_column)
def __init__(self): self.addChild = StrictMock() self.childCount = Mock(return_value=0) self.setCheckState = Mock() self.parent = Mock(return_value=False) self.childCount = Mock(return_value=1) self.child = Mock(return_value=MockQTreeWidgetChildItem(self))
def test_initialise_marked_columns_multiple_y_before_yerr(self): ws = MockWorkspace() # add 5 columns as that is how many the default mock WS has mock_column_types = [ TableWorkspaceColumnTypeMapping.X, TableWorkspaceColumnTypeMapping.Y, TableWorkspaceColumnTypeMapping.YERR, TableWorkspaceColumnTypeMapping.Y, TableWorkspaceColumnTypeMapping.Y, TableWorkspaceColumnTypeMapping.YERR, TableWorkspaceColumnTypeMapping.YERR, TableWorkspaceColumnTypeMapping.X ] ws.columnCount = StrictMock(return_value=len(mock_column_types)) ws.getPlotType = lambda i: mock_column_types[i] model = TableWorkspaceDisplayModel(ws) self.assertEqual(2, len(model.marked_columns.as_x)) self.assertEqual(3, len(model.marked_columns.as_y)) # no YErr is added because the Y column hasn't been added yet, # and there isn't anything to associate the error with self.assertEqual(3, len(model.marked_columns.as_y_err)) self.assertEqual(1, model.marked_columns.as_y_err[0].related_y_column) # the YErr associates with the FIRST Y column that doesn't have a Y Err self.assertEqual(3, model.marked_columns.as_y_err[1].related_y_column) self.assertEqual(4, model.marked_columns.as_y_err[2].related_y_column)
def __init__(self): self.setFocus = StrictMock() self.findFirst = StrictMock() self.findNext = StrictMock() self.hasSelectedText = StrictMock() self.selectedText = StrictMock() self.replace = StrictMock() self.replaceAll = StrictMock() self.fileName = StrictMock()
def __init__(self, parent=None): self.addChild = StrictMock() self.childCount = Mock(return_value=0) self.setCheckState = Mock() self.checkState = Mock() self.parent = Mock(return_value=parent) self.childCount = Mock(return_value=0) self.child = Mock(return_value=False)
def __init__(self): self.addWidget = StrictMock() self.replaceWidget = StrictMock() self.widget = StrictMock() self.hide = StrictMock() self.show = StrictMock() self.close = StrictMock() self.exec_ = StrictMock()
def __init__(self): self.mock_facility = MockFacility(self.all_facilities[0]) self.mock_instrument = self.mock_facility.all_instruments[0] self.getFacilityNames = StrictMock(return_value=self.all_facilities) self.getFacility = StrictMock(return_value=self.mock_facility) self.getInstrument = StrictMock(return_value=self.mock_instrument) self.getString = StrictMock(return_value="1") self.setFacility = StrictMock() self.setString = StrictMock()
def __init__(self, name): self.name = StrictMock(return_value=name) self.all_instruments = [MockInstrument(0), MockInstrument(1)] self.instruments = StrictMock(return_value=self.all_instruments)
def __init__(self): self.getString = StrictMock(return_value="1") self.setString = StrictMock()
def __init__(self): self.setString = StrictMock()
def __init__(self, idx): self.name = StrictMock(return_value="instr{}".format(idx))
def __init__(self): super(MockMultiFileInterpreter, self).__init__(None) self.execute_current = StrictMock() self.abort_current = StrictMock() self.close_tab = StrictMock() self.execute_current_async = StrictMock() self.execute_async = StrictMock() self.abort_current = StrictMock() self.toggle_find_replace_dialog = StrictMock() self.toggle_comment_current = StrictMock() self.tabs_to_spaces_current = StrictMock() self.spaces_to_tabs_current = StrictMock() self.toggle_whitespace_visible_all = StrictMock() self.plus_button_clicked = StrictMock()
def __init__(self): self.algorithm_tree_widget = MockQTreeWidget() self.interface_tree_widget = MockQTreeWidget() self.add_checked_widget_item = StrictMock( return_value=MockQTreeWidgetChildItem())
def __init__(self, string_value): self.string_value = string_value self.beginGroup = StrictMock() self.value = StrictMock() self.value.side_effect = self.value_depending_on_str self.endGroup = StrictMock()
def __init__(self): self.name = StrictMock(return_value=self.MOCK_NAME) self.instruments = StrictMock(return_value=self.all_instruments)
def __init__(self, read_return=None, axes=2, isHistogramData=True): if read_return is None: read_return = [1, 2, 3, 4, 5] # This is assigned to a function, as the original implementation is a function that returns # the spectrumInfo object self.spectrumInfo = self._return_MockSpectrumInfo self.getNumberHistograms = StrictMock(return_value=1) self.isHistogramData = StrictMock(return_value=isHistogramData) self.blocksize = StrictMock(return_value=len(read_return)) self.readX = StrictMock(return_value=read_return) self.readY = StrictMock(return_value=read_return) self.readE = StrictMock(return_value=read_return) self.axes = StrictMock(return_value=axes) self.hasMaskedBins = None self.maskedBinsIndices = None self.isCommonBins = StrictMock(return_value=True) self.column_types = ["int", "float", "string", "v3d", "bool"] self.columnTypes = StrictMock(return_value=self.column_types) self.mock_spectrum = MockSpectrum() self.getSpectrum = StrictMock(return_value=self.mock_spectrum) self.mock_axis = MockMantidAxis() self.getAxis = StrictMock(return_value=self.mock_axis) self.setCell = StrictMock() self.name = StrictMock(return_value=self.TEST_NAME) self._column_names = [] for i in range(self.COLS): self._column_names.append("col{0}".format(i)) self.getColumnNames = StrictMock(return_value=self._column_names) self.column_count = self.COLS self.columnCount = StrictMock(return_value=self.column_count) self.row_count = self.ROWS self.rowCount = StrictMock(return_value=self.row_count) self.column = StrictMock(return_value=[1] * self.row_count) self.emit_repaint = StrictMock() self.getPlotType = StrictMock()