def test_unknown_mentor(self): mentee = [['S1', 'M2']] capacity = [['M1', '1']] with self.assertRaises(matching.InvalidProblemStatement): matching.validate_and_transform(mentee, [['M1', 'S1']], capacity) with self.assertRaises(matching.InvalidProblemStatement): matching.validate_and_transform(mentee, [], capacity)
def test_duplicate_ranking(self): with self.assertRaises(matching.InvalidProblemStatement): mentee = [['S1', 'M1', 'M1']] mentor = [['M1', 'S1']] capacity = [['M1', '1']] matching.validate_and_transform(mentee, mentor, capacity) with self.assertRaises(matching.InvalidProblemStatement): mentee = [['S1', 'M1']] mentor = [['M1', 'S1', 'S1']] capacity = [['M1', '1']] matching.validate_and_transform(mentee, mentor, capacity)
def test_missing_capacity_for_mentor(self): with self.assertRaises(matching.InvalidProblemStatement): mentee = [['S1', 'M1']] mentor = [['M1', 'S1']] capacity = [['M2', '1']] matching.validate_and_transform(mentee, mentor, capacity) with self.assertRaises(matching.InvalidProblemStatement): mentee = [['S1', 'M1']] mentor = [['M1', 'S1'], ['M2', 'S1']] capacity = [['M1', '1']] matching.validate_and_transform(mentee, mentor, capacity)
def test_valid_ranking(self): mentee = [['S1', 'M1', 'M2'], ['S2', 'M1']] mentor = [['M1', 'S1'], ['M2', 'S1', 'S2']] capacity = [['M1', '1'], ['M2', '2']] res = matching.validate_and_transform(mentee, mentor, capacity) self.assertDictEqual(res.mentee_rankings, { 'S1': ['M1', 'M2'], 'S2': ['M1'] }) self.assertDictEqual(res.mentor_rankings, { 'M1': ['S1'], 'M2': ['S1', 'S2'] }) self.assertDictEqual(res.mentor_capacities, {'M1': 1, 'M2': 2})
def test_int_capacity_columns(self): res = matching.validate_and_transform([], [], [['a', 1]]) self.assertDictEqual(res.mentor_capacities, {'a': 1})
def test_bad_type_for_capacity_columns(self): with self.assertRaises(matching.InvalidProblemStatement): matching.validate_and_transform([], [], [['a', []]])
def test_duplicate_capacity_columns(self): with self.assertRaises(matching.InvalidProblemStatement): matching.validate_and_transform([], [], [['a', 1], ['a', 1]])
def test_zero_capacity_for_mentor(self): with self.assertRaises(matching.InvalidProblemStatement): matching.validate_and_transform([], [], [['a', 0]])
def test_insufficient_mentor_capacity(self): with self.assertRaises(matching.InvalidProblemStatement): mentee = [['S1', 'M1', 'M2'], ['S2', 'M1'], ['S3', 'M1']] mentor = [['M1', 'S1'], ['M2', 'S1', 'S2']] capacity = [['M1', '1'], ['M2', '1']] matching.validate_and_transform(mentee, mentor, capacity)