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


Python Challenge.get_status方法代码示例

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


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

示例1: ChallengeTest

# 需要导入模块: from Challenge.models import Challenge [as 别名]
# 或者: from Challenge.models.Challenge import get_status [as 别名]

#.........这里部分代码省略.........
        user1 = self.users[0]
        user2 = self.users[1]
        user3 = self.users[2]
        user4 = self.users[3]
        elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test",
                                   submission_time=datetime.now())
        elaboration1.save()
        elaboration2 = Elaboration(challenge=challenge1, user=user2, elaboration_text="test",
                                   submission_time=datetime.now())
        elaboration2.save()
        elaboration3 = Elaboration(challenge=challenge1, user=user3, elaboration_text="test",
                                   submission_time=datetime.now())
        elaboration3.save()
        elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test",
                                   submission_time=datetime.now())
        elaboration4.save()
        Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1,
               appraisal=Review.SUCCESS).save()
        Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1,
               appraisal=Review.SUCCESS).save()
        Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1,
               appraisal=Review.SUCCESS).save()
        assert not challenge3.is_enabled_for_user(user1)
        Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user2,
               appraisal=Review.SUCCESS).save()
        Review(elaboration=elaboration1, submission_time=datetime.now(), reviewer=user3,
               appraisal=Review.SUCCESS).save()

        assert not challenge3.is_enabled_for_user(user1)

    def test_status_not_started(self):
        user = self.users[0]
        assert self.challenge.is_enabled_for_user(user)
        assert self.challenge.get_status(user) == Challenge.NOT_STARTED

    def test_status_not_submitted(self):
        challenge1 = self.challenge
        self.create_challenge()
        challenge2 = self.challenge
        challenge2.prerequisite = challenge1
        challenge2.save()
        user = self.users[0]
        assert challenge1.get_status(user) == Challenge.NOT_STARTED
        elaboration = Elaboration(challenge=challenge1, user=user, elaboration_text="test")
        elaboration.save()
        assert challenge1.is_enabled_for_user(user)
        assert challenge1.get_status(user) == Challenge.NOT_SUBMITTED
        assert not challenge2.is_enabled_for_user(user)
        assert challenge2.get_status(user) == Challenge.NOT_ENABLED

    def test_status_blocked_bad_review_fail(self):
        challenge1 = self.challenge
        self.create_challenge()
        challenge2 = self.challenge
        challenge2.prerequisite = challenge1
        challenge2.save()
        self.create_challenge()
        challenge3 = self.challenge
        challenge3.prerequisite = challenge2
        challenge3.save()
        user1 = self.users[0]
        user2 = self.users[1]
        user3 = self.users[2]
        user4 = self.users[3]
        elaboration1 = Elaboration(challenge=challenge1, user=user1, elaboration_text="test",
                                   submission_time=datetime.now())
开发者ID:Bernhard---H,项目名称:aurora,代码行数:70,代码来源:tests.py


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