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)

    with pytest.raises(Exception):
        one_too_many = Classroom("Cant teach this")
        teacher.add_class(one_too_many)

    assert len(teacher.get_classes()) == 6
def test_classroom_warnings():
    assert Classroom.warnings == []

    some_class = Classroom("Math")

    # add 34 students to the class
    for i in range(34):
        some_student = Student("blah", "blah", datetime.datetime.now(), i)
        some_class.add_student(some_student)

    # should add a warning to the class variable 'warnings'
    warning_string = Classroom.warnings[0]
    assert warning_string == "Math has more than 33 students."
def test_cant_assign_work_to_someone_elses_class():
    teacher = Teacher("John", "Smith", datetime.datetime(2020, 1, 1), 1234)

    # raise an error if assigning work to a class not taught by the teacher
    someone_elses_class = Classroom("Computer Studies")
    with pytest.raises(Exception):
        teacher.assign_work(someone_elses_class)
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."
def test_classroom_getters_setters():
    math = Classroom("Math")

    assert math.get_students() == []
    assert math.get_name() == "Math"

    math.set_name("Blah")
    assert math.get_name() == "Blah"
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)
def test_classroom_hidden_fields():
    math = Classroom("Math")
    assert math._name == "Math"
    assert math._students == []
def test_classroom_add_remove_student():
    class StudentMock:
        pass

    math = Classroom("Math")

    some_student = StudentMock()
    math.add_student(some_student)
    assert len(math.get_students()) == 1

    math.remove_student(some_student)
    assert math.get_students() == []

    # Raises some exception when removing a studentnot in the class.
    with pytest.raises(Exception):
        math.remove_student(some_student)

    # Raise an exception when the same student is added to the same class
    math.add_student(some_student)
    with pytest.raises(Exception):
        math.add_student(some_student)