Skip to content

Commit

Permalink
added the delete method on Checklist
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericlepied committed Dec 25, 2014
1 parent e58b4f6 commit 69c051d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
32 changes: 30 additions & 2 deletions test/test_trello.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from trello import TrelloClient
import unittest
import os
import datetime


class TrelloClientTestCase(unittest.TestCase):
Expand Down Expand Up @@ -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']]
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions trello/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<Checklist %s>' % self.id

Expand Down

0 comments on commit 69c051d

Please sign in to comment.