From c7e8f089372a156ba667f7bbc76c6b7fc6073fc3 Mon Sep 17 00:00:00 2001 From: Anton Sherkhonov Date: Thu, 11 Feb 2016 20:54:57 +0000 Subject: [PATCH] added test for closed cards, fixed tests for python3(except test_delete_cards) --- test/test_board.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/test/test_board.py b/test/test_board.py index 7400307b..60731313 100644 --- a/test/test_board.py +++ b/test/test_board.py @@ -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)) @@ -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) @@ -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") @@ -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")