Пример #1
0
    def testTeamPointsInRound(self):
        """Tests calculating the team points leaders in a round."""
        profile = self.users[0].profile
        profile.add_points(10,
            datetime.datetime.today() - datetime.timedelta(minutes=1), "test")
        profile.save()

        self.assertEqual(team_mgr.team_points_leader(round_name=self.current_round),
                         profile.team,
                         "The user's team is not leading in the prize.")

        # Test that a user in a different team but same dorm changes the
        # leader for the original user.
        profile2 = self.users[2].profile
        profile2.add_points(profile.points() + 1,
                            datetime.datetime.today() -
                            datetime.timedelta(minutes=1),
                            "test")
        profile2.save()

        self.assertEqual(team_mgr.team_points_leader(round_name=self.current_round),
                         profile2.team,
                         "The user's team should have changed.")

        # Test that a tie is handled properly.
        profile.add_points(1, datetime.datetime.today(), "test")
        profile.save()

        self.assertEqual(team_mgr.team_points_leader(round_name=self.current_round),
                         profile.team,
                         "The leader of the team should have changed back.")
Пример #2
0
    def testTeamPointsInRound(self):
        """Tests calculating the team points leaders in a round."""
        profile = self.users[0].get_profile()
        profile.add_points(
            10,
            datetime.datetime.today() - datetime.timedelta(minutes=1), "test")
        profile.save()

        self.assertEqual(
            team_mgr.team_points_leader(round_name=self.current_round),
            profile.team, "The user's team is not leading in the prize.")

        # Test that a user in a different team but same dorm changes the
        # leader for the original user.
        profile2 = self.users[2].get_profile()
        profile2.add_points(
            profile.points() + 1,
            datetime.datetime.today() - datetime.timedelta(minutes=1), "test")
        profile2.save()

        self.assertEqual(
            team_mgr.team_points_leader(round_name=self.current_round),
            profile2.team, "The user's team should have changed.")

        # Test that a tie is handled properly.
        profile.add_points(1, datetime.datetime.today(), "test")
        profile.save()

        self.assertEqual(
            team_mgr.team_points_leader(round_name=self.current_round),
            profile.team, "The leader of the team should have changed back.")
Пример #3
0
    def _points_leader(self, team=None, place=1):
        """Return the point leader."""
        if self.round == None:
            round_name = "Round 1"
        else:
            round_name = self.round.name

        leader = None

        if self.award_to == "individual_overall":
            leader = player_mgr.points_leader(round_name=round_name, place=place)

        elif self.award_to == "team_group":
            if team:
                leaders = team.group.team_points_leaders(num_results=place, round_name=round_name)
                if len(leaders) >= place:
                    leader = leaders[place - 1]

        elif self.award_to == "team_overall":
            leader = team_mgr.team_points_leader(round_name=round_name, place=place)

        elif self.award_to == "group":
            leader = team_mgr.group_points_leader(round_name=round_name, place=place)

        elif self.award_to == "individual_team":
            if team:
                leaders = team.points_leaders(num_results=place, round_name=round_name)
                if len(leaders) >= place:
                    leader = leaders[place - 1]

        else:
            raise Exception("'%s' is not implemented yet." % self.award_to)

        return leader
Пример #4
0
    def _points_leader(self, team=None):
        """Return the point leader."""
        if self.round == None:
            round_name = "Round 1"
        else:
            round_name = self.round.name
        if self.award_to == "individual_overall":
            return player_mgr.points_leader(round_name=round_name)

        elif self.award_to == "team_group":
            if team:
                leaders = team.group.team_points_leaders(num_results=1, round_name=round_name)
                if leaders:
                    return leaders[0]
            return None

        elif self.award_to == "team_overall":
            return team_mgr.team_points_leader(round_name=round_name)

        elif self.award_to == "individual_team":
            if team:
                leaders = team.points_leaders(num_results=1, round_name=round_name)
                if leaders:
                    return leaders[0]
            return None
        elif self.award_to == "group_overall":
            return score_mgr.group_points_leader()

        raise Exception("'%s' is not implemented yet." % self.award_to)
Пример #5
0
    def _points_leader(self, team=None):
        """Return the point leader."""
        if self.round == None:
            round_name = "Round 1"
        else:
            round_name = self.round.name

        leader = None

        if self.award_to == "individual_overall":
            leader = player_mgr.points_leader(round_name=round_name)
        elif self.award_to == "team_group":
            if team:
                leaders = team.group.team_points_leaders(num_results=1,
                                                         round_name=round_name)
                if leaders:
                    leader = leaders[0]
        elif self.award_to == "team_overall":
            leader = team_mgr.team_points_leader(round_name=round_name)
        elif self.award_to == "group":
            leader = team_mgr.group_points_leader(round_name=round_name)
        elif self.award_to == "individual_team":
            if team:
                leaders = team.points_leaders(num_results=1,
                                              round_name=round_name)
                if leaders:
                    leader = leaders[0]
        else:
            raise Exception("'%s' is not implemented yet." % self.award_to)

        return leader