def test_Table_get_active_players(self): """Test Table.get_active_players() method.""" players = [ Player(stack=100), Player(stack=100), Player(stack=100), Player(stack=0) ] table = Table(players=players) active_players = table.get_active_players() # players[3] shouldn't be in players since they are sitting out # with stack == 0 self.assertIsNotNone(active_players) self.assertEqual(len(active_players), 3) self.assertNotIn(players[3], active_players)
def test_Game_play_hand(self): """Test Game.play_hand() method""" players = [ Player(name="Player One", stack=1000) ] table = Table(players = players) self.assertEqual(len(table.get_active_players()), 1) structure = Structure(Structure.LIMIT, ante=5, blinds=[10]) game = Game(table, structure, console=self.console) # Trying to play a hand with only one player should be an exception with self.assertRaises(PokerGameStateException): game.play_hand() table.seat_players([ Player(name="Player Two", stack=1000), Player(name="Player Three", stack=1000) ]) self.assertEqual(len(table.get_active_players()), 3) hand_state = game.play_hand() self.assertIsInstance(hand_state, HandState) # Make sure all players states have been reset for player in table.get_seated_players(): if player.stack > 0: self.assertTrue(player.is_active()) else: self.assertTrue(player.is_sitting_out())