Example #1
0
 def test_calculate_rating_for_player_missing_answers(self):
     # make sure it runs with not all questions answered
     rating.PlayerRatingSelection.objects.create(player=self.player1, rankset=self.rankset_empty,
                                                 rating=self.rating1, selection=self.rating1.options.get(value=3))
     rating.calculate_rating_for_player(self.player1, self.rankset_empty)
     player_rating = rating.get_rating_for_player(self.player1, self.rankset_empty)
     self.assertEqual(decimal.Decimal('1.5'), player_rating)
     rating.PlayerRatingSelection.objects.filter(player=self.player1, rankset=self.rankset_empty).delete()
Example #2
0
 def test_calculate_rating_for_player(self):
     # testing different kind of options
     rating.PlayerRatingSelection.objects.create(player=self.player1, rankset=self.rankset_empty,
                                                 rating=self.rating1, selection=self.rating1.options.get(value=1))
     rating.PlayerRatingSelection.objects.create(player=self.player1, rankset=self.rankset_empty,
                                                 rating=self.rating2, selection=self.rating2.options.get(value=1))
     rating.PlayerRatingSelection.objects.create(player=self.player1, rankset=self.rankset_empty,
                                                 rating=self.rating2, selection=self.rating2.options.get(value=2))
     rating.PlayerRatingSelection.objects.create(player=self.player1, rankset=self.rankset_empty,
                                                 rating=self.rating2, selection=self.rating2.options.get(value=3))
     rating.calculate_rating_for_player(self.player1, self.rankset_empty)
     player_rating = rating.get_rating_for_player(self.player1, self.rankset_empty)
     self.assertEqual(decimal.Decimal('3.5'), player_rating)
Example #3
0
 def test_calculate_rating_for_player_weights(self):
     # test non-equal weights
     self.rating1.weight = 1
     self.rating1.save()
     self.rating2.weight = 2
     self.rating2.save()
     self.assertEqual(decimal.Decimal('3.0'), rating.get_weight_total_for_set(self.rankset_empty))
     rating.PlayerRatingSelection.objects.create(player=self.player1, rankset=self.rankset_empty,
                                                 rating=self.rating1, selection=self.rating1.options.get(value=1))
     rating.PlayerRatingSelection.objects.create(player=self.player1, rankset=self.rankset_empty,
                                                 rating=self.rating2, selection=self.rating2.options.get(value=1))
     rating.PlayerRatingSelection.objects.create(player=self.player1, rankset=self.rankset_empty,
                                                 rating=self.rating2, selection=self.rating2.options.get(value=2))
     rating.PlayerRatingSelection.objects.create(player=self.player1, rankset=self.rankset_empty,
                                                 rating=self.rating2, selection=self.rating2.options.get(value=3))
     rating.calculate_rating_for_player(self.player1, self.rankset_empty)
     player_rating = rating.get_rating_for_player(self.player1, self.rankset_empty)
     self.assertEqual(decimal.Decimal('4.3333'), player_rating)
     # set the weights back
     self.rating1.weight = 1
     self.rating1.save()
     self.rating2.weight = 1
     self.rating2.save()
     self.assertEqual(decimal.Decimal('2.0'), rating.get_weight_total_for_set(self.rankset_empty))
Example #4
0
 def test_calculate_rating_for_player_no_answers(self):
     # make sure it runs with no answers
     rating.PlayerRatingSelection.objects.filter(player=self.player1, rankset=self.rankset_empty).delete()
     rating.calculate_rating_for_player(self.player1, self.rankset_empty)
     player_rating = rating.get_rating_for_player(self.player1, self.rankset_empty)
     self.assertEqual(0, player_rating)