Skip to content

Commit

Permalink
added test for closed cards, fixed tests for python3(except test_dele…
Browse files Browse the repository at this point in the history
…te_cards)
  • Loading branch information
t0ffel committed Feb 11, 2016
1 parent ce00a32 commit c7e8f08
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions test/test_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def _add_card(self, name, description=None):
card = self._list.add_card(name, description)
self.assertIsNotNone(card, msg="card is None")
self.assertIsNotNone(card.id, msg="id not provided")
self.assertEquals(card.name, name)
self.assertEqual(card.name, name.encode('utf-8'))
return card
except Exception as e:
print(str(e))
Expand All @@ -50,7 +50,7 @@ def test_get_cards(self):
self.assertEquals(len(cards), len(self._board.open_cards()))

for card in cards:
self.assertTrue(card.name in names, 'Unexpected card found')
self.assertTrue(card.name.decode('utf-8') in names, 'Unexpected card found')

self.assertIsInstance(self._board.all_cards(), list)
self.assertIsInstance(self._board.open_cards(), list)
Expand All @@ -67,6 +67,18 @@ def test_delete_cards(self):
card.delete()
self.assertEquals(len(self._board.closed_cards()), nb_deleted_cards + nb_open_cards)

def test_close_cards(self):
nb_closed_cards = len(self._board.closed_cards())
self._add_card("card to be closed")
cards = self._board.open_cards()
nb_open_cards = len(cards)
for card in cards:
card.set_closed(True)
cards_after = self._board.closed_cards()
nb_cards_after = len(cards_after)
self.assertEquals(nb_cards_after, nb_closed_cards + nb_open_cards)


def test_all_cards_reachable(self):
if not len(self._board.open_cards()):
self._add_card("an open card")
Expand Down Expand Up @@ -108,27 +120,27 @@ def test100_add_board(self):
test_list = test_board.add_list("test_list")
test_list.add_card("test_card")
open_boards = self._trello.list_boards(board_filter="open")
self.assertEqual(len([x for x in open_boards if x.name == "test_create_board"]), 1)
self.assertEqual(len([x for x in open_boards if x.name == "test_create_board".encode('utf-8')]), 1)

def test110_copy_board(self):
boards = self._trello.list_boards(board_filter="open")
source_board = next( x for x in boards if x.name == "test_create_board")
source_board = next( x for x in boards if x.name == "test_create_board".encode('utf-8'))
self._trello.add_board("copied_board", source_board=source_board)
listed_boards = self._trello.list_boards(board_filter="open")
copied_board = next(iter([x for x in listed_boards if x.name == "copied_board"]), None)
copied_board = next(iter([x for x in listed_boards if x.name == "copied_board".encode('utf-8')]), None)
self.assertIsNotNone(copied_board)
open_lists = copied_board.open_lists()
self.assertEqual(len(open_lists), 4) # default lists plus mine
test_list = open_lists[0]
self.assertEqual(len(test_list.list_cards()), 1)
test_card = next ( iter([ x for x in test_list.list_cards() if x.name == "test_card"]), None )
test_card = next ( iter([ x for x in test_list.list_cards() if x.name == "test_card".encode('utf-8')]), None )
self.assertIsNotNone(test_card)

def test120_close_board(self):
boards = self._trello.list_boards(board_filter="open")
open_count = len(boards)
test_create_board = next( x for x in boards if x.name == "test_create_board") # type: Board
copied_board = next( x for x in boards if x.name == "copied_board") # type: Board
test_create_board = next( x for x in boards if x.name == "test_create_board".encode('utf-8')) # type: Board
copied_board = next( x for x in boards if x.name == "copied_board".encode('utf-8')) # type: Board
test_create_board.close()
copied_board.close()
still_open_boards = self._trello.list_boards(board_filter="open")
Expand Down

0 comments on commit c7e8f08

Please sign in to comment.