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


Python Challenge.is_started方法代码示例

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


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

示例1: ChallengeTest

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

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

    def test_is_started(self):
        user = self.users[0]
        elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="")
        elaboration.save()
        assert self.challenge.is_started(user) is False
        elaboration.elaboration_text="test"
        elaboration.save()
        assert self.challenge.is_started(user) is True

    def test_submitted_by_user(self):
        user = self.users[0]
        elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test")
        elaboration.save()
        assert not self.challenge.submitted_by_user(user)
        elaboration.submission_time = datetime.now()
        elaboration.save()
        assert self.challenge.submitted_by_user(user)

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


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