summaryrefslogtreecommitdiff
path: root/tests/test_board.py
diff options
context:
space:
mode:
authorOlivier Gayot <olivier.gayot@sigexec.com>2020-05-16 02:11:08 +0200
committerOlivier Gayot <olivier.gayot@sigexec.com>2020-05-16 02:13:40 +0200
commit78207e912c479540c9123b2c70027775effa02db (patch)
tree7bd05623c2d60f29414ca20ba3e79decdafe0a50 /tests/test_board.py
parent0106b23a685da72e97291771d9345aa608f8b8d4 (diff)
Add unit tests for board
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'tests/test_board.py')
-rw-r--r--tests/test_board.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/test_board.py b/tests/test_board.py
new file mode 100644
index 0000000..6b0fefd
--- /dev/null
+++ b/tests/test_board.py
@@ -0,0 +1,48 @@
+import unittest
+
+from swiftstory.Board import Board
+
+
+class TestBoard(unittest.TestCase):
+ def setUp(self):
+ self.board = Board()
+
+ self.cards = [(int(i), f"Card number {i}") for i in range(10)]
+ self.players = [f"Player {i}" for i in range(10)]
+
+ def test_play_card(self):
+ self.assertEqual(len(self.board.played_cards), 0)
+ self.board.play_card(self.players[0], self.cards[0])
+ self.assertEqual(len(self.board.played_cards), 1)
+ self.board.play_card(self.players[1], self.cards[1])
+ self.assertEqual(len(self.board.played_cards), 2)
+
+ self.assertIn((self.cards[0], self.players[0]), self.board.played_cards)
+ self.assertIn((self.cards[1], self.players[1]), self.board.played_cards)
+
+ def test_pick_white_card(self):
+ with self.assertRaises(IndexError):
+ self.board.pick_white_card()
+
+ self.board.white_pick = self.cards[:2]
+
+ self.assertNotIn(self.board.pick_white_card(), self.board.white_pick)
+
+ def test_reveal_next_black_card(self):
+ self.board.current_black_card = None
+ self.board.black_recycled = list()
+ self.board.black_pick = list()
+
+ with self.assertRaises(IndexError):
+ self.board.reveal_next_black_card()
+
+ self.board.black_pick = self.cards[:5]
+
+ for i in range(10):
+ self.board.reveal_next_black_card()
+
+ self.assertIsNotNone(self.board.current_black_card)
+ self.assertNotIn(self.board.current_black_card, self.board.black_pick)
+
+ def test_shuffle_played_cards(self):
+ self.board.shuffle_played_cards()