Example #1
0
 def testFish(self):
     from game.ranker import FishPersonalRanker
     ranker = FishPersonalRanker(self.r)
     ranker.rank()
     # for r in PersonalRating.objects.all():
     #     print r
     self.assertEquals(12, PersonalRating.objects.count())
     self.assertEquals(4.0, ranker.rating(
         Entity.objects.get(name=u'老大')).rating_singles)
     self.assertEquals(3.0, ranker.rating(
         Entity.objects.get(name=u'fish')).rating_singles)
Example #2
0
 def testElo(self):
     from game.ranker import EloPersonalRanker
     ranker = EloPersonalRanker(self.r)
     ranker.rank()
     #for r in PersonalRating.objects.all():
     #    print r
     self.assertEquals(12, PersonalRating.objects.count())
     rating_laoda = ranker.rating(
         Entity.objects.get(name=u'老大')).rating_singles
     rating_fish = ranker.rating(
         Entity.objects.get(name=u'fish')).rating_singles
     rating_doubles_laoda = ranker.rating(
         Entity.objects.get(name=u'老大')).rating_doubles
     rating_doubles_zhutou = ranker.rating(
         Entity.objects.get(name=u'猪头')).rating_doubles
     self.assertTrue(rating_fish > rating_laoda)
     self.assertTrue(rating_doubles_laoda > rating_doubles_zhutou)
Example #3
0
 def tearDown(self):
     self.ranker.rank()
     ranker = self.ranker
     # for r in PersonalRating.objects.all():
     #     print r
     self.assertEquals(None, ranker.rating(Entity.objects.get(name=u'fish')).rating_doubles)
     self.assertEquals(None, ranker.rating(Entity.objects.get(name=u'小小')).rating_singles)
     self.assertEquals(None, ranker.rating(Entity.objects.get(name=u'龟龟')).rating_singles)
     self.assertTrue(ranker.rating(Entity.objects.get(name=u'fish')).rating_singles >
             ranker.rating(Entity.objects.get(name=u'小小')).rating_doubles)
     self.assertTrue(ranker.rating(Entity.objects.get(name=u'fish')).rating_singles >
             ranker.rating(Entity.objects.get(name=u'龟龟')).rating_doubles)