Example #1
0
def test_student_get_answer() -> None:
    student = Student(1, "Jane")
    q1 = Question(1, "How are you")
    a1 = Answer("good")
    q2 = Question(2, "hello")
    a2 = Answer("hi")
    assert student.get_answer(q1) is None
    student.set_answer(q1, a1)
    student.set_answer(q2, a2)
    assert student.get_answer(q1) == a1
    assert student.get_answer(q2) == a2
Example #2
0
def test_student_get_answer() -> None:
    """A test for get_answer() in class Student."""
    s = Student(123, 'Mike')
    ans = Answer(False)
    que = Question(2, 'F')
    s.set_answer(que, ans)
    test_ans = s.get_answer(que)
    assert ans == test_ans
Example #3
0
def test_student() -> None:
    student_1 = Student(1, "roney")
    student_2 = Student(2, "tim")
    student_3 = Student(3, "allen")
    assert str(student_1) == "roney"
    assert str(student_2) == "tim"
    assert str(student_3) != "roney"
    assert student_1.id == 1
    assert student_2.id != 4
    assert student_3.id == 3
    mcq_1 = MultipleChoiceQuestion(1, "Cities in Canada",
                                   ["Toronto", "Ottawa", "Vancouver"])
    mcq_2 = MultipleChoiceQuestion(2, "C", ["A", "O", "V"])
    mcq_1_ans = Answer("Toronto")
    student_1.set_answer(mcq_1, mcq_1_ans)
    assert student_1.has_answer(mcq_1)
    assert not student_1.has_answer(mcq_2)
    assert student_1.get_answer(mcq_1) == mcq_1_ans
    assert student_1.get_answer(mcq_2) == None
    assert student_2.get_answer(mcq_1) == None
Example #4
0
def test_student_set_answer():
    student = Student(1, "Jane")
    q1 = Question(1, "How are you")
    a1 = Answer("good")
    q2 = Question(2, "hello")
    a2 = Answer("hi")
    a3 = Answer("test")
    student.set_answer(q1, a1)
    student.set_answer(q2, a2)
    student.set_answer(q2, a3)
    assert student.get_answer(q1) == a1
    assert student.get_answer(q2) == a3