def delete_gpx_clicked(self, curr_index): if curr_index > -1: self.stack_redo.clear() datalist = self.gpxs command = RmCommand(curr_index, datalist, "gpx") command.execute() self.presenter.update_gpx_table() self.stack_undo.append(command)
def delete_points_clicked(self, gpx_index, curr_index): if gpx_index > -1 and curr_index > -1: self.stack_redo.clear() datalist = self.get_gpx(gpx_index) command = RmCommand(curr_index, datalist.track.track_segment, "points") command.execute() self.presenter.update_points_table() self.stack_undo.append(command)
def test_delete_from_empty(self): index = 1 cmnd = RmCommand(index, self.default_data, "points") flag = True try: cmnd.execute() flag = False except: flag = True if not flag: self.assertEqual(1, 0)
def test_single_point_delete(self): self.setUp() index = 1 benchmark_list = deepcopy(self.default_data) cmnd = RmCommand(index, self.default_data, "points") cmnd.execute() del benchmark_list[index] self.assertTrue(len(benchmark_list) == len(self.default_data)) for i in range(len(benchmark_list)): cond = benchmark_list[i] == self.default_data[i] self.assertTrue(cond)
def test_multiple_gpx_delete(self): self.setUp() index1 = 2 index2 = 0 benchmark_list = deepcopy(self.default_data) cmnd = RmCommand(index1, self.default_data, "gpx") cmnd.execute() cmnd = RmCommand(index2, self.default_data, "gpx") cmnd.execute() del benchmark_list[index1] del benchmark_list[index2] self.assertCountEqual(benchmark_list, self.default_data) for i in range(len(benchmark_list)): cond = benchmark_list[i] == self.default_data[i] self.assertTrue(cond)