示例#1
0
    def all_available_periods(self, student, internship_length, periods):
        """Difference between the authorized periods and the already affected periods from the student."""
        student_affectations = get_student_affectations(
            student, self.affectations)
        unavailable_periods = get_periods_from_affectations(
            student_affectations)
        available_periods = difference(periods, unavailable_periods)
        grouped_periods = list(
            group_periods_by_consecutives(available_periods,
                                          length=internship_length))

        return grouped_periods
示例#2
0
 def student_empty_periods(self, student, affectations):
     student_affectations = get_student_affectations(student, affectations)
     unavailable_periods = get_periods_from_affectations(
         student_affectations)
     return difference(list(self.periods), unavailable_periods)
 def test_difference_with_empty_lists(self):
     first_list = []
     second_list = []
     expected = []
     self.assertEqual(expected, difference(first_list, second_list))
 def test_difference_with_list_without_common_elements(self):
     first_list = [1, 2, 3, 4]
     second_list = [5, 6]
     expected = [1, 2, 3, 4]
     self.assertEqual(expected, difference(first_list, second_list))
 def test_difference_non_empty_lists(self):
     first_list = [1, 2, 3, 4, 5]
     second_list = [4, 5]
     expected = [1, 2, 3]
     self.assertEqual(expected, difference(first_list, second_list))