From 987e01a5e6a89cbebd1719fd92998d475638d9aa Mon Sep 17 00:00:00 2001 From: Mathias Kahl Date: Thu, 7 Aug 2014 14:55:19 +0200 Subject: [PATCH] added property Card.date_last_activity : datetime, and test for fetching card attributes (including the new datetime property) --- test/test_trello.py | 17 +++++++++++++++++ trello/__init__.py | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/test/test_trello.py b/test/test_trello.py index b9ac4701..808376c3 100644 --- a/test/test_trello.py +++ b/test/test_trello.py @@ -1,3 +1,4 @@ +from datetime import datetime from trello import TrelloClient import unittest import os @@ -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() diff --git a/trello/__init__.py b/trello/__init__.py index 365b7223..c925dc06 100644 --- a/trello/__init__.py +++ b/trello/__init__.py @@ -1,5 +1,6 @@ from datetime import datetime import json +from dateutil import parser as dateparser import requests from requests_oauthlib import OAuth1 @@ -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 @@ -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: