def test_data(self): model = TimeSeriesModelVariableResolution( TimeSeriesVariableResolution( ["2019-07-05T12:00", "2019-07-21T08:15"], [-5.0, 7.0], True, False)) for role in [Qt.DisplayRole, Qt.EditRole]: model_index = model.index(0, 0) self.assertEqual(model.data(model_index, role), "2019-07-05T12:00:00") model_index = model.index(0, 1) self.assertEqual(model.data(model_index, role), -5.0)
def test_batch_set_data(self): model = TimeSeriesModelVariableResolution( TimeSeriesVariableResolution( ["2019-07-05T12:00", "2019-07-21T08:15", "2019-07-23T09:10"], [2.3, -5.0, 7.0], True, False)) indexes = [model.index(0, 0), model.index(1, 1), model.index(2, 1)] values = ["2018-07-05T12:00", 55.5, -55.5] model.batch_set_data(indexes, values) expected = TimeSeriesVariableResolution( ["2018-07-05T12:00", "2019-07-21T08:15", "2019-07-23T09:10"], [2.3, 55.5, -55.5], True, False) self.assertEqual(model.value, expected)
def test_flags(self): model = TimeSeriesModelVariableResolution( TimeSeriesVariableResolution( ["2019-07-05T12:00", "2019-07-21T08:15"], [-5.0, 7.0], True, False)) for row in range(2): for column in range(2): model_index = model.index(row, column) self.assertEqual( model.flags(model_index), Qt.ItemIsSelectable | Qt.ItemIsEnabled | Qt.ItemIsEditable)
def test_setData(self): model = TimeSeriesModelVariableResolution( TimeSeriesVariableResolution( ["1991-01-01T13:30", "1992-01-01T13:30"], [2.3, -5.0], True, False)) model_index = model.index(0, 1) model.setData(model_index, -4.0) self.assertEqual( model.value, TimeSeriesVariableResolution( ["1991-01-01T13:30", "1992-01-01T13:30"], [-4.0, -5.0], True, False), )