Пример #1
0
    def test_no_args_with_target_objects(self):
        self.setup_points({
            "ATE_SOMETHING": 5,
            "DRANK_SOMETHING": 10,
            "WENT_TO_SLEEP": 4
        })
        points = PointValue.objects.all()

        TargetStat.objects.create(target_object=points[0], points=100)
        TargetStat.objects.create(target_object=points[1], points=90)
        TargetStat.objects.create(target_object=points[2], points=90)

        TargetStat.update_positions()

        self.assertEqual([(p.position, p.points)
                          for p in TargetStat.objects.order_by("position")],
                         [(1, 100), (2, 90), (2, 90)])
Пример #2
0
    def test_down_range_with_target_objects(self):
        self.setup_points({
            "ATE_SOMETHING": 5,
            "DRANK_SOMETHING": 10,
            "WENT_TO_SLEEP": 4
        })
        points = PointValue.objects.all()

        TargetStat.objects.create(target_object=points[0], points=100, position=1)
        TargetStat.objects.create(target_object=points[1], points=90, position=2)
        TargetStat.objects.create(target_object=points[2], points=95, position=3)

        TargetStat.update_positions((95, 90))

        self.assertEqual(
            [(p.position, p.points) for p in TargetStat.objects.order_by("position")],
            [(1, 100), (2, 95), (3, 90)]
        )
Пример #3
0
    def test_no_range(self):
        self.setup_users(9)

        TargetStat.objects.create(target_user=self.users[0], points=100)
        TargetStat.objects.create(target_user=self.users[1], points=90)
        TargetStat.objects.create(target_user=self.users[2], points=85)
        TargetStat.objects.create(target_user=self.users[3], points=70)
        TargetStat.objects.create(target_user=self.users[4], points=70)
        TargetStat.objects.create(target_user=self.users[5], points=60)
        TargetStat.objects.create(target_user=self.users[6], points=50)
        TargetStat.objects.create(target_user=self.users[7], points=10)
        TargetStat.objects.create(target_user=self.users[8], points=5)

        TargetStat.update_positions()

        self.assertEqual(
            [(p.position, p.points) for p in TargetStat.objects.order_by("position")],
            [(1, 100), (2, 90), (3, 85), (4, 70), (4, 70), (6, 60), (7, 50), (8, 10), (9, 5)]
        )
Пример #4
0
    def test_no_range(self):
        self.setup_users(9)

        TargetStat.objects.create(target_user=self.users[0], points=100)
        TargetStat.objects.create(target_user=self.users[1], points=90)
        TargetStat.objects.create(target_user=self.users[2], points=85)
        TargetStat.objects.create(target_user=self.users[3], points=70)
        TargetStat.objects.create(target_user=self.users[4], points=70)
        TargetStat.objects.create(target_user=self.users[5], points=60)
        TargetStat.objects.create(target_user=self.users[6], points=50)
        TargetStat.objects.create(target_user=self.users[7], points=10)
        TargetStat.objects.create(target_user=self.users[8], points=5)

        TargetStat.update_positions()

        self.assertEqual([(p.position, p.points)
                          for p in TargetStat.objects.order_by("position")],
                         [(1, 100), (2, 90), (3, 85), (4, 70), (4, 70),
                          (6, 60), (7, 50), (8, 10), (9, 5)])
Пример #5
0
    def test_down_range(self):
        self.setup_users(9)

        TargetStat.objects.create(target_user=self.users[0], points=100, position=1)
        TargetStat.objects.create(target_user=self.users[1], points=90, position=2)
        TargetStat.objects.create(target_user=self.users[2], points=69, position=3)
        TargetStat.objects.create(target_user=self.users[3], points=70, position=4)
        TargetStat.objects.create(target_user=self.users[4], points=70, position=4)
        TargetStat.objects.create(target_user=self.users[5], points=60, position=6)
        TargetStat.objects.create(target_user=self.users[6], points=50, position=7)
        TargetStat.objects.create(target_user=self.users[7], points=10, position=8)
        TargetStat.objects.create(target_user=self.users[8], points=5, position=9)

        # user 6 scored 11 points
        TargetStat.update_positions((85, 69))

        self.assertEqual(
            [(p.position, p.points) for p in TargetStat.objects.order_by("position")],
            [(1, 100), (2, 90), (3, 70), (3, 70), (5, 69), (6, 60), (7, 50), (8, 10), (9, 5)]
        )
Пример #6
0
    def test_down_range(self):
        self.setup_users(9)

        TargetStat.objects.create(target_user=self.users[0],
                                  points=100,
                                  position=1)
        TargetStat.objects.create(target_user=self.users[1],
                                  points=90,
                                  position=2)
        TargetStat.objects.create(target_user=self.users[2],
                                  points=69,
                                  position=3)
        TargetStat.objects.create(target_user=self.users[3],
                                  points=70,
                                  position=4)
        TargetStat.objects.create(target_user=self.users[4],
                                  points=70,
                                  position=4)
        TargetStat.objects.create(target_user=self.users[5],
                                  points=60,
                                  position=6)
        TargetStat.objects.create(target_user=self.users[6],
                                  points=50,
                                  position=7)
        TargetStat.objects.create(target_user=self.users[7],
                                  points=10,
                                  position=8)
        TargetStat.objects.create(target_user=self.users[8],
                                  points=5,
                                  position=9)

        # user 6 scored 11 points
        TargetStat.update_positions((85, 69))

        self.assertEqual([(p.position, p.points)
                          for p in TargetStat.objects.order_by("position")],
                         [(1, 100), (2, 90), (3, 70), (3, 70), (5, 69),
                          (6, 60), (7, 50), (8, 10), (9, 5)])