Skip to content

Commit

Permalink
added property Card.date_last_activity : datetime, and test for fetch…
Browse files Browse the repository at this point in the history
…ing card attributes (including the new datetime property)
  • Loading branch information
Mathias Kahl committed Aug 7, 2014
1 parent 03e7a27 commit 987e01a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/test_trello.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from trello import TrelloClient
import unittest
import os
Expand Down Expand Up @@ -74,6 +75,22 @@ def test40_list_cards(self):
break
pass

def test41_fetch_cards(self):
"""
Tests fetching all attributes for all cards
"""
boards = self._trello.list_boards()
for b in boards:
for l in b.all_lists():
for c in l.list_cards():
c.fetch()

self.assertIsInstance(c.date_last_activity, datetime, msg='date not provided')
self.assertTrue(len(c.board_id) > 0, msg='board id not provided')
break
break
pass


def test50_add_card(self):
boards = self._trello.list_boards()
Expand Down
6 changes: 6 additions & 0 deletions trello/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from datetime import datetime
import json
from dateutil import parser as dateparser
import requests
from requests_oauthlib import OAuth1

Expand Down Expand Up @@ -450,6 +451,10 @@ def board_id(self):
def description(self):
return self.desc

@property
def date_last_activity(self) -> datetime:
return self._dateLastActivity

@description.setter
def description(self, value):
self.desc = value
Expand Down Expand Up @@ -484,6 +489,7 @@ def fetch(self):
self.badges = json_obj['badges']
self.due = json_obj['due']
self.checked = json_obj['checkItemStates']
self._dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])

self.checklists = []
if self.badges['checkItems'] > 0:
Expand Down

0 comments on commit 987e01a

Please sign in to comment.