Ejemplo n.º 1
0
    def test_get_protected_messages_with_protected_datas(self):
        # Insert multiple in future with protected datas
        all_edy = []
        for ac_year in self.generated_ac_years.academic_years:
            edy = EducationGroupYearFactory(
                education_group=self.education_group_year.education_group,
                management_entity=self.entity,
                administration_entity=self.entity,
                academic_year=ac_year,
            )
            # Protected data [Offer enrollment]
            OfferEnrollmentFactory(education_group_year=edy)
            all_edy.append(edy)

        protected_messages = shorten._get_protected_messages(all_edy)
        self.assertIsInstance(protected_messages, list)
        self.assertEqual(len(protected_messages), 10)

        # Ensure that the order of protected messages is by academic_year.year + Message expected
        count_enrollment = 1
        msg_expected = [
            ngettext_lazy(
                "%(count_enrollment)d student is enrolled in the offer.",
                "%(count_enrollment)d students are enrolled in the offer.",
                count_enrollment
            ) % {"count_enrollment": count_enrollment}
        ]
        for idx, ac_year in enumerate(self.generated_ac_years.academic_years):
            protected_message = protected_messages
            self.assertEqual(protected_message[idx]['education_group_year'].academic_year, ac_year)
            self.assertEqual(protected_message[idx]['messages'], msg_expected)
Ejemplo n.º 2
0
 def test_get_protected_messages_without_any_protected_datas(self):
     edy = EducationGroupYearFactory(
         education_group=self.education_group_year.education_group,
         management_entity=self.entity,
         administration_entity=self.entity,
         academic_year=self.generated_ac_years.academic_years[0],
     )
     protected_messages = shorten._get_protected_messages([edy])
     self.assertFalse(protected_messages)
Ejemplo n.º 3
0
 def test_get_protected_messages_linked_with_epc(self):
     edy = EducationGroupYearFactory(
         education_group=self.education_group_year.education_group,
         management_entity=self.entity,
         administration_entity=self.entity,
         academic_year=self.generated_ac_years.academic_years[0],
         linked_with_epc=True
     )
     protected_messages = shorten._get_protected_messages([edy])
     self.assertEqual(protected_messages[0]['messages'][0], _('Linked with EPC'))