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