summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-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()