Exemplo n.º 1
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)
Exemplo n.º 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