Skip to content

Commit

Permalink
Changed the due_date format in Card
Browse files Browse the repository at this point in the history
YYYY-MM-DD was the chosen format due to the original intention
observed in def set_due, which was different from 'self.due' assignment
in Card.fetch.  For practical reasons, YYYY-MM-DD was chosen.

- Due date of Card is in YYYY-MM-DD format.
- Extra test case was added for set_due on a card.
  • Loading branch information
kennethzfeng committed May 9, 2014
1 parent 082135d commit 39f9084
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
32 changes: 32 additions & 0 deletions test/test_trello.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from trello import TrelloClient
import unittest
import os
import datetime

class TrelloClientTestCase(unittest.TestCase):

Expand Down Expand Up @@ -126,6 +127,37 @@ def test51_add_card(self):
if not card:
self.fail("No card created")

def test52_add_card_set_due(self):
boards = self._trello.list_boards()
board_id = None
for b in boards:
if b.name != os.environ['TRELLO_TEST_BOARD_NAME']:
continue

for l in b.open_lists():
try:
name = "Testing from Python"
description = "Description goes here"
card = l.add_card(name, description)
except Exception as e:
print str(e)
self.fail("Caught Exception adding card")

# Set the due date to be 3 days from now
today = datetime.datetime.today()
day_detla = datetime.timedelta(3)
due_date = today + day_detla #
card.set_due(due_date)
expected_due_date = card.due
# Refresh the due date from cloud
card.fetch()
actual_due_date = card.due[:10]
self.assertEquals(expected_due_date, actual_due_date)
break
break
if not card:
self.fail("No card created")

def suite():
tests = ['test01_list_boards', 'test10_board_attrs', 'test20_add_card']
return unittest.TestSuite(map(TrelloClientTestCase, tests))
Expand Down
3 changes: 2 additions & 1 deletion trello/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ def fetch(self):
self.idBoard = json_obj['idBoard']
self.labels = json_obj['labels']
self.badges = json_obj['badges']
self.due = json_obj['due']
# For consistency, due date is in YYYY-MM-DD format
self.due = json_obj.get('due', '')[:10]
self.checked = json_obj['checkItemStates']

self.checklists = []
Expand Down

0 comments on commit 39f9084

Please sign in to comment.