本文整理汇总了Python中Challenge.models.Challenge.is_enabled_for_user方法的典型用法代码示例。如果您正苦于以下问题:Python Challenge.is_enabled_for_user方法的具体用法?Python Challenge.is_enabled_for_user怎么用?Python Challenge.is_enabled_for_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Challenge.models.Challenge
的用法示例。
在下文中一共展示了Challenge.is_enabled_for_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ChallengeTest
# 需要导入模块: from Challenge.models import Challenge [as 别名]
# 或者: from Challenge.models.Challenge import is_enabled_for_user [as 别名]
#.........这里部分代码省略.........
elaboration4 = Elaboration(challenge=challenge1, user=user4, elaboration_text="test",
submission_time=datetime.now())
elaboration4.save()
assert len(challenge1.get_reviews_written_by_user(user1)) == 0
review1 = Review(elaboration=elaboration2, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS)
review1.save()
assert len(challenge1.get_reviews_written_by_user(user1)) == 1
assert review1 in challenge1.get_reviews_written_by_user(user1)
review2 = Review(elaboration=elaboration3, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS)
review2.save()
assert len(challenge1.get_reviews_written_by_user(user1)) == 2
assert review1 in challenge1.get_reviews_written_by_user(user1)
assert review2 in challenge1.get_reviews_written_by_user(user1)
review3 = Review(elaboration=elaboration4, submission_time=datetime.now(), reviewer=user1,
appraisal=Review.SUCCESS)
review3.save()
assert len(challenge1.get_reviews_written_by_user(user1)) == 3
assert review1 in challenge1.get_reviews_written_by_user(user1)
assert review2 in challenge1.get_reviews_written_by_user(user1)
assert review3 in challenge1.get_reviews_written_by_user(user1)
def test_get_elaborations(self):
assert len(self.challenge.get_elaborations()) == 0
user = self.users[0]
elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test")
elaboration.save()
assert len(self.challenge.get_elaborations()) == 1
assert elaboration in self.challenge.get_elaborations()
def test_first_challenge_is_always_enabled(self):
user = self.users[0]
assert self.challenge.is_enabled_for_user(user)
def test_already_submitted_challenges_are_enabled(self):
challenge1 = self.challenge
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
user = self.users[0]
assert not challenge2.is_enabled_for_user(user)
elaboration = Elaboration(challenge=challenge2, user=user, elaboration_text="test")
elaboration.save()
assert not challenge2.is_enabled_for_user(user)
elaboration.submission_time = datetime.now()
elaboration.save()
assert challenge2.is_enabled_for_user(user)
def test_enough_user_reviews_required(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())