Skip to content

Commit

Permalink
Merge 3392238 into ee33b2f
Browse files Browse the repository at this point in the history
  • Loading branch information
calmrat committed Oct 5, 2015
2 parents ee33b2f + 3392238 commit 4eefed6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
19 changes: 12 additions & 7 deletions did/plugins/trello.py
Expand Up @@ -18,7 +18,8 @@
Optional arguments::
board_links = g9mdhdzg
filters = updateCheckItemStateOnCard,updateCard
filters = updateCheckItemStateOnCard, updateCard, updateCard:closed,
updateCard:idList, createCard
apikey
https://trello.com/app-key
Expand Down Expand Up @@ -46,6 +47,9 @@
from did.utils import log, pretty, listed
from did.stats import Stats, StatsGroup

DEFAULT_FILTERS = ('updateCheckItemStateOnCard, updateCard, updateCard:closed,'
' updateCard:idList, createCard')


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Trello Stats
Expand Down Expand Up @@ -131,7 +135,7 @@ def fetch(self):
"Searching for cards created in %s by %s",
self.parent.option, self.user)
actions = [
"{0} was created".format(act['data']['card']['name'])
act['data']['card']['name']
for act in self.trello.get_actions(
filters=self.filt,
since=self.options.since.date,
Expand All @@ -144,7 +148,7 @@ def fetch(self):
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class TrelloCards(TrelloStats):
""" Trello cards """
""" Trello cards updated"""

def fetch(self):
log.info(
Expand Down Expand Up @@ -196,7 +200,7 @@ def fetch(self):
"Searching for cards moved in %s by %s",
self.parent.option, self.user)
actions = [
"{0} moved from {1} to {2}".format(
"[{0}] moved from [{1}] to [{2}]".format(
act['data']['card']['name'],
act['data']['listBefore']['name'],
act['data']['listAfter']['name'])
Expand All @@ -213,7 +217,7 @@ def fetch(self):
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

class TrelloCheckItem(TrelloStats):
""" Trello cards """
""" Trello checklist item completed"""

def fetch(self):
log.info(
Expand Down Expand Up @@ -256,7 +260,7 @@ def __init__(self, option, name=None, parent=None, user=None):
'createCard': TrelloCardsCreated},
'Checklists': {
'updateCheckItemStateOnCard': TrelloCheckItem}
}
}
self._session = None
self.url = "https://trello.com/1"
config = dict(Config().section(option))
Expand All @@ -279,7 +283,8 @@ def __init__(self, option, name=None, parent=None, user=None):
else:
trello = TrelloAPI(stats=self, config=config)

filters = [filt.strip() for filt in config['filters'].split(',')]
_filters = config.get('filters') or DEFAULT_FILTERS
filters = [filt.strip() for filt in _filters.split(',')]
for filt_group in filter_map.keys():
for filt in filter_map[filt_group].keys():
if filters != [""] and filt not in filters:
Expand Down
6 changes: 3 additions & 3 deletions tests/plugins/test_trello.py
Expand Up @@ -35,7 +35,7 @@ def test_trello_cards_created():
stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[0].stats
print stats
assert any([
"Card1 was created" in unicode(stat) for stat in stats])
"Card2" in unicode(stat) for stat in stats])


def test_trello_cards_updated():
Expand All @@ -44,7 +44,7 @@ def test_trello_cards_updated():
stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[1].stats
print stats
assert any([
"Card3"
"Card4"
in unicode(stat) for stat in stats])


Expand All @@ -64,7 +64,7 @@ def test_trello_cards_moved():
stats = did.cli.main(INTERVAL)[0][0].stats[0].stats[3].stats
print stats
assert any([
"Card3 moved from List1 to List3"
"[Card3] moved from [List1] to [List3]"
in unicode(stat) for stat in stats])


Expand Down

0 comments on commit 4eefed6

Please sign in to comment.