def test_import_common_offer(self, mocker): education_group_year_list = [EducationGroupYearCommonFactory()] from base.management.commands.import_reddot import import_common_offer Context = collections.namedtuple('Context', 'entity language') 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)
def test_get_publish_url_case_is_common_of_common(self): common = EducationGroupYearCommonFactory() expected_url = "{api_url}/{endpoint}".format( api_url=settings.ESB_API_URL, endpoint=settings.ESB_REFRESH_COMMON_PEDAGOGY_ENDPOINT.format( year=common.academic_year.year), ) self.assertEqual(expected_url, _get_url_to_publish(common))
def test_get_relevant_sections_case_common_ensure_webservice_not_called( self, mock_requests): common = EducationGroupYearCommonFactory() expected_section = [ AGREGATION, CAAP, PREREQUISITE, COMMON_DIDACTIC_PURPOSES, COMPLEMENTARY_MODULE, EVALUATION ] sections = general_information.get_relevant_sections(common) self.assertFalse(mock_requests.called) self.assertListEqual(sections, expected_section)
def setUpTestData(cls): cls.language = settings.LANGUAGE_CODE_EN cls.egy = EducationGroupYearCommonFactory() cls.pertinent_sections = general_information_sections.SECTIONS_PER_OFFER_TYPE['common'] cls.data = {} for section in cls.pertinent_sections['specific']: tt = TranslatedTextFactory( reference=cls.egy.id, entity=OFFER_YEAR, language=cls.language, text_label__label=section ) cls.data[tt.text_label.label] = tt.text cls.serializer = CommonTextSerializer(cls.data, context={'language': cls.language})
def setUpTestData(cls): # Common offer must exist cls.academic_year = create_current_academic_year() EducationGroupYearCommonFactory(academic_year=cls.academic_year) cls.training = EducationGroupYearMasterFactory( academic_year=cls.academic_year, ) cls.publication_contact = EducationGroupPublicationContactFactory( education_group_year=cls.training, type=PublicationContactType.ACADEMIC_RESPONSIBLE.name ) # Create a central manager and linked it to entity of training cls.person = CentralManagerFactory("change_educationgroup", "can_access_education_group") PersonEntityFactory(person=cls.person, entity=cls.training.management_entity)
def test_main_common_show_only_identification_and_general_information( self): main_common = EducationGroupYearCommonFactory( academic_year=self.academic_year) url = reverse("education_group_read", args=[main_common.pk, main_common.pk]) response = self.client.get(url) self.assertTrue(response.context['show_identification']) self.assertTrue(response.context['show_general_information']) self.assertFalse(response.context['show_diploma']) self.assertFalse(response.context['show_skills_and_achievements']) self.assertFalse(response.context['show_administrative']) self.assertFalse(response.context['show_content']) self.assertFalse(response.context['show_utilization']) self.assertFalse(response.context['show_admission_conditions'])
def setUp(self): # Common offer must exist self.academic_year = create_current_academic_year() EducationGroupYearCommonFactory(academic_year=self.academic_year) self.training = TrainingFactory(academic_year=self.academic_year) self.publication_contact = EducationGroupPublicationContactFactory( education_group_year=self.training, type=PublicationContactType.ACADEMIC_RESPONSIBLE.name) # Create a central manager and linked it to entity of training self.person = CentralManagerFactory("change_educationgroup", "can_access_education_group") PersonEntityFactory(person=self.person, entity=self.training.management_entity) self.client.force_login(self.person.user)
def setUpTestData(cls): cls.person = PersonFactory() cls.language = settings.LANGUAGE_CODE_EN cls.egy = EducationGroupYearCommonFactory() cls.pertinent_sections = general_information_sections.SECTIONS_PER_OFFER_TYPE[ 'common'] cls.data = {} for section in cls.pertinent_sections['specific']: tt = TranslatedTextFactory(reference=cls.egy.id, entity=OFFER_YEAR, language=cls.language, text_label__label=section) cls.data[tt.text_label.label] = tt.text cls.url = reverse(CommonText.name, kwargs={ 'year': cls.egy.academic_year.year, 'language': cls.language })
def setUp(self): self.education_group_year = EducationGroupYearFactory(acronym='ACTU2M') common_education_group_year = EducationGroupYearCommonFactory( academic_year=self.education_group_year.academic_year ) self.cms_label_name = 'evaluation' text_label = TextLabelFactory(entity=OFFER_YEAR, label='evaluation') TranslatedTextLabelFactory(text_label=text_label, language='fr-be') self.evaluation = TranslatedTextRandomFactory(text_label=text_label, language='fr-be', reference=self.education_group_year.id, entity=text_label.entity) self.common = TranslatedTextRandomFactory(text_label=text_label, language='fr-be', reference=common_education_group_year.id, entity=text_label.entity)
def setUpTestData(cls): cls.egy = TrainingFactory( education_group_type__name=TrainingType.PGRM_MASTER_120.name) cls.common_egy = EducationGroupYearCommonFactory( academic_year=cls.egy.academic_year) cls.language = settings.LANGUAGE_CODE_EN cls.pertinent_sections = { 'specific': [DETAILED_PROGRAM, SKILLS_AND_ACHIEVEMENTS], 'common': [COMMON_DIDACTIC_PURPOSES] } for section in cls.pertinent_sections['common']: TranslatedTextLabelFactory(language=cls.language, text_label__label=section) TranslatedTextFactory( reference=cls.common_egy.id, entity=OFFER_YEAR, language=cls.language, text_label__label=section, ) for section in cls.pertinent_sections['specific']: TranslatedTextLabelFactory(language=cls.language, text_label__label=section) TranslatedTextFactory(reference=cls.egy.id, entity=OFFER_YEAR, language=cls.language, text_label__label=section) for label in [ SKILLS_AND_ACHIEVEMENTS_INTRO, SKILLS_AND_ACHIEVEMENTS_EXTRA ]: TranslatedTextFactory(text_label__label=label, reference=cls.egy.id, entity=OFFER_YEAR, language=cls.language) cls.serializer = GeneralInformationSerializer(cls.egy, context={ 'language': cls.language, 'acronym': cls.egy.acronym })
def setUpTestData(cls): cls.person = PersonFactory() cls.language = settings.LANGUAGE_CODE_EN cls.egy = EducationGroupYearFactory() common_egy = EducationGroupYearCommonFactory(academic_year=cls.egy.academic_year) cls.pertinent_sections = { 'specific': [EVALUATION_KEY, DETAILED_PROGRAM, SKILLS_AND_ACHIEVEMENTS], 'common': [COMMON_DIDACTIC_PURPOSES, EVALUATION_KEY] } for section in cls.pertinent_sections['common']: TranslatedTextLabelFactory(language=cls.language, text_label__label=section) TranslatedTextFactory( reference=common_egy.id, entity=OFFER_YEAR, language=cls.language, text_label__label=section ) for section in cls.pertinent_sections['specific']: if section != EVALUATION_KEY: TranslatedTextLabelFactory(language=cls.language, text_label__label=section) TranslatedTextFactory( reference=cls.egy.id, entity=OFFER_YEAR, language=cls.language, text_label__label=section ) for label in [SKILLS_AND_ACHIEVEMENTS_INTRO, SKILLS_AND_ACHIEVEMENTS_EXTRA]: TranslatedTextFactory( text_label__label=label, reference=cls.egy.id, entity=OFFER_YEAR, language=cls.language ) cls.url = reverse('generalinformations_read', kwargs={ 'acronym': cls.egy.acronym, 'year': cls.egy.academic_year.year, 'language': cls.language })
def setUpTestData(cls): cls.egy = TrainingFactory( education_group_type__name=TrainingType.PGRM_MASTER_120.name) EducationGroupYearCommonFactory(academic_year=cls.egy.academic_year) cls.language = settings.LANGUAGE_CODE_EN