示例#1
0
 def test_show_value_editor(self):
     editor = ArrayEditor()
     editor.set_value(Array([-1.0]))
     table_view = editor._ui.array_table_view
     model = table_view.model()
     rect = table_view.visualRect(model.index(0, 0))
     editor.open_value_editor = MagicMock()
     menu = ArrayTableContextMenu(editor, table_view, rect.center())
     open_action = _find_action(menu, "Open value editor...")
     self.assertIsNotNone(open_action)
     open_action.trigger()
     editor.open_value_editor.assert_called_once_with(model.index(0, 0))
示例#2
0
 def test_remove_rows(self):
     editor = ArrayEditor()
     editor.set_value(Array([-1.0, -2.0]))
     table_view = editor._ui.array_table_view
     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(), -2.0)
示例#3
0
 def test_remove_rows_with_time_pattern_editor(self):
     editor = TimePatternEditor()
     editor.set_value(TimePattern(["1d", "2d"], [-1.1, -2.2]))
     table_view = editor._ui.pattern_edit_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(), "2d")
     self.assertEqual(model.index(0, 1).data(), -2.2)
示例#4
0
 def test_insert_row_before(self):
     editor = ArrayEditor()
     editor.set_value(Array([-1.0]))
     table_view = editor._ui.array_table_view
     table_view.selectRow(0)
     model = table_view.model()
     rect = table_view.visualRect(model.index(0, 0))
     menu = ArrayTableContextMenu(editor, 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(), 0.0)
     self.assertEqual(model.index(1, 0).data(), -1.0)
示例#5
0
 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)