def test_reset(self):
        w = WorkbenchTableWidgetItem(500, editable=False)

        w.display_data = 4444
        w.reset()

        self.assertEqual(4444, w.data(Qt.DisplayRole))
 def test_initialise_editable_bool(self):
     """
     Test that the widget is correctly initialised and the type is correctly kept in the .data call
     """
     mock_data = True
     w = WorkbenchTableWidgetItem(mock_data, editable=True)
     self.assertEqual(mock_data, w.display_data)
     self.assertEqual(mock_data, w.data(Qt.DisplayRole))
 def test_initialise_editable_bool(self):
     """
     Test that the widget is correctly initialised and the type is correctly kept in the .data call
     """
     mock_data = True
     w = WorkbenchTableWidgetItem(mock_data, editable=True)
     self.assertEqual(mock_data, w.display_data)
     self.assertEqual(mock_data, w.data(Qt.DisplayRole))
    def test_reset(self):
        w = WorkbenchTableWidgetItem(500, editable=False)

        w.display_data = 4444
        w.reset()

        self.assertEqual(4444, w.data(Qt.DisplayRole))
예제 #5
0
파일: presenter.py 프로젝트: ethoeng/mantid
    def load_data(self, table):
        num_rows = self.model.get_number_of_rows()
        table.setRowCount(num_rows)

        num_cols = self.model.get_number_of_columns()
        table.setColumnCount(num_cols)

        for col in range(num_cols):
            column_data = self.model.get_column(col)
            editable = self.model.is_editable_column(col)
            for row in range(num_rows):
                item = WorkbenchTableWidgetItem(column_data[row],
                                                editable=editable)
                table.setItem(row, col, item)
예제 #6
0
    def load_data(self, table):
        num_rows = self.model.get_number_of_rows()
        table.setRowCount(num_rows)

        num_cols = self.model.get_number_of_columns()

        # the table should be editable if the ws is not PeaksWS
        editable = not self.model.is_peaks_workspace()

        for col in range(num_cols):
            column_data = self.model.get_column(col)
            for row in range(num_rows):
                item = WorkbenchTableWidgetItem(column_data[row],
                                                editable=editable)
                table.setItem(row, col, item)
    def test_initialise_readonly(self):
        """
        Test that the widget converts everything to string if read only
        :return:
        """
        mock_data = 123
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))

        mock_data = 1.3333333
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))

        mock_data = V3D(1, 2, 3)
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))

        mock_data = True
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))

        mock_data = "apples"
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))
 def test_update(self):
     w = WorkbenchTableWidgetItem(500, editable=False)
     w.setData(Qt.DisplayRole, 4444)
     w.update()
     self.assertEqual(4444, w.display_data)
 def test_initialise_editable_with_float(self):
     mock_data = 42.00
     w = WorkbenchTableWidgetItem(mock_data, True)
     self.assertEqual(mock_data, w.data(Qt.DisplayRole))
     self.assertEqual(mock_data, w.display_data)
 def test_initialise_editable_with_v3d(self):
     mock_data = V3D(1, 2, 3)
     w = WorkbenchTableWidgetItem(mock_data, True)
     self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))
     # the original data of the V3D is stored as a string too
     self.assertEqual(str(mock_data), w.display_data)
    def test_initialise_readonly(self):
        """
        Test that the widget converts everything to string if read only
        :return:
        """
        mock_data = 123
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))

        mock_data = 1.3333333
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))

        mock_data = V3D(1, 2, 3)
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))

        mock_data = True
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))

        mock_data = "apples"
        w = WorkbenchTableWidgetItem(mock_data, editable=False)
        self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))
 def test_update(self):
     w = WorkbenchTableWidgetItem(500, editable=False)
     w.setData(Qt.DisplayRole, 4444)
     w.update()
     self.assertEqual(4444, w.display_data)
 def test_initialise_editable_with_float(self):
     mock_data = 42.00
     w = WorkbenchTableWidgetItem(mock_data, True)
     self.assertEqual(mock_data, w.data(Qt.DisplayRole))
     self.assertEqual(mock_data, w.display_data)
 def test_initialise_editable_with_v3d(self):
     mock_data = V3D(1, 2, 3)
     w = WorkbenchTableWidgetItem(mock_data, True)
     self.assertEqual(str(mock_data), w.data(Qt.DisplayRole))
     # the original data of the V3D is stored as a string too
     self.assertEqual(str(mock_data), w.display_data)