def test_get_favourite(name, capacity, pref_names): """ Check the correct player is returned as the hospital's favourite. """ hospital = Hospital(name, capacity) others = [Resident(other) for other in pref_names] hospital.set_prefs(others) assert hospital.get_favourite() == others[0] hospital.matching = others assert hospital.get_favourite() is None
def test_check_if_match_is_unacceptable(name, capacity, pref_names): """ Check that a hospital can verify the acceptability of its matches. """ hospital = Hospital(name, capacity) others = [Resident(other) for other in pref_names] assert hospital.check_if_match_is_unacceptable() == [] hospital.set_prefs(others[:-1]) hospital.matching = [others[-1]] message = hospital.not_in_preferences_message(others[-1]) assert hospital.check_if_match_is_unacceptable() == [message]
def test_get_successors(name, capacity, pref_names): """Check that a hospital can get the successors to its worst current match.""" hospital = Hospital(name, capacity) others = [Resident(other) for other in pref_names] hospital.set_prefs(others) hospital.matching = [others[0]] assert hospital.get_successors() == others[1:] hospital.matching = others assert hospital.get_successors() == []
def test_match(name, capacity, pref_names): """ Check that a hospital can match to a player correctly. """ hospital = Hospital(name, capacity) others = [Resident(other) for other in pref_names] hospital.set_prefs(others) for i, other in enumerate(others[:-1]): hospital.match(other) assert hospital.matching == others[:i + 1] hospital.match(others[-1]) assert hospital.matching == others