def test_initial_value(self): editor = TimeSeriesFixedResolutionEditor() value = editor.value() self.assertEqual( value, TimeSeriesFixedResolution("2000-01-01T00:00", "1 hour", [0.0, 0.0], False, False))
def test_value_access(self): editor = TimeSeriesFixedResolutionEditor() editor.set_value( TimeSeriesFixedResolution("1996-04-06T16:06", "3 days", [4.0, 3.5, 3.0], True, True)) self.assertEqual( editor.value(), TimeSeriesFixedResolution("1996-04-06T16:06", "3 days", [4.0, 3.5, 3.0], True, True))
def test_remove_rows_with_time_series_fixed_resolution_editor(self): editor = TimeSeriesFixedResolutionEditor() editor.set_value(TimeSeriesFixedResolution("2020-11-11T14:25", "1D", [-1.1, -2.2], False, False)) table_view = editor._ui.time_series_table table_view.selectRow(0) model = table_view.model() rect = table_view.visualRect(model.index(0, 0)) menu = ArrayTableContextMenu(editor, table_view, rect.center()) remove_action = _find_action(menu, "Remove rows") self.assertIsNotNone(remove_action) remove_action.trigger() self.assertEqual(model.rowCount(), 1 + 1) self.assertEqual(model.index(0, 0).data(), "2020-11-11T14:25:00") self.assertEqual(model.index(0, 1).data(), -2.2)
def test_insert_row_before_with_time_series_fixed_resolution_editor(self): editor = TimeSeriesFixedResolutionEditor() editor.set_value(TimeSeriesFixedResolution("2020-11-11T14:25", "1D", [-1.1], False, False)) table_view = editor._ui.time_series_table table_view.selectRow(0) model = table_view.model() rect = table_view.visualRect(model.index(0, 0)) menu = IndexedValueTableContextMenu(table_view, rect.center()) insert_action = _find_action(menu, "Insert row before") self.assertIsNotNone(insert_action) insert_action.trigger() self.assertEqual(model.rowCount(), 2 + 1) self.assertEqual(model.index(0, 0).data(), "2020-11-11T14:25:00") self.assertEqual(model.index(0, 1).data(), 0.0) self.assertEqual(model.index(1, 0).data(), "2020-11-12T14:25:00") self.assertEqual(model.index(1, 1).data(), -1.1)