コード例 #1
0
    def test_is_tournament_over_one_remaining_player(self):
        player_list = []
        for i in sorted(range(0, 8)):
            interface = BasicPlayer()
            player_list.append((interface, i))

        manager = Manager(player_list)
        manager.get_winners_and_cheaters = MagicMock(
            return_value=([player_list[0]], []))
        # manager.get_winners = MagicMock(return_value=[player_list[0]])
        manager.run_tournament()
        # make only one winner
        self.assertEqual(manager.round, 1)
コード例 #2
0
    def test_is_tournament_over_3_remaining_players_with_tie(self):
        player_list = []
        for i in sorted(range(0, 3)):
            interface = BasicPlayer()
            player_list.append((interface, i))

        manager = Manager(player_list)
        manager.get_winners_and_cheaters = MagicMock(
            return_value=([player_list[0], player_list[1]], []))
        manager.run_tournament()
        #have ties with 4 players left
        self.assertEqual(manager.round, 2)
        self.assertEqual(manager.last_round_winners,
                         [player_list[0], player_list[1]])
コード例 #3
0
    def test_is_tournament_over_duplicate_round_winners(self):
        """
        Purpose: Checks to determine if a tournament has reached the end condition.
        Signature: Void -> Void.
        """
        player_list = []
        for i in sorted(range(0, 8)):
            interface = BasicPlayer()
            player_list.append((interface, i))

        manager = Manager(player_list)
        manager.get_winners_and_cheaters = MagicMock(return_value=(player_list,
                                                                   []))
        manager.last_round_winners = player_list
        manager.run_tournament()
        # get last round winners to equal current round winners
        self.assertEqual(manager.round, 1)