def _make_instances( student_prefs, project_supervisors, project_capacities, supervisor_capacities, ): """Create ``Player``, ``Project`` and ``Supervisor`` instances for the names in each dictionary.""" student_dict, project_dict, supervisor_dict = {}, {}, {} for student_name in student_prefs: student = Student(name=student_name) student_dict[student_name] = student for project_name, supervisor_name in project_supervisors.items(): capacity = project_capacities[project_name] project = Project(name=project_name, capacity=capacity) project_dict[project_name] = project for supervisor_name, capacity in supervisor_capacities.items(): supervisor = Supervisor(name=supervisor_name, capacity=capacity) supervisor_dict[supervisor_name] = supervisor for project_name, supervisor_name in project_supervisors.items(): project = project_dict[project_name] supervisor = supervisor_dict[supervisor_name] project.set_supervisor(supervisor) return student_dict, project_dict, supervisor_dict
def test_set_supervisor(name, capacity): """Check that a project can update its supervisor member and that it is added to the supervisor's project list.""" project = Project(name, capacity) supervisor = Supervisor("foo", capacity) project.set_supervisor(supervisor) assert project.supervisor == supervisor assert supervisor.projects == [project]