Example #1
0
    def test_start_shorten_case_multiple_deletion(self):
        # Insert multiple in future
        for ac_year in self.generated_ac_years.academic_years:
            EducationGroupYearFactory(
                education_group=self.education_group_year.education_group,
                management_entity=self.entity,
                administration_entity=self.entity,
                academic_year=ac_year,
            )

        result = shorten.start(self.education_group_year.education_group,
                               self.current_academic_year.year)

        self.assertIsInstance(result, list)
        self.assertEqual(len(result), 10)
        # Ensure that the order is by academic_year.year
        for idx, ac_year in enumerate(self.generated_ac_years.academic_years):
            self.assertEqual(result[idx].academic_year, ac_year)

        # Ensure that data doesn't exist anymore
        self.assertFalse(
            EducationGroupYear.objects.filter(
                education_group=self.education_group_year.education_group,
                academic_year__year__gt=self.current_academic_year.year).count(
                ))
Example #2
0
    def _post_save(self):
        education_group_instance = self.forms[EducationGroupModelForm].instance
        egy_deleted = []
        if education_group_instance.end_year:
            egy_deleted = shorten.start(education_group_instance,
                                        education_group_instance.end_year)

        return {'object_list_deleted': egy_deleted}
Example #3
0
    def _post_save(self):
        education_group_instance = self.forms[EducationGroupModelForm].instance
        egy_deleted = []
        if education_group_instance.end_year:
            egy_deleted = shorten.start(education_group_instance, education_group_instance.end_year)

        return {
            'object_list_deleted': egy_deleted
        }
Example #4
0
    def test_start_shorten_case_no_deletion(self):
        # Remove all in the future
        EducationGroupYear.objects.filter(
            education_group=self.education_group_year.education_group,
            academic_year__year__gt=self.current_academic_year.year
        ).delete()

        result = shorten.start(self.education_group_year.education_group, self.current_academic_year)
        self.assertIsInstance(result, list)
        self.assertFalse(result)