diff --git a/test/test_trello.py b/test/test_trello.py index 8de4056a..ee6f5b64 100644 --- a/test/test_trello.py +++ b/test/test_trello.py @@ -252,6 +252,21 @@ def test54_set(self): self.assertEquals(card.name, name) self.assertEquals(card.description, description) + def test55_set_pos(self): + card_names = lambda: [c.name for c in self._list.list_cards()] + self._list.add_card('card1') + card2 = self._list.add_card('card2') + names = card_names() + self.assertGreater(names.index('card2'), names.index('card1')) + + card2.set_pos('top') + names = card_names() + self.assertGreater(names.index('card1'), names.index('card2')) + + card2.set_pos('bottom') + names = card_names() + self.assertGreater(names.index('card2'), names.index('card1')) + def test60_delete_cards(self): cards = self._board.get_cards() for card in cards: diff --git a/trello/__init__.py b/trello/__init__.py index 0fe4497b..33e3d3ae 100644 --- a/trello/__init__.py +++ b/trello/__init__.py @@ -670,6 +670,7 @@ def fetch(self, eager=True): self.idBoard = json_obj['idBoard'] self.labels = json_obj['labels'] self.badges = json_obj['badges'] + self.pos = json_obj['pos'] # For consistency, due date is in YYYY-MM-DD format if json_obj.get('due', ''): self.due = json_obj.get('due', '')[:10] @@ -695,7 +696,7 @@ def get_comments(self): '/cards/' + self.id + '/actions', query_params={'filter': 'commentCard'}) return comments - + def fetch_checklists(self): checklists = [] json_obj = self.client.fetch_json( @@ -788,6 +789,15 @@ def set_due(self, due): self._set_remote_attribute('due', datestr) self.due = datestr + def set_pos(self, pos): + """ + Update card position in list + + :pos: 'top', 'bottom' or int + """ + self._set_remote_attribute('pos', pos) + self.pos = pos + def set_closed(self, closed): self._set_remote_attribute('closed', closed) self.closed = closed