예제 #1
0
def test_teacher_assing_work():
    teacher = Teacher("John", "Smith", datetime.datetime(2020, 1, 1), 1234)
    math = Classroom("Math")
    teacher.add_class(math)

    assert teacher.assign_work(
        math) == "John Smith assigns work to Math class."
예제 #2
0
def test_teacher_cannot_have_more_than_6_classes():
    teacher = Teacher("John", "Smith", datetime.datetime(2020, 1, 1), 1234)

    # OK to have 6
    for i in range(6):
        some_class = Classroom(str(i))
        teacher.add_class(some_class)
    
    # Error when trying to add a 7th class
    with pytest.raises(Exception):
        one_too_many = Classroom("Cant teach this")
        teacher.add_class(one_too_many)
    
    assert len(teacher.get_classes()) == 6
예제 #3
0
def test_teacher_add_remove_class():
    teacher = Teacher("John", "Smith", datetime.datetime(2020, 1, 1), 1234)
    some_class = Classroom("Math")
    teacher.add_class(some_class)

    assert some_class in teacher.get_classes()

    teacher.remove_class(some_class)
    assert teacher.get_classes() == []

    # ensure you cannot teach the same class twice
    teacher.add_class(some_class)
    with pytest.raises(Exception):
        teacher.add_class(some_class)