def setUp(self): # Create structure self._create_basic_entity_structure() # Create education group with 'CHIM' as entity cls self.education_group_year = EducationGroupYearFactory( management_entity=self.chim_entity)
def setUpTestData(cls): academic_yr = AcademicYearFactory() cls.grandfather = EducationGroupYearFactory( academic_year=academic_yr, ) cls.parent = EducationGroupYearFactory(academic_year=academic_yr, ) cls.child = EducationGroupYearFactory(academic_year=academic_yr, )
def setUp(self): self.education_group_year_1 = EducationGroupYearFactory(credits=10) self.education_group_year_2 = EducationGroupYearFactory(credits=20) self.learning_unit_year_1 = LearningUnitYearFactory() self.learning_unit_year_2 = LearningUnitYearFactory( periodicity=BIENNIAL_ODD) self.learning_unit_year_3 = LearningUnitYearFactory(status=False) self.learning_unit_year_4 = LearningUnitYearFactory( periodicity=BIENNIAL_EVEN) self.group_element_year_1 = GroupElementYearFactory( parent=self.education_group_year_1, child_branch=self.education_group_year_2, is_mandatory=True) self.group_element_year_2 = GroupElementYearFactory( parent=self.education_group_year_2, child_branch=None, child_leaf=self.learning_unit_year_1, is_mandatory=True) self.group_element_year_3 = GroupElementYearFactory( parent=self.education_group_year_2, child_branch=None, child_leaf=self.learning_unit_year_2, is_mandatory=True) self.group_element_year_4 = GroupElementYearFactory( parent=self.education_group_year_2, child_branch=None, child_leaf=self.learning_unit_year_3, is_mandatory=True) self.learning_component_year_1 = LearningComponentYearFactory( learning_container_year=self.learning_unit_year_1. learning_container_year, type=LECTURING) self.learning_component_year_2 = LearningComponentYearFactory( learning_container_year=self.learning_unit_year_1. learning_container_year, type=PRACTICAL_EXERCISES) self.learning_component_year_3 = LearningComponentYearFactory( learning_container_year=self.learning_unit_year_2. learning_container_year, type=LECTURING) self.learning_component_year_4 = LearningComponentYearFactory( learning_container_year=self.learning_unit_year_2. learning_container_year, type=PRACTICAL_EXERCISES) self.learning_component_year_5 = LearningComponentYearFactory( learning_container_year=self.learning_unit_year_3. learning_container_year, type=LECTURING) self.learning_component_year_6 = LearningComponentYearFactory( learning_container_year=self.learning_unit_year_3. learning_container_year, type=PRACTICAL_EXERCISES) self.learning_component_year_7 = LearningComponentYearFactory( learning_container_year=self.learning_unit_year_4. learning_container_year, type=LECTURING) self.learning_unit_component_1 = LearningUnitComponentFactory( learning_unit_year=self.learning_unit_year_1, learning_component_year=self.learning_component_year_1) self.learning_unit_component_2 = LearningUnitComponentFactory( learning_unit_year=self.learning_unit_year_1, learning_component_year=self.learning_component_year_2) self.learning_unit_component_3 = LearningUnitComponentFactory( learning_unit_year=self.learning_unit_year_2, learning_component_year=self.learning_component_year_3) self.learning_unit_component_4 = LearningUnitComponentFactory( learning_unit_year=self.learning_unit_year_2, learning_component_year=self.learning_component_year_4) self.learning_unit_component_5 = LearningUnitComponentFactory( learning_unit_year=self.learning_unit_year_3, learning_component_year=self.learning_component_year_5) self.learning_unit_component_6 = LearningUnitComponentFactory( learning_unit_year=self.learning_unit_year_3, learning_component_year=self.learning_component_year_6) self.learning_unit_component_7 = LearningUnitComponentFactory( learning_unit_year=self.learning_unit_year_4, learning_component_year=self.learning_component_year_7)
def setUpTestData(cls): cls.education_group_year = EducationGroupYearFactory() cls.organization = OrganizationFactory()
def test_check_unauthorized_type(self): education_group = EducationGroupYearFactory() result = check_authorized_type(education_group) self.assertFalse(result)
def test_type_property(self): education_group_year = EducationGroupYearFactory() self.assertEqual(education_group_year.type, education_group_year.education_group_type.name)
def setUpTestData(cls): cls.academic_year = AcademicYearFactory(year=2017) cls.learning_container_luy1 = LearningContainerYearFactory( academic_year=cls.academic_year) cls.learning_unit_yr_1 = LearningUnitYearFactory( academic_year=cls.academic_year, learning_container_year=cls.learning_container_luy1, credits=50) cls.learning_unit_yr_2 = LearningUnitYearFactory() cls.proposal_creation_1 = ProposalLearningUnitFactory( state=proposal_state.ProposalState.ACCEPTED.name, type=proposal_type.ProposalType.CREATION.name, ) cls.proposal_creation_2 = ProposalLearningUnitFactory( state=proposal_state.ProposalState.ACCEPTED.name, type=proposal_type.ProposalType.CREATION.name, ) direct_parent_type = EducationGroupTypeFactory( name='Bachelor', category=education_group_categories.TRAINING) cls.an_education_group_parent = EducationGroupYearFactory( academic_year=cls.academic_year, education_group_type=direct_parent_type, acronym=ROOT_ACRONYM) cls.group_element_child = GroupElementYearFactory( parent=cls.an_education_group_parent, child_branch=None, child_leaf=cls.learning_unit_yr_1) cls.an_education_group = EducationGroupYearFactory( academic_year=cls.academic_year, acronym=PARENT_ACRONYM, title=PARENT_TITLE, partial_acronym=PARENT_PARTIAL_ACRONYM) cls.group_element_child2 = GroupElementYearFactory( parent=cls.an_education_group, child_branch=cls.group_element_child.parent, ) cls.old_academic_year = AcademicYearFactory( year=datetime.date.today().year - 2) cls.current_academic_year = AcademicYearFactory( year=datetime.date.today().year) generatorContainer = GenerateContainer(cls.old_academic_year, cls.current_academic_year) cls.learning_unit_year_with_entities = generatorContainer.generated_container_years[ 0].learning_unit_year_full entities = [ EntityVersionFactory( start_date=datetime.datetime(1900, 1, 1), end_date=None, entity_type=entity_type.FACULTY, entity__organization__type=organization_type.MAIN) for _ in range(4) ] cls.learning_unit_year_with_entities.entity_requirement = entities[0] cls.learning_unit_year_with_entities.entity_allocation = entities[1] cls.proposal_creation_3 = ProposalLearningUnitFactory( learning_unit_year=cls.learning_unit_year_with_entities, state=proposal_state.ProposalState.ACCEPTED.name, type=proposal_type.ProposalType.CREATION.name, ) cls.learning_container_luy = LearningContainerYearFactory( academic_year=cls.academic_year) cls.luy_with_attribution = LearningUnitYearFactory( academic_year=cls.academic_year, learning_container_year=cls.learning_container_luy, periodicity=learning_unit_year_periodicity.ANNUAL, status=True, language=None, ) cls.luy_with_attribution.entity_requirement = entities[0] cls.luy_with_attribution.entity_allocation = entities[1] cls.component_lecturing = LearningComponentYearFactory( learning_unit_year=cls.luy_with_attribution, type=learning_component_year_type.LECTURING, hourly_volume_total_annual=15, hourly_volume_partial_q1=10, hourly_volume_partial_q2=5, planned_classes=1) cls.component_practical = LearningComponentYearFactory( learning_unit_year=cls.luy_with_attribution, type=learning_component_year_type.PRACTICAL_EXERCISES, hourly_volume_total_annual=15, hourly_volume_partial_q1=10, hourly_volume_partial_q2=5, planned_classes=1) a_person_tutor_1 = PersonFactory(last_name='Dupuis', first_name='Tom', email="*****@*****.**") cls.a_tutor_1 = TutorFactory(person=a_person_tutor_1) cls.an_attribution_1 = AttributionNewFactory(tutor=cls.a_tutor_1, start_year=2017, function=COORDINATOR) cls.attribution_charge_new_lecturing_1 = AttributionChargeNewFactory( learning_component_year=cls.component_lecturing, attribution=cls.an_attribution_1, allocation_charge=15.0) cls.attribution_charge_new_practical_1 = AttributionChargeNewFactory( learning_component_year=cls.component_practical, attribution=cls.an_attribution_1, allocation_charge=5.0) cls.a_tutor_2 = TutorFactory( person=PersonFactory(last_name='Maréchal', first_name='Didier')) cls.an_attribution_2 = AttributionNewFactory(tutor=cls.a_tutor_2, start_year=2017) cls.attribution_charge_new_lecturing_2 = AttributionChargeNewFactory( learning_component_year=cls.component_lecturing, attribution=cls.an_attribution_2, allocation_charge=15.0) cls.attribution_charge_new_practical_2 = AttributionChargeNewFactory( learning_component_year=cls.component_practical, attribution=cls.an_attribution_2, allocation_charge=5.0) cls.entity_requirement = EntityVersion.objects.filter(entity=OuterRef( 'learning_container_year__requirement_entity'), ).current( OuterRef('academic_year__start_date')).values('acronym')[:1] cls.entity_allocation = EntityVersion.objects.filter(entity=OuterRef( 'learning_container_year__allocation_entity'), ).current( OuterRef('academic_year__start_date')).values('acronym')[:1]
def setUp(self): self.education_group_year = EducationGroupYearFactory() self.organization = OrganizationFactory()
def setUp(self): self.academic_year = AcademicYearFactory(current=True) self.root = EducationGroupYearFactory(academic_year=self.academic_year)
def setUpTestData(cls): today = datetime.date.today() cls.academic_year = AcademicYearFactory( start_date=today, end_date=today.replace(year=today.year + 1), year=today.year) cls.previous_academic_year = AcademicYearFactory( start_date=today.replace(year=today.year - 1), end_date=today - datetime.timedelta(days=1), year=today.year - 1) cls.type_training = EducationGroupTypeFactory( category=education_group_categories.TRAINING) cls.type_minitraining = EducationGroupTypeFactory( category=education_group_categories.MINI_TRAINING) cls.type_group = EducationGroupTypeFactory( category=education_group_categories.GROUP) cls.education_group_edph2 = EducationGroupYearFactory( acronym='EDPH2', academic_year=cls.academic_year, partial_acronym='EDPH2_SCS', education_group_type=cls.type_group) cls.education_group_arke2a = EducationGroupYearFactory( acronym='ARKE2A', academic_year=cls.academic_year, education_group_type=cls.type_training) cls.education_group_hist2a = EducationGroupYearFactory( acronym='HIST2A', academic_year=cls.academic_year, education_group_type=cls.type_group) cls.education_group_arke2a_previous_year = EducationGroupYearFactory( acronym='ARKE2A', academic_year=cls.previous_academic_year, education_group_type=cls.type_training) oph_entity = EntityFactory() envi_entity = EntityFactory() cls.oph_entity_v = EntityVersionFactory(entity=oph_entity, parent=envi_entity, end_date=None) cls.envi_entity_v = EntityVersionFactory(entity=envi_entity, end_date=None) cls.offer_year_entity_edph2 = OfferYearEntityFactory( education_group_year=cls.education_group_edph2, entity=envi_entity, type=offer_year_entity_type.ENTITY_MANAGEMENT) cls.offer_year_entity_hist2a = OfferYearEntityFactory( education_group_year=cls.education_group_hist2a, entity=oph_entity, type=offer_year_entity_type.ENTITY_MANAGEMENT) cls.offer_year_entity_arke2a = OfferYearEntityFactory( education_group_year=cls.education_group_arke2a, type=offer_year_entity_type.ENTITY_MANAGEMENT, entity=oph_entity) cls.offer_year_entity_arke2a_previous_year = \ OfferYearEntityFactory(education_group_year=cls.education_group_arke2a_previous_year, entity=oph_entity, type=offer_year_entity_type.ENTITY_MANAGEMENT) cls.user = UserFactory() cls.user.user_permissions.add( Permission.objects.get(codename="can_access_education_group")) cls.url = reverse("education_groups")
def test_education_content(self): an_education_group = EducationGroupYearFactory() self.initialize_session() url = reverse("education_group_diplomas", args=[an_education_group.id]) response = self.client.get(url) self.assertTemplateUsed(response, "education_group/tab_diplomas.html")
def setUp(self): academic_yr = AcademicYearFactory() self.grandfather = EducationGroupYearFactory( academic_year=academic_yr, ) self.parent = EducationGroupYearFactory(academic_year=academic_yr, ) self.child = EducationGroupYearFactory(academic_year=academic_yr, )
def setUpTestData(cls): cls.user = UserFactory() cls.user_adri = UserFactory() entity_version = EntityVersionFactory(acronym='ADRI') PartnershipEntityManagerFactory(entity=entity_version.entity, person__user=cls.user_adri) cls.user_gs = UserFactory() cls.user_gf = UserFactory() cls.user_other_gf = UserFactory() cls.user_project = UserFactory() PartnershipEntityManagerFactory( entity=entity_version.entity, person__user=cls.user_project, scopes=[PartnershipType.PROJECT.name] ) # Dates : cls.partner = PartnerFactory() cls.partner_entity = PartnerEntityFactory(partner=cls.partner) # Years cls.academic_year_2149 = AcademicYearFactory(year=2149) cls.start_academic_year = AcademicYearFactory(year=2150) cls.from_academic_year = AcademicYearFactory(year=2151) cls.end_academic_year = AcademicYearFactory(year=2152) cls.academic_year_2153 = AcademicYearFactory(year=2153) # Initialize config PartnershipConfiguration.objects.update( partnership_creation_update_min_year_id=cls.academic_year_2149.pk ) cls.education_field = DomainIscedFactory() cls.education_level = PartnershipYearEducationLevelFactory() # Ucl root = EntityVersionFactory(parent=None).entity sector = EntityVersionFactory( entity_type=SECTOR, parent=root, ).entity cls.ucl_university = EntityVersionFactory( parent=sector, entity_type=FACULTY, ).entity UCLManagementEntityFactory(entity=cls.ucl_university) cls.ucl_university_labo = EntityVersionFactory( parent=cls.ucl_university, ).entity UCLManagementEntityFactory(entity=cls.ucl_university_labo) cls.ucl_university_not_choice = EntityVersionFactory( entity_type=FACULTY, ).entity cls.ucl_university_labo_not_choice = EntityVersionFactory( parent=cls.ucl_university_not_choice, ).entity cls.university_offer = EducationGroupYearFactory(administration_entity=cls.ucl_university_labo) PartnershipEntityManagerFactory(person__user=cls.user_gs, entity=sector) PartnershipEntityManagerFactory(person__user=cls.user_gf, entity=cls.ucl_university) PartnershipEntityManagerFactory(person__user=cls.user_other_gf, entity=cls.ucl_university) mission = PartnershipMission.objects.filter( types__contains=[PartnershipType.MOBILITY.name], ).first() cls.partner_gf = PartnerFactory(author=cls.user_gf.person) cls.partnership = PartnershipFactory( partner=cls.partner, partner_entity=cls.partner_entity.entity, author=cls.user_gf.person, years=[], ucl_entity=cls.ucl_university, missions=[mission], ) PartnershipYearFactory( partnership=cls.partnership, academic_year=cls.start_academic_year, ) PartnershipYearFactory( partnership=cls.partnership, academic_year=cls.from_academic_year, ) PartnershipYearFactory( partnership=cls.partnership, academic_year=cls.end_academic_year, ) cls.url = resolve_url('partnerships:update', pk=cls.partnership.pk) cls.other_partnership = PartnershipFactory( partnership_type=PartnershipType.PROJECT.name, ) cls.other_url = resolve_url('partnerships:update', pk=cls.other_partnership.pk) cls.data = { 'partnership_type': PartnershipType.MOBILITY.name, 'comment': '', 'partner': cls.partner.pk, 'partner_entities': [cls.partner_entity.entity_id], 'supervisor': '', 'ucl_entity': cls.ucl_university_labo.pk, 'year-is_sms': True, 'year-is_smp': False, 'year-is_smst': True, 'year-is_sta': True, 'year-is_stt': False, 'year-education_fields': [cls.education_field.pk], 'year-education_levels': [cls.education_level.pk], 'year-entities': [], 'year-offers': [], 'year-start_academic_year': cls.start_academic_year.pk, 'year-from_academic_year': cls.from_academic_year.pk, 'year-end_academic_year': cls.end_academic_year.pk, }
def setUpTestData(cls): cls.current_academic_yr = create_current_academic_year() cls.next_academic_yr = AcademicYearFactory( year=cls.current_academic_yr.year + 1) cls.start_date = date.today().replace(year=2010) cls.fac_1_older_version = EntityVersionFactory( acronym="DRT", entity_type=FACULTY, start_date=date.today().replace(year=2000), end_date=cls.start_date - timezone.timedelta(days=1)) cls.fac_1_version = EntityVersionFactory( acronym="DRT_NEW", entity_type=FACULTY, start_date=cls.start_date, end_date=None, ) cls.fac_2_version = EntityVersionFactory( acronym="AGRO", entity_type=FACULTY, start_date=cls.start_date, end_date=None, ) cls.fac_3_version_with_child = EntityVersionFactory( acronym="ESPO", entity_type=FACULTY, end_date=None, start_date=cls.start_date) cls.fac_3_child_version = EntityVersionFactory( acronym="ESPO_child", entity_type=SCHOOL, end_date=None, start_date=cls.start_date, parent=cls.fac_3_version_with_child.entity) cls.fac_4_version = EntityVersionFactory( acronym="ILV", entity_type=FACULTY, start_date=cls.start_date, end_date=None, ) letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'] cls.education_groups_fac_1_version = [ EducationGroupFactory(start_year=cls.current_academic_yr) for _ in range(0, len(letters)) ] cls.education_group_yrs = [ EducationGroupYearFactory( academic_year=cls.next_academic_yr, acronym='{}_FORM'.format(letters[index]), management_entity=cls.fac_1_version.entity, education_group=education_group) for index, education_group in enumerate(cls.education_groups_fac_1_version) ] cls.education_group_on_faculty = EducationGroupFactory( start_year=cls.current_academic_yr) cls.education_group_yr_on_faculty = EducationGroupYearFactory( academic_year=cls.next_academic_yr, acronym='E_FORM', management_entity=cls.fac_3_version_with_child.entity, education_group=cls.education_group_on_faculty) cls.education_group_on_faculty_child = EducationGroupFactory( start_year=cls.current_academic_yr) cls.education_group_yr_on_faculty_child = EducationGroupYearFactory( academic_year=cls.next_academic_yr, acronym='E_FORM_Child', management_entity=cls.fac_3_child_version.entity, education_group=cls.education_group_on_faculty_child) cls.admissions_fac_1_version = [ AdmissionFactory(formation=ContinuingEducationTrainingFactory( education_group=cls.education_groups_fac_1_version[index]), state=state, academic_year=cls.current_academic_yr) for index, state in enumerate( [SUBMITTED, REJECTED, WAITING, DRAFT, SUBMITTED]) ] cls.registrations = [ AdmissionFactory(formation=ContinuingEducationTrainingFactory( education_group=cls.education_groups_fac_1_version[ len(cls.admissions_fac_1_version) + index], ), state=state, ucl_registration_complete=index == 0, payment_complete=index != 0, academic_year=cls.current_academic_yr) for index, state in enumerate([ACCEPTED, REGISTRATION_SUBMITTED]) ] cls.education_group_on_fac4 = EducationGroupFactory( start_year=cls.current_academic_yr) cls.education_group_yr_on_faculty_child = EducationGroupYearFactory( academic_year=cls.next_academic_yr, acronym='E_FORM_Child', management_entity=cls.fac_4_version.entity, education_group=cls.education_group_on_fac4) cls.registration_validated = AdmissionFactory( formation=ContinuingEducationTrainingFactory( education_group=cls.education_group_on_fac4), state=VALIDATED, payment_complete=False, ucl_registration_complete=False, academic_year=cls.current_academic_yr) cls.all_registrations_expected = cls.registrations.copy() cls.all_registrations_expected.append(cls.registration_validated) cls.archived_submitted = AdmissionFactory( formation=ContinuingEducationTrainingFactory( education_group=cls.education_groups_fac_1_version[7], ), state=SUBMITTED, archived=True, academic_year=cls.current_academic_yr) ed_free_text_acronym = EducationGroupFactory( start_year=cls.current_academic_yr) EducationGroupYearFactory(acronym="TestText", academic_year=cls.next_academic_yr, education_group=ed_free_text_acronym) ed_free_text_title = EducationGroupFactory( start_year=cls.current_academic_yr) EducationGroupYearFactory(academic_year=cls.next_academic_yr, education_group=ed_free_text_title, title="bla TestText bla") ed = EducationGroupFactory(start_year=cls.current_academic_yr) EducationGroupYearFactory(academic_year=cls.next_academic_yr, education_group=ed) cls.formation_no_registration_required = ContinuingEducationTrainingFactory( education_group=ed, registration_required=False, ) cls.persons = [ PersonFactory(first_name="TestText"), PersonFactory(last_name="TestText"), PersonFactory(email="*****@*****.**") ] cls.eds = [ed_free_text_title, ed_free_text_acronym] cls.admissions_free_text = [] cls.country_accent = CountryFactory(name=COUNTRY_NAME_WITH_ACCENT) cls.country_without_accent = CountryFactory( name=COUNTRY_NAME_WITHOUT_ACCENT) cls.form = AdmissionFilterForm() cls.registration_form = RegistrationFilterForm()
def test_when_acronym_not_exists(self): EducationGroupYearFactory(acronym='CODE1') e = EducationGroupYearFactory.build(acronym='CODE2') e.clean_acronym()
def setUpTestData(cls): cls.education_group_year = EducationGroupYearFactory() cls.cms_text_label = TextLabelFactory()
def setUp(self): self.education_group_year = EducationGroupYearFactory()
def setUp(self): self.education_group_year = EducationGroupYearFactory() Context = collections.namedtuple('Context', 'entity language') self.context = Context(entity='offer_year', language='fr-be')
def test_get_contacts_intro_text_case_no_value(self): education_group_year = EducationGroupYearFactory() self.assertIsNone( business.get_contacts_intro_text(education_group_year, settings.LANGUAGE_CODE_FR))
def setUpTestData(cls): cls.current_academic_year = create_current_academic_year() cls.education_group_year = EducationGroupYearFactory( academic_year=cls.current_academic_year)
def test_when_options_in_finalities_are_not_consistent(self): root_grp = GroupElementYearFactory( parent=EducationGroupYearFactory( education_group_type__category=Categories.TRAINING.name, education_group_type__name=TrainingType.PGRM_MASTER_120.name, academic_year=self.current_academic_year, education_group__end_year=None ), child_branch=EducationGroupYearFactory( education_group_type__category=Categories.GROUP.name, education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name, academic_year=self.current_academic_year, education_group__end_year=None ) ) child_grp = GroupElementYearFactory( parent=root_grp.child_branch, child_branch=EducationGroupYearFactory( education_group_type__category=Categories.TRAINING.name, education_group_type__name=TrainingType.MASTER_MA_120.name, academic_year=self.current_academic_year, education_group__end_year=None ) ) child_child_grp = GroupElementYearFactory( parent=child_grp.child_branch, child_branch=EducationGroupYearFactory( education_group_type__category=Categories.MINI_TRAINING.name, education_group_type__name=MiniTrainingType.OPTION.name, academic_year=self.current_academic_year, education_group__end_year=None ) ) root_egy_n1 = EducationGroupYearFactory( education_group_type=root_grp.parent.education_group_type, education_group=root_grp.parent.education_group, academic_year=self.next_academic_year ) child_egy_n1 = EducationGroupYearFactory( acronym=child_grp.child_branch.acronym, partial_acronym=child_grp.child_branch.partial_acronym, education_group_type=child_grp.child_branch.education_group_type, education_group=child_grp.child_branch.education_group, academic_year=self.next_academic_year, ) child_child_egy_n1 = EducationGroupYearFactory( acronym=child_child_grp.child_branch.acronym, partial_acronym=child_child_grp.child_branch.partial_acronym, education_group_type=child_child_grp.child_branch.education_group_type, education_group=child_child_grp.child_branch.education_group, academic_year=self.next_academic_year, ) self.postponer = PostponeContent(root_grp.parent) self.postponer.postpone() self.assertEqual( _("The option %(education_group_year_option)s is not anymore accessible in " "%(education_group_year_root)s " "in %(academic_year)s => It is retired of the finality %(education_group_year_finality)s.") % { "education_group_year_option": "{} - {}".format(child_child_grp.child_branch.partial_acronym, child_child_grp.child_branch.acronym), "education_group_year_root": "{} - {}".format(root_egy_n1.partial_acronym, root_egy_n1.acronym), "education_group_year_finality": "{} - {}".format(child_grp.child_branch.partial_acronym, child_grp.child_branch.acronym), "academic_year": self.next_academic_year }, str(self.postponer.warnings[0]) )
def setUpTestData(cls): cls.user = UserFactory() cls.user_adri = UserFactory() cls.user_gs = UserFactory() cls.user_gf = UserFactory() cls.user_other_gf = UserFactory() cls.user_2_types = UserFactory() root = EntityVersionFactory(parent=None).entity entity_version = EntityVersionFactory(acronym='ADRI', parent=root) PartnershipEntityManagerFactory( entity=entity_version.entity, person__user=cls.user_adri, ) PartnershipEntityManagerFactory(entity=entity_version.entity, person__user=cls.user_2_types, scopes=[ PartnershipType.MOBILITY.name, PartnershipType.GENERAL.name ]) cls.partner = PartnerFactory() cls.partner_entity = PartnerEntityFactory(partner=cls.partner) cls.partner_entity_2 = PartnerEntityFactory(partner=cls.partner) cls.start_academic_year = AcademicYearFactory(year=2150) cls.end_academic_year = AcademicYearFactory(year=2151) AcademicYearFactory.produce_in_future(quantity=3) cls.education_field = DomainIscedFactory() cls.education_level = PartnershipYearEducationLevelFactory() cls.url = reverse('partnerships:create') cls.mobility_url = reverse( 'partnerships:create', kwargs={'type': PartnershipType.MOBILITY}, ) # Ucl sector = EntityVersionFactory( parent=root, entity_type=SECTOR, ).entity cls.ucl_university = EntityVersionFactory( parent=sector, entity_type=FACULTY, ).entity cls.ucl_university_labo = EntityVersionFactory( parent=cls.ucl_university, ).entity UCLManagementEntityFactory(entity=cls.ucl_university) UCLManagementEntityFactory() cls.ucl_university_not_choice = EntityVersionFactory( entity_type=FACULTY, ).entity cls.ucl_university_labo_not_choice = EntityVersionFactory( parent=cls.ucl_university_not_choice, ).entity cls.university_offer = EducationGroupYearFactory( administration_entity=cls.ucl_university_labo) PartnershipEntityManagerFactory(person__user=cls.user_gs, entity=sector) PartnershipEntityManagerFactory(person__user=cls.user_gf, entity=cls.ucl_university) PartnershipEntityManagerFactory(person__user=cls.user_other_gf, entity=cls.ucl_university) PartnershipEntityManagerFactory(person__user=cls.user_2_types, entity=cls.ucl_university) cls.data = { 'partnership_type': PartnershipType.MOBILITY.name, 'comment': '', 'partner': cls.partner.pk, 'partner_entities': [cls.partner_entity.entity_id], 'supervisor': '', 'ucl_entity': cls.ucl_university.pk, 'university_offers': [cls.university_offer.pk], 'year-is_sms': True, 'year-is_smp': False, 'year-is_sta': True, 'year-is_stt': False, 'year-education_fields': [cls.education_field.pk], 'year-education_levels': [cls.education_level.pk], 'year-entities': [], 'year-offers': [], 'year-start_academic_year': cls.start_academic_year.pk, 'year-end_academic_year': cls.end_academic_year.pk, 'missions': [PartnershipMissionFactory().pk], }
def test_case_complex_hierarchy(self): education_group_year_child = EducationGroupYearFactory( academic_year=self.academic_year) EntityVersionFactory( entity=education_group_year_child.management_entity, acronym="CHILD") education_group_year_parent1 = EducationGroupYearFactory( academic_year=self.academic_year) EntityVersionFactory( entity=education_group_year_parent1.management_entity, acronym="PARENT1") GroupElementYearFactory(parent=education_group_year_parent1, child_branch=education_group_year_child) education_group_year_parent2 = EducationGroupYearFactory( academic_year=self.academic_year) EntityVersionFactory( entity=education_group_year_parent2.management_entity, acronym="PARENT2") GroupElementYearFactory(parent=education_group_year_parent2, child_branch=education_group_year_child) education_group_year_parent3 = EducationGroupYearFactory( academic_year=self.academic_year) EntityVersionFactory( entity=education_group_year_parent3.management_entity, acronym="PARENT3") GroupElementYearFactory(parent=education_group_year_parent3, child_branch=education_group_year_parent1) education_group_year_parent4 = EducationGroupYearFactory( academic_year=self.academic_year) EntityVersionFactory( entity=education_group_year_parent4.management_entity, acronym="PARENT4") GroupElementYearFactory(parent=education_group_year_parent4, child_branch=education_group_year_parent1) education_group_year_parent5 = EducationGroupYearFactory( academic_year=self.academic_year) EntityVersionFactory( entity=education_group_year_parent5.management_entity, acronym="PARENT5") GroupElementYearFactory(parent=education_group_year_parent5, child_branch=education_group_year_child) GroupElementYearFactory(parent=education_group_year_parent5, child_branch=education_group_year_parent2) education_group_year_parent6 = EducationGroupYearFactory( academic_year=self.academic_year) EntityVersionFactory( entity=education_group_year_parent6.management_entity, acronym="PARENT6") GroupElementYearFactory(parent=education_group_year_parent6, child_branch=education_group_year_parent5) education_group_year_child.management_entity = None education_group_year_child.save() education_group_year_parent1.management_entity = None education_group_year_parent1.save() education_group_year_parent5.management_entity = None education_group_year_parent5.save() self.assertCountEqual( get_education_group_year_eligible_management_entities( education_group_year_child), [ education_group_year_parent2.management_entity, education_group_year_parent3.management_entity, education_group_year_parent4.management_entity, education_group_year_parent6.management_entity, ])
def test_clean_case_no_duration_with_duration_unit(self): e = EducationGroupYearFactory(duration=None, duration_unit=duration_unit.QUADRIMESTER) with self.assertRaises(ValidationError): e.clean()
def test_check_authorized_type(self): education_group = EducationGroupYearFactory() AuthorizedRelationshipFactory( parent_type=education_group.education_group_type) result = check_authorized_type(education_group) self.assertTrue(result)
def test_clean_case_no_duration_unit_with_duration(self): e = EducationGroupYearFactory(duration=1, duration_unit=None) with self.assertRaises(ValidationError): e.clean()
def test_case_different_objects_instances(self): with self.assertRaises(AttributeError): group_element_year._raise_if_incorrect_instance( [EducationGroupYearFactory(), LearningUnitYearFactory()])
def test_when_acronym_existed_in_past(self): EducationGroupYearFactory(acronym=self.acronym, academic_year=self.previous_acy) e = EducationGroupYearFactory.build(acronym=self.acronym, academic_year=self.current_acy) e.clean_acronym()
def test_postpone(self): self.current_education_group_year = EducationGroupYearFactory( academic_year=self.current_year) publication_contact_entity = EntityFactory() self.previous_education_group_year = EducationGroupYearFactory( academic_year=self.previous_year, education_group=self.current_education_group_year.education_group, publication_contact_entity=publication_contact_entity, ) TranslatedTextFactory( entity=OFFER_YEAR, reference=str(self.previous_education_group_year.pk), text= "It is our choices, Harry, that show what we truly are, far more than our abilities." ) EducationGroupPublicationContactFactory( education_group_year=self.previous_education_group_year) EducationGroupDetailedAchievementFactory( education_group_achievement__education_group_year=self. previous_education_group_year) AdmissionConditionLineFactory( admission_condition__education_group_year=self. previous_education_group_year, section="nothing else matters") # this object will be removed during the copy. AdmissionConditionLineFactory( admission_condition__education_group_year=self. current_education_group_year, section="the world is dying.") postponer = ReddotEducationGroupAutomaticPostponement() postponer.postpone() self.assertEqual(len(postponer.result), 1) self.assertEqual(len(postponer.errors), 0) self.assertEqual( TranslatedText.objects.get( entity=OFFER_YEAR, reference=str(self.current_education_group_year.pk)).text, "It is our choices, Harry, that show what we truly are, far more than our abilities." ) self.assertTrue( EducationGroupPublicationContact.objects.filter( education_group_year=self.current_education_group_year).exists( )) self.current_education_group_year.refresh_from_db() self.assertEqual( self.current_education_group_year.publication_contact_entity, publication_contact_entity) self.assertTrue( EducationGroupDetailedAchievement.objects.filter( education_group_achievement__education_group_year=self. current_education_group_year).exists()) self.assertTrue( AdmissionConditionLine.objects.get( admission_condition__education_group_year=self. current_education_group_year).section, "nothing else matters")
def setUpTestData(cls): cls.luy_to_find = LearningUnitYearFactory(acronym='CYN', specific_title='Drop dead cynical') cls.egy_to_find = EducationGroupYearFactory(acronym='RAV', title='The Ravenlord') cls.user = SuperUserFactory()