def test_submit_quiz_less_answers_than_options(tst): q1 = Question('whats your name?', ['Thiago', 'James', 'Bond'], 'Thiago') q2 = Question('how old are you?', [20, 40, 27], 27) quiz = Quiz(tst.teacher, tst.classroom, [q1, q2]) student_quiz = StudentQuiz(tst.student, quiz) with pytest.raises(Exception): student_quiz.submit_answers(['Thiago'])
def test_assign_quiz_student_not_in_classroom(tst): q1 = Question('whats your name?', ['Thiago', 'James', 'Bond'], 'Thiago') q2 = Question('how old are you?', [20, 40, 27], 27) quiz = Quiz(tst.teacher, tst.classroom, [q1, q2]) tst.student.classes = [] with pytest.raises(AssertionError): StudentQuiz(tst.student, quiz)
def test_create_quiz_with_questions_later(tst): q1 = Question('whats your name?', ['Thiago', 'James', 'Bond'], 'Thiago') q2 = Question('how old are you?', [20, 40, 27], 27) assert q1.question == 'whats your name?' assert q1.options == ['Thiago', 'James', 'Bond'] assert q1.correct_answer == 'Thiago' quiz = Quiz(tst.teacher, tst.classroom) assert len(quiz.questions) == 0 assert quiz.questions == [] assert quiz.teacher.name == tst.teacher.name quiz.add_question(q1) quiz.add_question(q2) assert len(quiz.questions) == 2 assert quiz.questions == [q1, q2]
def test_assign_quiz_student(tst): q1 = Question('whats your name?', ['Thiago', 'James', 'Bond'], 'Thiago') q2 = Question('how old are you?', [20, 40, 27], 27) quiz = Quiz(tst.teacher, tst.classroom, [q1, q2]) student_quiz = StudentQuiz(tst.student, quiz) assert student_quiz.quiz == quiz assert student_quiz.student == tst.student assert student_quiz.grade == 0 assert student_quiz.answers == []
def test_submit_quiz_answers_and_grade_ten(tst): q1 = Question('whats your name?', ['Thiago', 'James', 'Bond'], 'Thiago') q2 = Question('how old are you?', [20, 40, 27], 27) quiz = Quiz(tst.teacher, tst.classroom, [q1, q2]) student_quiz = StudentQuiz(tst.student, quiz) student_quiz.submit_answers(['Thiago', 27]) assert student_quiz.quiz == quiz assert student_quiz.student == tst.student assert student_quiz.grade == 0 assert student_quiz.answers == ['Thiago', 27] student_quiz.grade_quiz() assert student_quiz.grade == 10
def test_submit_quiz_answers_and_get_grade_another_semester(tst): q1 = Question('whats your name?', ['Thiago', 'James', 'Bond'], 'Thiago') q2 = Question('how old are you?', [20, 40, 27], 27) quiz = Quiz(tst.teacher, tst.classroom, [q1, q2]) student_quiz = StudentQuiz(tst.student, quiz) student_quiz.submit_answers(['Thiago', 27]) assert student_quiz.quiz == quiz assert student_quiz.student == tst.student assert student_quiz.grade == 0 assert student_quiz.answers == ['Thiago', 27] student_quiz.grade_quiz() assert student_quiz.grade == 10 assert GradeService(tst.teacher).calculate_grade(tst.student, 2018, 1) == 0