def test_A_has_values_1_and_11(self):
        deck = PokerCardsDeck()

        card = deck.draw_card()
        while card.name is not "A":
            card = deck.draw_card()

        self.assertIn(1, card.value)
        self.assertIn(11, card.value)
    def test_raises_exception_after_52_cards(self):
        deck = PokerCardsDeck()

        for _ in range(52):
            self.assertIsInstance(deck.draw_card(), Card)

        with self.assertRaisesRegex(Exception,
                                    "No more cards remain in the Deck."):
            deck.draw_card()
    def test_returns_4_cards_of_each_type(self):
        deck = PokerCardsDeck()
        counter = Counter()

        for _ in range(52):
            card_name = deck.draw_card().name
            counter[card_name] += 1

        card_frequencies = counter.values()
        self.assertEqual(max(card_frequencies), 4)
        self.assertEqual(min(card_frequencies), 4)
    def test_cards_remaining(self):
        deck = PokerCardsDeck()
        for _ in range(51):
            deck.draw_card()

        self.assertTrue(deck.cards_remain())
        deck.draw_card()
        self.assertFalse(deck.cards_remain())
Esempio n. 5
0
    def test_play_game_at_least_two_cards_per_player(self):
        players = self.setup_players(num_of_players=8, want_cards=False)
        game = BlackjackGame(shuffled_deck=PokerCardsDeck(), players=players)

        all_player_hands = game.play_game()

        for hand in all_player_hands:
            self.assertTrue(len(hand) >= 2)
Esempio n. 6
0
    def test_play_game_each_player_plays(self):
        players = self.setup_players(4, want_cards=True)
        game = BlackjackGame(shuffled_deck=PokerCardsDeck(), players=players)

        game.play_game()

        for player in players:
            player.wants_new_card.assert_called_with()
            player.accept_card.assert_called()
    def test_not_every_new_deck_equal(self):
        """
        This test goes through two decks and checks whether both decks have the
        same cards in the same order. In that case, the test fails.
        :return: None
        """
        random.seed(0)

        deck1 = PokerCardsDeck()
        deck2 = PokerCardsDeck()

        equal_order = True
        for _ in range(52):
            equal_order &= equal_order and (deck1.draw_card().name
                                            == deck2.draw_card().name)

        self.assertFalse(equal_order)
Esempio n. 8
0
    def test_deals_no_more_cards_than_deck_has(self):
        players = self.setup_players(num_of_players=100, want_cards=True)
        game = BlackjackGame(shuffled_deck=PokerCardsDeck(), players=players)

        self.assertRaises(Exception, game.play_game)