From 05baa7da268437edfc1db104ac59a0e1b821874f Mon Sep 17 00:00:00 2001 From: Giulio Fidente Date: Tue, 11 Dec 2018 17:35:42 +0100 Subject: [PATCH 1/2] Add commentCard to trello DEFAULT_FILTERS It is not sufficient to customize the trello plugin 'filters' to make it display the commentCard objects too, because there is no mapping for such a card action into a python class. This change updates the DEFAULT_FILTERS list to include commentCard and adds the matching filter_map item. --- did/plugins/trello.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/did/plugins/trello.py b/did/plugins/trello.py index c38bd984..9df3dadb 100644 --- a/did/plugins/trello.py +++ b/did/plugins/trello.py @@ -49,7 +49,7 @@ from did.stats import Stats, StatsGroup DEFAULT_FILTERS = [ - "createCard", "updateCard", + "commentCard", "createCard", "updateCard", "updateCard:idList", "updateCard:closed", "updateCheckItemStateOnCard"] @@ -256,6 +256,7 @@ def __init__(self, option, name=None, parent=None, user=None): 'Boards': {}, 'Lists': {}, 'Cards': { + 'commentCard': TrelloCards, 'updateCard': TrelloCards, 'updateCard:closed': TrelloCardsClosed, 'updateCard:idList': TrelloCardsMoved, From 55326c5817513d2c2f1dd37839557cf6fefb79cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20=C5=A0pl=C3=ADchal?= Date: Wed, 19 Dec 2018 11:18:08 +0100 Subject: [PATCH 2/2] Fix commented cards title, improve the test suite Introduced a new class to correctly name the commented cards section. Created a new public test board for Did Tester and extended tests to cover commented cards as well. --- did/plugins/trello.py | 22 ++++++++++++++++++--- tests/plugins/test_trello.py | 37 ++++++++++++++++++++++-------------- 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/did/plugins/trello.py b/did/plugins/trello.py index 9df3dadb..b7ba68d7 100644 --- a/did/plugins/trello.py +++ b/did/plugins/trello.py @@ -149,7 +149,7 @@ def fetch(self): # Trello updateCard # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class TrelloCards(TrelloStats): +class TrelloCardsUpdated(TrelloStats): """ Trello cards updated""" def fetch(self): @@ -165,6 +165,22 @@ def fetch(self): self.stats = sorted(list(set(actions))) +class TrelloCardsCommented(TrelloStats): + """ Trello cards commented""" + + def fetch(self): + log.info( + "Searching for cards commented in %s by %s", + self.parent.option, self.user) + actions = [ + act['data']['card']['name'] + for act in self.trello.get_actions( + filters=self.filt, + since=self.options.since.date, + before=self.options.until.date)] + self.stats = sorted(list(set(actions))) + + # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # Trello updateCard:closed # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -256,8 +272,8 @@ def __init__(self, option, name=None, parent=None, user=None): 'Boards': {}, 'Lists': {}, 'Cards': { - 'commentCard': TrelloCards, - 'updateCard': TrelloCards, + 'commentCard': TrelloCardsCommented, + 'updateCard': TrelloCardsUpdated, 'updateCard:closed': TrelloCardsClosed, 'updateCard:idList': TrelloCardsMoved, 'createCard': TrelloCardsCreated}, diff --git a/tests/plugins/test_trello.py b/tests/plugins/test_trello.py index 895db3b4..22235c5b 100644 --- a/tests/plugins/test_trello.py +++ b/tests/plugins/test_trello.py @@ -1,6 +1,5 @@ -# -*- coding: utf-8 -*- -# @Author: Eduard Trott -# Test Board: https://trello.com/b/sH1cMiyg/public-test-board +# coding: utf-8 +# Test Board: https://trello.com/b/YcOfywBd/did-testing """ Tests for the Trello plugin """ @@ -14,14 +13,14 @@ # Constants # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -INTERVAL = "--since 2015-10-01 --until 2015-10-03" +INTERVAL = "--since 2018-12-19 --until 2018-12-19" CONFIG = """ [general] -email = "Eduard Trott" +email = "Did Tester" [trello] type = trello -user = maybelinot +user = didtester """ @@ -35,7 +34,7 @@ def test_trello_cards_created(): stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[0].stats print stats assert any([ - "Card2" in unicode(stat) for stat in stats]) + "CreatedCard" in unicode(stat) for stat in stats]) def test_trello_cards_updated(): @@ -44,7 +43,7 @@ def test_trello_cards_updated(): stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[1].stats print stats assert any([ - "Card4" + "UpdatedCard" in unicode(stat) for stat in stats]) @@ -54,32 +53,42 @@ def test_trello_cards_closed(): stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[2].stats print stats assert any([ - "Archived Card: closed" + "ClosedCard: closed" + in unicode(stat) for stat in stats]) + + +def test_trello_cards_commented(): + """ Commented cards """ + did.base.Config(CONFIG) + stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[3].stats + print stats + assert any([ + "CommentedCard" in unicode(stat) for stat in stats]) def test_trello_cards_moved(): """ Moved cards """ did.base.Config(CONFIG) - stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[3].stats + stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[4].stats print stats assert any([ - "[Card3] moved from [List1] to [List3]" + "[MovedCard] moved from [new] to [active]" in unicode(stat) for stat in stats]) def test_trello_checklists_checkitem(): """ Completed Checkitems in checklists """ did.base.Config(CONFIG) - stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[4].stats + stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[5].stats print stats # print[unicode(stat) for stat in stats] assert any([ - "Card1: CheckItem3" + "ChecklistCard: CheckItem" in unicode(stat) for stat in stats]) -def test_trello_missing_apikey(): +def test_trello_missing_username(): """ Missing username """ did.base.Config("[trello]\ntype = trello") with pytest.raises(did.base.ReportError):