def test_set_player_best_hands(self): players = [Player(), Player()] game = Game(players) game.deal() game.deal() game.deal() game.deal() game.set_player_hands() player = game.players[0]
def test_preflop_deal_gives_each_player_2_cards(self): players = [Player(), Player(), Player()] game = Game(players) game.deal() for player in game.players: self.assertEqual(len(player.hand), 2) self.assertEqual(len(game.deck.cards), 52 - len(game.players) * 2) self.assertEqual(game.stage, Stage.PREFLOP)
def test_can_create_player(self): players = [Player(), Player()] game = Game(players) game.deal() game.deal() game.deal() game.deal() player = game.players[0] self.assertEqual(len(player.hand), 2)
def test_flop_deal_puts_3_cards_in_community(self): players = [Player(), Player(), Player()] game = Game(players) game.deal() game.deal() for player in game.players: self.assertEqual(len(player.hand), 2) # Deck length is less the initial deal minus 3 community - 1 burn self.assertEqual(len(game.deck.cards), 52 - len(game.players) * 2 - 3 - 1) self.assertEqual(game.stage, Stage.FLOP)
def test_passing_blank_list_returns_full_community(self): flop_cards = [] players = [Player(), Player()] game = Game(players, flop_cards=flop_cards) self.assertEqual(len(game.deck.cards), 52) self.assertEqual(len(game.flop_cards), 0) game.deal() game.deal() game.deal() game.deal() self.assertEqual(len(game.community), 5)
def test_passed_flop_cards_removed_from_deck_one_card(self): flop_cards = ['D4'] players = [Player(), Player()] game = Game(players, flop_cards=flop_cards) self.assertEqual(len(game.deck.cards), 52 - 1) self.assertEqual(len(game.flop_cards), 1) game.deal() game.deal() game.deal() game.deal() self.assertEqual(len(game.community), 5) self.assertTrue('D4' == repr(game.community[0]))
def test_passed_flop_cards_removed_from_deck_two_cards(self): flop_cards = ['D4', 'C14'] players = [Player(), Player()] game = Game(players, flop_cards=flop_cards) self.assertEqual(len(game.deck.cards), 52 - 2) self.assertEqual(len(game.flop_cards), 2) game.deal() game.deal() game.deal() game.deal() self.assertEqual(len(game.community), 5) self.assertTrue( 'D4' in [repr(game.community[0]), repr(game.community[1])]) self.assertTrue( 'C14' in [repr(game.community[0]), repr(game.community[1])])
def test_deal_maintains_player_start_hands(self): user_hand = ['D4', 'C14'] other_hand = [['D13', 'C13']] player1 = Player(is_user=True, starting_hand=user_hand) player2 = Player(starting_hand=other_hand[0]) players = [player1, player2] game = Game(players) game.deal() self.assertTrue( repr(player1.hand[0]) in [player1.starting_hand[0], player1.starting_hand[1]]) self.assertTrue( repr(player1.hand[1]) in [player1.starting_hand[0], player1.starting_hand[1]]) self.assertTrue( repr(player2.hand[0]) in [player2.starting_hand[0], player2.starting_hand[1]]) self.assertTrue( repr(player2.hand[1]) in [player2.starting_hand[0], player2.starting_hand[1]])
def test_passed_turn_card_is_in_community(self): turn_card = 'D4' players = [Player(), Player()] game = Game(players, turn_card=turn_card) game.deal() game.deal() self.assertEqual(len(game.community), 3) game.deal() self.assertEqual(len(game.community), 4) game.deal() self.assertEqual(len(game.community), 5) self.assertEqual(turn_card, repr(game.turn_card)) self.assertEqual(repr(game.community[3]), 'D4')
def test_passed_flop_cards_are_in_community(self): flop_cards = ['D4', 'C14', 'D13'] players = [Player(), Player()] game = Game(players, flop_cards=flop_cards) game.deal() game.deal() self.assertEqual(len(game.community), 3) game.deal() self.assertEqual(len(game.community), 4) game.deal() self.assertEqual(len(game.community), 5) self.assertEqual(3, len(game.flop_cards)) self.assertTrue(repr(game.community[0]) in flop_cards) self.assertTrue(repr(game.community[1]) in flop_cards) self.assertTrue(repr(game.community[2]) in flop_cards)