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
                       })
示例#2
0
 def setUpTestData(cls):
     cls.current_academic_year = create_current_academic_year()
     OpenAcademicCalendarFactory(reference=EDUCATION_GROUP_EDITION,
                                 academic_year=cls.current_academic_year,
                                 data_year=cls.current_academic_year)
     cls.common_bachelor = EducationGroupYearCommonBachelorFactory(
         academic_year=cls.current_academic_year)
     cls.training = TrainingFactory(academic_year=cls.current_academic_year)
示例#3
0
    def test_get_publish_url_case_common_type(self):
        bachelor_common = EducationGroupYearCommonBachelorFactory()
        expected_url = "{api_url}/{endpoint}".format(
            api_url=settings.ESB_API_URL,
            endpoint=settings.ESB_REFRESH_COMMON_ADMISSION_ENDPOINT.format(
                year=bachelor_common.academic_year.year),
        )

        self.assertEqual(expected_url, _get_url_to_publish(bachelor_common))
 def setUpTestData(cls):
     egy = EducationGroupYearFactory(
         education_group_type__name=TrainingType.BACHELOR.name)
     cls.ac = AdmissionConditionFactory(education_group_year=egy)
     common_egy = EducationGroupYearCommonBachelorFactory(
         academic_year=egy.academic_year)
     AdmissionConditionFactory(education_group_year=common_egy)
     cls.serializer = BachelorAdmissionConditionsSerializer(
         cls.ac, context={
             'lang': settings.LANGUAGE_CODE_EN,
         })
示例#5
0
    def test_is_faculty_manager_case_cannot_modify_data_in_past(self):
        previous_year = self.current_academic_year.year - 1

        training_in_past = TrainingFactory(academic_year__year=previous_year)
        common_in_past = EducationGroupYearCommonBachelorFactory(academic_year__year=previous_year)
        faculty_manager = FacultyManagerFactory()

        for education_group_year in [training_in_past, common_in_past]:
            perm = AdmissionConditionPerms(faculty_manager.user, education_group_year)
            with self.assertRaises(PermissionDenied):
                perm._is_faculty_manager_eligible()
示例#6
0
    def test_load_admission_conditions_for_bachelor(self):
        education_group_year_common = EducationGroupYearCommonBachelorFactory()
        item = {
            'year': education_group_year_common.academic_year.year,
            'acronym': '1ba',
            'info': {
                'alert_message': {
                    'text-common': 'Alert Message'
                },
                'ca_bacs_cond_generales': {
                    'text-common': 'General Conditions'
                },
                'ca_bacs_cond_particulieres': {
                    'text-common': 'Specific Conditions'
                },
                'ca_bacs_examen_langue': {
                    'text-common': 'Language Exam'
                },
                'ca_bacs_cond_speciales': {
                    'text-common': 'Special Conditions'
                },
            }
        }

        self.command.load_admission_conditions_for_bachelor(
            item, education_group_year_common.academic_year.year)

        common_bacs = EducationGroupYear.objects.filter(
            academic_year=education_group_year_common.academic_year,
            acronym='common-1ba').first()

        admission_condition = AdmissionCondition.objects.get(
            education_group_year=common_bacs)
        info = item['info']
        self.assertEqual(admission_condition.text_alert_message,
                         info['alert_message']['text-common'])
        self.assertEqual(admission_condition.text_ca_bacs_cond_generales,
                         info['ca_bacs_cond_generales']['text-common'])
        self.assertEqual(admission_condition.text_ca_bacs_cond_particulieres,
                         info['ca_bacs_cond_particulieres']['text-common'])
        self.assertEqual(admission_condition.text_ca_bacs_examen_langue,
                         info['ca_bacs_examen_langue']['text-common'])
        self.assertEqual(admission_condition.text_ca_bacs_cond_speciales,
                         info['ca_bacs_cond_speciales']['text-common'])
示例#7
0
    def test_admission_conditions_for_bachelors_with_common(self):
        education_group_year = EducationGroupYearFactory(acronym='hist1ba')

        education_group_year_common = EducationGroupYearCommonBachelorFactory(
            academic_year=education_group_year.academic_year
        )

        admission_condition_common = AdmissionCondition.objects.create(
            education_group_year=education_group_year_common,
            text_alert_message='alert',
            text_ca_bacs_cond_generales='this is a test')

        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'])

        self.assertDictEqual(condition_admissions_section, {
            'id': 'conditions_admission',
            'label': 'conditions_admission',
            'content': {
                'alert_message': 'alert',
                'ca_bacs_cond_generales': 'this is a test',
                'ca_bacs_cond_particulieres': '',
                'ca_bacs_examen_langue': '',
                'ca_bacs_cond_speciales': '',
            }
        })
示例#8
0
 def setUpTestData(cls):
     cls.current_academic_year = create_current_academic_year()
     cls.common_bachelor = EducationGroupYearCommonBachelorFactory(
         academic_year=cls.current_academic_year)
     cls.training = TrainingFactory(academic_year=cls.current_academic_year)