def test_sum_rows_when_double_click(self): # given mapList4 = [{ "a": 1, "b": 2, "c": 3 }, { "a": 4, "b": 5, "c": 6 }, { "a": 7, "b": 8, "c": 5 }] tabledisplay = TableDisplay(mapList4) def dclick(row, column, table): table.values[row][column] = sum(map(int, table.values[row])) tabledisplay.setDoubleClickAction(dclick) param = {'event': 'DOUBLE_CLICK', 'row': 0, 'column': 0} # when tabledisplay.handle_msg(tabledisplay, param, []) # then values = tabledisplay.chart.values self.assertEqual(values[0][0], 6)
def test_negate_when_context_menu_item_event(self): # given mapList4 = [{ "a": 1, "b": 2, "c": 3 }, { "a": 4, "b": 5, "c": 6 }, { "a": 7, "b": 8, "c": 5 }] tabledisplay = TableDisplay(mapList4) def negate(row, column, table): table.values[row][column] = -1 * int(table.values[row][column]) tabledisplay.addContextMenuItem("negate", negate) param = { 'event': 'CONTEXT_MENU_CLICK', 'itemKey': 'negate', 'row': 1, 'column': 1 } # when tabledisplay.handle_msg(tabledisplay, param, []) # then values = tabledisplay.chart.values self.assertEqual(values[1][1], -5)