Exemple #1
0
def test_do_hw_return_hw_res():
    st = task02.Student("Mashaev", "Nikita")
    hw = task02.Homework("Actual", 1)
    hw_res = st.do_homework(hw, "done")
    assert isinstance(hw_res, task02.HomeworkResult)
    assert hw_res.solution == "done"
    assert hw_res.homework == hw
    assert hw_res.author == st
Exemple #2
0
def test_check_same():
    st = task02.Student("Mashaev", "Nikita")
    hw = task02.Homework("Actual", 1)
    hw_res = st.do_homework(hw, "2 + 2 = 4")
    assert len(task02.Teacher.homework_done[hw]) == 0
    task02.Teacher.check_homework(hw_res)
    assert len(task02.Teacher.homework_done[hw]) == 1
    task02.Teacher.check_homework(hw_res)
    assert len(task02.Teacher.homework_done[hw]) == 1
Exemple #3
0
def test_reset_results_delete_hw_done_if_nothing_given():
    task02.Teacher.homework_done = defaultdict(list)
    st = task02.Student("Mashaev", "Nikita")
    hw1 = task02.Homework("hw1", 1)
    hw2 = task02.Homework("hw2", 2)
    hw_res1 = st.do_homework(hw1, "2 + 2 = 4")
    hw_res2 = st.do_homework(hw2, "Green Gauss gradient approach")
    task02.Teacher.check_homework(hw_res1)
    task02.Teacher.check_homework(hw_res2)
    assert len(task02.Teacher.homework_done) == 2
    task02.Teacher.reset_results()
    assert len(task02.Teacher.homework_done) == 0
Exemple #4
0
def test_reject_pass():
    st = task02.Student("Mashaev", "Nikita")
    hw = task02.Homework("Actual", 1)
    hw_res = st.do_homework(hw, "2=2")
    assert not task02.Teacher.check_homework(hw_res)
    assert not hw_res.homework in task02.Teacher.homework_done.keys()
Exemple #5
0
def test_do_hw_deadline_exception():
    student = task02.Student("Mashaev", "Nikita")
    expired_homework = task02.Homework("Expired", 0)
    with pytest.raises(task02.DeadlineError, match="You are late"):
        student.do_homework(expired_homework, "solution")
Exemple #6
0
def test_raising_error_if_not_hw_given():
    student = task02.Student("Mashaev", "Nikita")
    with pytest.raises(TypeError,
                       match="Error: Expected homework but unknown found!"):
        task02.HomeworkResult(student, "str instead of Homework", "solution")