本文整理汇总了Python中Challenge.models.Challenge.get_stack方法的典型用法代码示例。如果您正苦于以下问题:Python Challenge.get_stack方法的具体用法?Python Challenge.get_stack怎么用?Python Challenge.get_stack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Challenge.models.Challenge
的用法示例。
在下文中一共展示了Challenge.get_stack方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_stack
# 需要导入模块: from Challenge.models import Challenge [as 别名]
# 或者: from Challenge.models.Challenge import get_stack [as 别名]
def test_get_stack(self):
challenge = Challenge(
title='test_title',
subtitle='test_subtitle',
description='test_description',
course=self.course
)
challenge.save()
assert challenge.get_stack() is None
assert self.challenge.get_stack() == self.stack
示例2: ChallengeTest
# 需要导入模块: from Challenge.models import Challenge [as 别名]
# 或者: from Challenge.models.Challenge import get_stack [as 别名]
class ChallengeTest(TestCase):
def setUp(self):
self.create_test_users(4)
self.create_course()
self.create_stack()
self.create_challenge()
self.create_review_question()
def create_test_user(self, username):
user = AuroraUser(username=username)
user.email = '%[email protected]' % username
user.first_name = 'Firstname_%s' % username
user.last_name = 'Lastname_%s' % username
user.nickname = 'Nickname_%s' % username
user.is_staff = False
user.is_superuser = False
password = username
user.set_password(password)
user.save()
return user
def create_test_users(self, amount):
self.users = []
for i in range(amount):
self.users.append(self.create_test_user("s%s" % i))
def create_course(self):
self.course = Course(
title='test_title',
short_title='test_short_title',
description='test_description',
course_number='test_course_number',
)
self.course.save()
for user in self.users:
CourseUserRelation(course=self.course, user=user).save()
def create_stack(self):
self.stack = Stack(title="test stack", description="test description", course=self.course)
self.stack.save()
def create_challenge(self):
self.challenge = Challenge(
title='test_title',
subtitle='test_subtitle',
description='test_description',
course=self.course,
)
self.challenge.save()
StackChallengeRelation(stack=self.stack, challenge=self.challenge).save()
def create_review_question(self):
self.review_question = ReviewQuestion(
challenge=self.challenge,
order=1,
text="Can you find any additional material not included in this submission?"
)
self.review_question.save()
def create_review(self, elaboration, reviewer):
Review(elaboration=elaboration, submission_time=datetime.now(), reviewer=reviewer, appraisal='S').save()
def test_next(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()
assert challenge1.get_next() == challenge2
assert challenge2.get_next() == challenge3
assert challenge3.get_next() is None
def test_get_elaboration(self):
user = self.users[0]
assert self.challenge.get_elaboration(user) is None
elaboration = Elaboration(challenge=self.challenge, user=user, elaboration_text="test")
elaboration.save()
assert self.challenge.get_elaboration(user) == elaboration
def test_get_stack(self):
challenge = Challenge(
title='test_title',
subtitle='test_subtitle',
description='test_description',
course=self.course
)
challenge.save()
assert challenge.get_stack() is None
assert self.challenge.get_stack() == self.stack
def test_is_first_challenge(self):
challenge1 = self.challenge
self.create_challenge()
challenge2 = self.challenge
challenge2.prerequisite = challenge1
challenge2.save()
#.........这里部分代码省略.........