From 69c051d32f7a8eb2534fafe9da652816ace2120f Mon Sep 17 00:00:00 2001 From: Frederic Lepied Date: Thu, 25 Dec 2014 10:43:46 +0100 Subject: [PATCH] added the delete method on Checklist --- test/test_trello.py | 32 ++++++++++++++++++++++++++++++-- trello/__init__.py | 6 ++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/test/test_trello.py b/test/test_trello.py index 8c2c64e2..c306a8e2 100644 --- a/test/test_trello.py +++ b/test/test_trello.py @@ -2,7 +2,6 @@ from trello import TrelloClient import unittest import os -import datetime class TrelloClientTestCase(unittest.TestCase): @@ -176,6 +175,35 @@ def test42_add_card_with_comments(self): if not card: self.fail("No card created") + def test43_delete_checklist(self): + boards = self._trello.list_boards() + for b in boards: + if b.name != os.environ['TRELLO_TEST_BOARD_NAME']: + continue + + for l in b.open_lists(): + try: + name = "Card with comments" + card = l.add_card(name) + card.fetch(True) + except Exception as e: + print(str(e)) + self.fail("Caught Exception adding card") + + self.assertIsNotNone(card, msg="card is None") + name = 'Checklists' + checklist = card.add_checklist(name, + ['item1', 'item2']) + self.assertIsNotNone(checklist, msg="checklist is None") + self.assertIsNotNone(checklist.id, msg="id not provided") + self.assertEquals(checklist.name, name) + checklist.delete() + card.delete() + break + break + if not card: + self.fail("No card created") + def test52_get_cards(self): boards = [board for board in self._trello.list_boards() if board.name == os.environ['TRELLO_TEST_BOARD_NAME']] @@ -223,7 +251,7 @@ def test52_add_card_set_due(self): self.fail("Caught Exception adding card") # Set the due date to be 3 days from now - today = datetime.datetime.today() + today = datetime.today() day_detla = datetime.timedelta(3) due_date = today + day_detla # card.set_due(due_date) diff --git a/trello/__init__.py b/trello/__init__.py index 0cfdf581..80ed0d21 100644 --- a/trello/__init__.py +++ b/trello/__init__.py @@ -839,6 +839,12 @@ def rename_checklist_item(self, name, new_name): self.items[ix] = json_obj return json_obj + def delete(self): + """Removes this checklist""" + self.client.fetch_json( + '/checklists/%s' % self.id, + http_method='DELETE') + def __repr__(self): return '' % self.id