예제 #1
0
    def test_complete_dealers_hand(self):
        # Cards given to the player.
        players_cards = [
            Card(1, SUIT_SPADES),
            Card(2, SUIT_SPADES),
        ]
        # Cards given to the dealer.
        dealers_cards = [
            Card(3, SUIT_SPADES),
            Card(7, SUIT_SPADES),
            Card(8, SUIT_SPADES),
        ]

        deck = players_cards + dealers_cards + [
            Card(9, SUIT_SPADES),
        ]
        with patch.object(Game, 'shuffle_deck', autospec=True):
            game = Game(deck)
            game.start()
            game.complete_dealers_hand()
            dealer = game.dealer
            self.assertEqual(dealers_cards, dealer.hand.cards)
예제 #2
0
    def test_complete_dealers_hand_does_not_hit_on_hard_17(self):
        # Cards given to the player.
        players_cards = [
            Card(4, SUIT_SPADES),
            Card(5, SUIT_SPADES),
        ]
        # Cards given to the dealer.
        dealers_cards = [
            Card(10, SUIT_SPADES),
            Card(6, SUIT_SPADES),
            Card(1, SUIT_SPADES),
        ]

        deck = players_cards + dealers_cards + [
            Card(9, SUIT_SPADES),
        ]
        with patch.object(Game, 'shuffle_deck', autospec=True):
            game = Game(deck)
            game.start()
            game.complete_dealers_hand()
            dealer = game.dealer
            self.assertEqual(dealers_cards, dealer.hand.cards,
                             'Dealer must not hit on a hard 17')