Esempio n. 1
0
def test_RandomStudent_do_homework_negative():
    """Test RandomStudent.do_homework when deadline expires"""
    hw = oop.Homework("text", 0)
    st = oop.RandomStudent("Last", "First")

    with pytest.raises(oop.DeadlineError, match="You are late"):
        st.do_homework(hw)
Esempio n. 2
0
def test_homework_result_init():
    """Test normal HomeworkResult.__init__()"""
    hw_r = oop.HomeworkResult(oop.Homework("_", 1), "_",
                              oop.RandomStudent("_", "_"))
    assert isinstance(hw_r.homework, oop.Homework)
    assert isinstance(hw_r.author, oop.RandomStudent)
    assert isinstance(hw_r.created, datetime.datetime)
Esempio n. 3
0
def test_RandomStudent_do_homework_positive():
    """Test RandomStudent.do_homework() at time"""
    hw = oop.Homework("text", 1)
    st = oop.RandomStudent("Last", "First")

    result = st.do_homework(hw)

    assert result.author == st
Esempio n. 4
0
def test_reset_result_single():
    """Test Teacher.reset_result() with arg"""
    teacher = oop.Teacher("_", "_")
    hw1 = teacher.create_homework("_", 1)
    RandomStudent = oop.RandomStudent("_", "_")
    hw_result = RandomStudent.do_homework(hw1)
    hw_result.solution = "123456"
    teacher.check_homework(hw_result)
Esempio n. 5
0
def test_check_homework_positive():
    """Test Teacher.check_homework with perfect RandomStudents"""
    teacher = oop.Teacher("_", "_")
    hw = teacher.create_homework("_", 1)

    hw_result1 = oop.RandomStudent("_", "_").do_homework(hw)
    hw_result1.solution = "1234567"
    hw_result2 = oop.RandomStudent("_", "_").do_homework(hw)
    hw_result2.solution = "12345678"

    teacher.reset_result()

    assert teacher.check_homework(hw_result1)

    oop.Teacher("_", "_").check_homework(hw_result2)

    assert len(teacher.homework_done[hw]) == 2
    teacher.reset_result()
Esempio n. 6
0
def test_check_homework_negative():
    """Test Teacher.check_homework with bad homework"""
    teacher = oop.Teacher("_", "_")
    hw = teacher.create_homework("_", 1)

    hw_result = oop.RandomStudent("_", "_").do_homework(hw)
    hw_result.solution = ""
    teacher.reset_result()

    assert not teacher.check_homework(hw_result)
    assert len(teacher.homework_done) == 0

    teacher.reset_result()
Esempio n. 7
0
def test_homework_result_err():
    """test HomeworkResult takes wrong argument"""
    with pytest.raises(TypeError, match="You gave a not Homework object"):
        oop.HomeworkResult(1, "_", oop.RandomStudent("_", "_"))
Esempio n. 8
0
def test_RandomStudent_init():
    """Test RandomStudent.__init__()"""
    st = oop.RandomStudent("Last", "First")
    assert st.last_name == "Last"
    assert st.first_name == "First"