blob: 6b0fefd77bcc8face1f3864244d869f9de686d15 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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()
|