예제 #1
0
파일: tests.py 프로젝트: slok/dwarf
    def test_basic_decrement(self):
        decr_points = 50
        user = User.objects.get(id=1)

        self.assertEqual(0, user.profile.points)
        self.assertEqual(0, user.profile.level.level_number)

        level = utils.decr_points(user, decr_points)
        self.assertEqual(0, user.profile.points)
        self.assertEqual(0, user.profile.level.level_number)
        self.assertIsNone(level)
예제 #2
0
파일: tests.py 프로젝트: slok/dwarf
    def test_basic_decrement_with_level(self):
        decr_points = 3000
        start_points = 5000

        user = User.objects.get(id=1)
        user.profile.points = start_points
        user.profile.level = Level.objects.get(level_number=5)
        user.save()

        self.assertEqual(start_points, user.profile.points)

        level = utils.decr_points(user, decr_points)
        self.assertEqual(start_points - decr_points, user.profile.points)
        self.assertEqual(2, user.profile.level.level_number)
        self.assertEqual(2, level.level_number)
예제 #3
0
파일: tests.py 프로젝트: slok/dwarf
    def test_basic_decrement_without_level(self):
        decr_points = 999
        start_points = 1999

        user = User.objects.get(id=1)
        user.profile.points = start_points
        user.profile.level = Level.objects.get(level_number=1)
        user.save()

        self.assertEqual(start_points, user.profile.points)

        level = utils.decr_points(user, decr_points)
        self.assertEqual(start_points - decr_points, user.profile.points)
        self.assertEqual(1, user.profile.level.level_number)
        self.assertIsNone(level)