コード例 #1
0
ファイル: tests.py プロジェクト: YuseqYaseq/pytajnix
 def __prepare_question_vote(self, username):
     with transaction.atomic():
         lecture = Lecture.objects.filter(hash='3j7t950').first()
         participant = Participant(username=username, public_nickname=username)
         participant.save()
         lecture.participants.add(participant)
         question = Question(text='How are you?', tags='hello', creator=participant, event=lecture)
         question.save()
         vote = QuestionVote(value=1, voter=participant, question=question)
         vote.save()
         lecture.save()
     return participant, lecture, question
コード例 #2
0
 def create_questions(cls):
     users = LaskUser.objects.all()
     tags = Tag.objects.all()
     faker = Faker()
     for _ in range(QUESTIONS_COUNT):
         question = Question(
             title=faker.sentence(),
             text=faker.text(),
             question_author=random.choice(users),
             rating=random.randint(1, 100),
         )
         question.save()
         for _ in range(random.randint(1, 4)):
             question.tags.add(random.choice(tags))
     stdout_writer.stdout.write("Created test data: QUESTIONS")
コード例 #3
0
ファイル: tests.py プロジェクト: YuseqYaseq/pytajnix
 def test_question_can_vote_2(self):
     participant = Participant.objects.create(username='******')
     lecture = Lecture.objects.get(hash='3j7t950')
     question = Question(text='How are you?', tags='hello', creator=participant, event=lecture)
     question.save()
     self.assertTrue(question.can_vote(participant))