当前位置: 首页>>代码示例>>Python>>正文


Python ExerciseLog.points方法代码示例

本文整理汇总了Python中main.models.ExerciseLog.points方法的典型用法代码示例。如果您正苦于以下问题:Python ExerciseLog.points方法的具体用法?Python ExerciseLog.points怎么用?Python ExerciseLog.points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在main.models.ExerciseLog的用法示例。


在下文中一共展示了ExerciseLog.points方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_exerciselog_collision

# 需要导入模块: from main.models import ExerciseLog [as 别名]
# 或者: from main.models.ExerciseLog import points [as 别名]
    def test_exerciselog_collision(self):

        # create a new exercise log with the same exercise_id and user, but different points/attempts
        exerciselog = ExerciseLog(exercise_id=self.EXERCISE_ID, user=self.user)
        exerciselog.points = self.NEW_POINTS
        exerciselog.attempts = self.NEW_ATTEMPTS

        # try saving the new ExerciseLog: this is where the collision will happen, hopefully leading to a merge
        exerciselog.save()

        # get a new reference to the existing ExerciseLog
        exerciselog2 = ExerciseLog.objects.get(id=self.original_exerciselog.id)

        # make sure the ExerciseLog has been properly merged
        self.assertEqual(exerciselog.points, max(self.ORIGINAL_POINTS, self.NEW_POINTS), "The ExerciseLog's points were not properly merged.")
        self.assertEqual(exerciselog.attempts, max(self.ORIGINAL_ATTEMPTS, self.NEW_ATTEMPTS), "The ExerciseLog's attempts have already changed.")
开发者ID:AbhiUnni,项目名称:ka-lite,代码行数:18,代码来源:log_model_tests.py


注:本文中的main.models.ExerciseLog.points方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。