def test_setData_on_last_row_extends_array(self):
     model = ArrayModel()
     model.reset(Array([5.0]))
     self.assertTrue(model.setData(model.index(1, 0), 2.3))
     self.assertEqual(model.rowCount(), 3)
     self.assertEqual(model.index(0, 0).data(), 5.0)
     self.assertEqual(model.index(1, 0).data(), 2.3)
Example #2
0
 def test_removeRows_remove_all_rows(self):
     model = ArrayModel()
     model.reset(Array([5.0, 3.0, 7.0]))
     self.assertTrue(model.removeRows(0, 3))
     self.assertEqual(model.rowCount(), 1)
     index = model.index(0, 0)
     self.assertIsNone(index.data())
Example #3
0
 def test_columnCount(self):
     model = ArrayModel()
     self.assertEqual(model.columnCount(), 1)
     model.reset(Array([3, 5, 1]))
     self.assertEqual(model.columnCount(), 1)
 def test_setData(self):
     model = ArrayModel()
     model.reset(Array([5.0]))
     self.assertTrue(model.setData(model.index(0, 0), 2.3))
     self.assertEqual(model.rowCount(), 2)
     self.assertEqual(model.index(0, 0).data(), 2.3)
 def test_set_array_type_converts_existing_data(self):
     model = ArrayModel()
     model.reset(Array([5.0]))
     model.set_array_type(str)
     self.assertEqual(model.rowCount(), 2)
     self.assertEqual(model.index(0, 0).data(), "5.0")
 def test_batch_set_data_on_last_row_extends_table(self):
     model = ArrayModel()
     model.reset(Array([5.0]))
     model.batch_set_data([model.index(1, 0)], ["2.3"])
     self.assertEqual(model.rowCount(), 3)
     self.assertEqual(model.index(0, 0).data(), 5.0)
 def test_batch_set_data(self):
     model = ArrayModel()
     model.reset(Array([5.0]))
     model.batch_set_data([model.index(0, 0)], ["2.3"])
     self.assertEqual(model.rowCount(), 2)
     self.assertEqual(model.index(0, 0).data(), 2.3)