Beispiel #1
0
    def test_create_quiz_questions(self):
        quiz = Quiz.objects.get(pk=1)
        QuizQuestion.objects.filter(quiz=quiz).delete()

        # check no questions
        no_questions = QuizQuestion.objects.filter(quiz=quiz).count()
        self.assertEqual(no_questions, 0)

        with open(self.quiz_json_file) as json_data:
            quiz_obj = json.load(json_data)

        quiz_obj['id'] = quiz.pk

        user = User.objects.get(pk=1)
        create_quiz_questions(user, quiz, quiz_obj)

        # check no questions
        no_questions = QuizQuestion.objects.filter(quiz=quiz).count()
        self.assertEqual(no_questions, 10)
    def test_create_quiz_questions(self): 
        quiz = Quiz.objects.get(pk=1)
        QuizQuestion.objects.filter(quiz=quiz).delete()
         
        # check no questions
        no_questions = QuizQuestion.objects.filter(quiz=quiz).count()
        self.assertEqual(no_questions, 0)
        
        with open(self.quiz_json_file) as json_data:
            quiz_obj = json.load(json_data)

        quiz_obj['id'] = quiz.pk  
        
        user = User.objects.get(pk=1)
        create_quiz_questions(user, quiz, quiz_obj)
        
        # check no questions
        no_questions = QuizQuestion.objects.filter(quiz=quiz).count()
        self.assertEqual(no_questions, 10)