def setUpTestData(cls):
     cls.person = PersonFactory()
     cls.language = settings.LANGUAGE_CODE_EN
     cls.anac = AcademicYearFactory()
     common_ba = EducationGroupYearCommonBachelorFactory(
         academic_year=cls.anac)
     common_m = EducationGroupYearCommonMasterFactory(
         academic_year=cls.anac)
     common_mc = EducationGroupYearCommonSpecializedMasterFactory(
         academic_year=cls.anac)
     common_2a = EducationGroupYearCommonAgregationFactory(
         academic_year=cls.anac)
     cls.common_egy = [common_ba, common_m, common_mc, common_2a]
     cls.data = {}
     for egy in cls.common_egy:
         ac = AdmissionConditionFactory(education_group_year=egy)
         relevant_attr = general_information_sections.COMMON_TYPE_ADMISSION_CONDITIONS[
             egy.education_group_type.name]
         cls.data[egy.acronym] = {
             field: getattr(ac, 'text_{}{}'.format(field, '_en')) or None
             for field in relevant_attr
         }
     cls.url = reverse(CommonAdmissionCondition.name,
                       kwargs={
                           'year': cls.anac.year,
                           'language': cls.language
                       })
Exemple #2
0
 def test_import_common_offer(self, mocker):
     education_group_year_list = [EducationGroupYearCommonMasterFactory()]
     from base.management.commands.import_reddot import import_common_offer
     context = None
     offer = {'year': education_group_year_list[0].academic_year.year}
     import_common_offer(context, offer, None)
     mocker.assert_called_with(offer, education_group_year_list[0], None,
                               context)
Exemple #3
0
 def test_without_education_group_year(self):
     EducationGroupFactory(start_year=self.academic_year.year,
                           end_year=self.academic_year.year + 1)
     self.assertEqual(EducationGroupYear.objects.count(), 0)
     EducationGroupYearCommonMasterFactory(academic_year=self.academic_year)
     self.assertEqual(EducationGroupYear.objects.count(), 1)
     create_common_offer_for_academic_year(self.academic_year.year)
     self.assertEqual(EducationGroupYear.objects.count(), 2)
 def setUpTestData(cls):
     egy = TrainingFactory(
         education_group_type__name=TrainingType.PGRM_MASTER_120.name)
     cls.ac = AdmissionConditionFactory(education_group_year=egy)
     common_egy = EducationGroupYearCommonMasterFactory(
         academic_year=egy.academic_year)
     AdmissionConditionFactory(education_group_year=common_egy)
     cls.serializer = MasterAdmissionConditionsSerializer(
         cls.ac, context={
             'lang': settings.LANGUAGE_CODE_EN,
         })
Exemple #5
0
    def test_admission_conditions_for_master(self):
        education_group_year = EducationGroupYearMasterFactory()

        admission_condition = AdmissionCondition.objects.create(education_group_year=education_group_year)
        admission_condition.text_university_bachelors = 'text_university_bachelors'
        admission_condition.save()

        education_group_year_common = EducationGroupYearCommonMasterFactory(
            academic_year=education_group_year.academic_year
        )

        admission_condition_common = AdmissionCondition.objects.create(
            education_group_year=education_group_year_common
        )
        admission_condition_common.text_free = 'text_free'
        admission_condition_common.text_personalized_access = 'text_personalized_access'
        admission_condition_common.text_adults_taking_up_university_training = 'text_adults_taking_up_university_training'
        admission_condition_common.text_admission_enrollment_procedures = 'text_admission_enrollment_procedures'
        admission_condition_common.save()

        iso_language, language = 'fr-be', 'fr'

        message = {
            'anac': education_group_year.academic_year.year,
            'code_offre': education_group_year.acronym,
            'sections': [
                'conditions_admissions'
            ]
        }

        response = self.post(education_group_year.academic_year.year,
                             language,
                             education_group_year.acronym,
                             data=message)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content_type, 'application/json')

        response_json = response.json()

        useless, condition_admissions_section = remove_conditions_admission(response_json['sections'])
        sections = condition_admissions_section['content']['sections']
        self.assertEqual(sections['university_bachelors']['text'], admission_condition.text_university_bachelors)
        self.assertEqual(sections['personalized_access']['text-common'],
                         admission_condition_common.text_personalized_access)
        self.assertEqual(sections['adults_taking_up_university_training']['text-common'],
                         admission_condition_common.text_adults_taking_up_university_training)
        self.assertEqual(sections['admission_enrollment_procedures']['text-common'],
                         admission_condition_common.text_admission_enrollment_procedures)
Exemple #6
0
 def setUpTestData(cls):
     cls.data_to_serialize = {'id': 'ID', 'dummy': 'DUMMY'}
     cls.language = settings.LANGUAGE_CODE_EN
     cls.egy = EducationGroupYearFactory(
         acronym='ARKE2M',
         education_group_type__name=TrainingType.PGRM_MASTER_120.name)
     common_egy = EducationGroupYearCommonMasterFactory(
         academic_year=cls.egy.academic_year)
     AdmissionConditionFactory(education_group_year=common_egy)
     AdmissionConditionFactory(education_group_year=cls.egy)
     cls.serializer = AdmissionConditionSectionSerializer(
         cls.data_to_serialize,
         context={
             'egy': cls.egy,
             'lang': cls.language
         })
Exemple #7
0
    def test_without_education_group_year(self):
        academic_year = AcademicYearFactory()
        self.assertEqual(EducationGroup.objects.count(), 0)

        from base.management.commands.import_reddot import OFFERS
        for offer in OFFERS:
            EducationGroupType.objects.create(name=offer['name'],
                                              category=offer['category'])

        from base.management.commands.import_reddot import create_common_offer_for_academic_year
        education_group = EducationGroupFactory(start_year=academic_year.year,
                                                end_year=academic_year.year +
                                                1)
        self.assertEqual(EducationGroupYear.objects.count(), 0)
        EducationGroupYearCommonMasterFactory(academic_year=academic_year)
        self.assertEqual(EducationGroupYear.objects.count(), 1)
        create_common_offer_for_academic_year(academic_year.year)
        self.assertEqual(EducationGroupYear.objects.count(), 2)
Exemple #8
0
    def test_raise_with_unknown_common_text(self):
        from webservices.views import process_section
        education_group_year = EducationGroupYearMasterFactory()
        education_group_year_common = EducationGroupYearCommonMasterFactory(
            academic_year=education_group_year.academic_year
        )

        context = new_context(education_group_year, 'fr-be', 'fr', education_group_year.acronym)

        text_label = TextLabelFactory(label='caap', entity='offer_year')
        translated_text_label = TranslatedTextLabelFactory(text_label=text_label, language=context.language)
        tt = TranslatedTextRandomFactory(text_label=text_label,
                                         language=context.language,
                                         reference=str(education_group_year_common.id),
                                         entity=text_label.entity)

        section = process_section(context, education_group_year, 'nothing-commun')
        self.assertIsNone(section['label'])
Exemple #9
0
    def test_find_common_text(self):
        from webservices.views import process_section
        education_group_year = EducationGroupYearMasterFactory()
        education_group_year_common = EducationGroupYearCommonMasterFactory(
            academic_year=education_group_year.academic_year,
        )

        context = new_context(education_group_year, 'fr-be', 'fr', education_group_year.acronym)

        text_label = TextLabelFactory(label='caap', entity='offer_year')
        translated_text_label = TranslatedTextLabelFactory(text_label=text_label, language=context.language)
        tt = TranslatedTextRandomFactory(text_label=text_label,
                                         language=context.language,
                                         reference=str(education_group_year_common.id),
                                         entity=text_label.entity)

        section = process_section(context, education_group_year, 'caap-commun')
        self.assertEqual(translated_text_label.text_label, text_label)
        self.assertEqual(section['label'], translated_text_label.label)
        self.assertEqual(section['content'], tt.text)
Exemple #10
0
    def test_admission_conditions_for_master_with_diplomas(self):
        education_group_year = EducationGroupYearMasterFactory()

        admission_condition = AdmissionCondition.objects.create(education_group_year=education_group_year)

        EducationGroupYearCommonMasterFactory(academic_year=education_group_year.academic_year)

        acl = AdmissionConditionLine.objects.create(admission_condition=admission_condition)
        acl.section = 'ucl_bachelors'
        acl.diploma = 'diploma'
        acl.conditions = 'conditions'
        acl.remarks = 'remarks'
        acl.access = CONDITION_ADMISSION_ACCESSES[2][0]
        acl.save()

        iso_language, language = 'fr-be', 'fr'

        message = {
            'anac': education_group_year.academic_year.year,
            'code_offre': education_group_year.acronym,
            'sections': [
                'conditions_admissions'
            ]
        }

        response = self.post(education_group_year.academic_year.year,
                             language,
                             education_group_year.acronym,
                             data=message)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.content_type, 'application/json')

        response_json = response.json()

        useless, condition_admissions_section = remove_conditions_admission(response_json['sections'])
        sections = condition_admissions_section['content']['sections']
        self.assertEqual(len(sections['university_bachelors']['records']['ucl_bachelors']), 1)
Exemple #11
0
    def test_with_one_section_with_common(self):
        education_group_year = EducationGroupYearMasterFactory()

        common_education_group_year = EducationGroupYearCommonMasterFactory(
            academic_year=education_group_year.academic_year,
        )

        text_label = TextLabelFactory(entity=OFFER_YEAR, label='caap')

        for iso_language, language in [('fr-be', 'fr'), ('en', 'en')]:
            with self.subTest(iso_language=iso_language, language=language):
                ttl = TranslatedTextLabelFactory(text_label=text_label,
                                                 language=iso_language)
                tt = TranslatedTextRandomFactory(text_label=text_label,
                                                 language=iso_language,
                                                 reference=education_group_year.id,
                                                 entity=text_label.entity)

                tt2 = TranslatedTextRandomFactory(text_label=text_label,
                                                  language=iso_language,
                                                  reference=common_education_group_year.id,
                                                  entity=text_label.entity)

                message = {
                    'code_offre': education_group_year.acronym,
                    'anac': str(education_group_year.academic_year.year),
                    'sections': [
                        text_label.label,
                        text_label.label + '-commun'
                    ]
                }

                response = self.post(
                    education_group_year.academic_year.year,
                    language,
                    education_group_year.acronym,
                    data=message
                )

                self.assertEqual(response.status_code, 200)
                self.assertEqual(response.content_type, 'application/json')

                response_json = response.json()

                title_to_test = education_group_year.title if language == 'fr' else education_group_year.title_english

                sections, conditions_admission_section = remove_conditions_admission(response_json.pop('sections', []))
                response_sections = convert_sections_list_of_dict_to_dict(sections)

                self.assertDictEqual(response_json, {
                    'acronym': education_group_year.acronym.upper(),
                    'language': language,
                    'title': title_to_test,
                    'year': education_group_year.academic_year.year,
                })

                sections = [{
                    'id': tt.text_label.label,
                    'label': ttl.label,
                    'content': tt.text,
                }, {
                    'id': tt.text_label.label + '-commun',
                    'label': ttl.label,
                    'content': tt2.text,
                }]
                sections = convert_sections_list_of_dict_to_dict(sections)

                self.assertDictEqual(response_sections, sections)