def test_remove_rows(self): editor = MapEditor() editor.set_value(Map(["a"], [-1.0])) table_view = editor._ui.map_table_view table_view.selectRow(0) model = table_view.model() rect = table_view.visualRect(model.index(0, 0)) menu = MapTableContextMenu(editor, table_view, rect.center()) insert_action = _find_action(menu, "Remove rows") self.assertIsNotNone(insert_action) insert_action.trigger() self.assertEqual(model.rowCount(), 1)
def test_show_value_editor(self): editor = MapEditor() editor.set_value(Map(["a"], [-1.0])) table_view = editor._ui.map_table_view model = table_view.model() rect = table_view.visualRect(model.index(0, 0)) editor.open_value_editor = MagicMock() menu = MapTableContextMenu(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))
def test_insert_column_before(self): editor = MapEditor() editor.set_value(Map(["a"], [-1.0])) table_view = editor._ui.map_table_view table_view.selectColumn(0) model = table_view.model() rect = table_view.visualRect(model.index(0, 0)) menu = MapTableContextMenu(editor, table_view, rect.center()) insert_action = _find_action(menu, "Insert column before") self.assertIsNotNone(insert_action) insert_action.trigger() self.assertEqual(model.columnCount(), 3 + 1) self.assertEqual(model.index(0, 0).data(), None) self.assertEqual(model.index(0, 1).data(), "a") self.assertEqual(model.index(0, 2).data(), -1.0)
def test_value_access(self): editor = MapEditor() editor.set_value(Map(["A", "B"], [2.2, 2.1])) self.assertEqual(editor.value(), Map(["A", "B"], [2.2, 2.1]))