Exemplo n.º 1
0
 def test_hit(self):
     hand = Hand(60)
     player = Player("Foo", 100)
     game = SingleDeck([player])
     deck = Deck.create(1)
     game.get_card = Mock(return_value=deck.get_card())
     hand.hit(game)
     assert len(hand.cards) == 1
Exemplo n.º 2
0
 def test_can_do_split(self):
     hand = Hand(60)
     deck = Deck.create(1)
     while (len(hand.cards) < 2 and not deck.is_empty()):
         card = deck.get_card()
         if card.value > 9:
             hand.add_card(card)
     assert hand.can_do_split()
Exemplo n.º 3
0
 def test_is_empty(self):
     deck = Deck.create(1)
     cards = list(deck.deck)
     assert not deck.is_empty()
     try:
         while True:
             deck.get_card()
     except:
         assert deck.is_empty()
Exemplo n.º 4
0
    def test_get_score(self):
        hand = Hand(60)
        deck = Deck.create(1)
        card1 = deck.get_card()
        card2 = deck.get_card()
        hand.add_card(card1)
        hand.add_card(card2)

        assert hand.get_score() == card1.value + card2.value
Exemplo n.º 5
0
 def test_cards(self):
     hand = Hand()
     deck = Deck.create(1)
     card = deck.get_card()
     card.hidden = True
     hand.add_card(card)
     hand.add_card(deck.get_card())
     assert any([card.hidden for card in hand.cards])
     hand.reveal()
     assert all([not card.hidden for card in hand.cards])
Exemplo n.º 6
0
 def test_split(self):
     hand = Hand(60)
     assert hand.bet == 60
     deck = Deck.create(1)
     card1 = deck.get_card()
     card2 = deck.get_card()
     hand.add_card(card1)
     hand.add_card(card2)
     player = Player("Foo", 100)
     game = Game([player])
     new_hand = hand.split(game)
     assert len(hand.cards) == 1
     assert hand.cards[0] == card1
     assert hand.bet == 30
     assert len(new_hand.cards) == 1
     assert new_hand.cards[0] == card2
     assert new_hand.bet == 30
Exemplo n.º 7
0
 def test_shuffle(self):
     deck = Deck.create(1)
     cards = list(deck.deck)
     deck.shuffle()
     assert cards[0] != deck.deck[0]