def setUp(self): self.person = PersonFactory() an_organization = OrganizationFactory(type=organization_type.MAIN) current_academic_year = create_current_academic_year() learning_container_year = LearningContainerYearFactory( academic_year=current_academic_year, container_type=learning_container_year_types.COURSE, campus=CampusFactory(organization=an_organization, is_administration=True)) self.learning_unit_year = LearningUnitYearFakerFactory( credits=5, subtype=learning_unit_year_subtypes.FULL, academic_year=current_academic_year, learning_container_year=learning_container_year) self.entity_container_year = EntityContainerYearFactory( learning_container_year=self.learning_unit_year. learning_container_year, type=entity_container_year_link_type.REQUIREMENT_ENTITY) today = datetime.date.today() an_entity = EntityFactory(organization=an_organization) self.entity_version = EntityVersionFactory( entity=an_entity, entity_type=entity_type.SCHOOL, start_date=today, end_date=today.replace(year=today.year + 1)) self.language = LanguageFactory(code="EN") self.campus = CampusFactory( name="OSIS Campus", organization=OrganizationFactory(type=organization_type.MAIN), is_administration=True) self.form_data = { "academic_year": self.learning_unit_year.academic_year.id, "first_letter": "L", "acronym": "OSIS1245", "common_title": "New common title", "common_title_english": "New common title english", "specific_title": "New title", "specific_title_english": "New title english", "container_type": self.learning_unit_year.learning_container_year.container_type, "internship_subtype": "", "credits": "4", "periodicity": learning_unit_periodicity.BIENNIAL_ODD, "status": False, "language": self.language.pk, "quadrimester": learning_unit_year_quadrimesters.Q1, "campus": self.campus.id, "requirement_entity": self.entity_version.id, "allocation_entity": self.entity_version.id, "entity": self.entity_version.id, "folder_id": "1", "state": proposal_state.ProposalState.CENTRAL.name }
class TestCampus(TestCase): def setUp(self): self.campus = CampusFactory() def test_find_by_id(self): campus_id = self.campus.id self.assertEqual(self.campus, campus.find_by_id(campus_id)) self.campus.delete() self.assertIsNone(campus.find_by_id(campus_id))
def setUp(self): current_academic_year = create_current_academic_year() an_organization = OrganizationFactory(type=organization_type.MAIN) learning_container_year = LearningContainerYearFactory( academic_year=current_academic_year, container_type=learning_container_year_types.COURSE, requirement_entity=EntityFactory()) self.learning_unit_year = LearningUnitYearFakerFactory( credits=5, subtype=learning_unit_year_subtypes.FULL, academic_year=current_academic_year, learning_container_year=learning_container_year, campus=CampusFactory(organization=an_organization, is_administration=True)) today = datetime.date.today() an_entity = EntityFactory(organization=an_organization) self.entity_version = EntityVersionFactory( entity=an_entity, entity_type=entity_type.SCHOOL, start_date=today, end_date=today.replace(year=today.year + 1)) self.learning_component_year_lecturing = LearningComponentYearFactory( type=learning_component_year_type.LECTURING, acronym="PM", learning_unit_year=self.learning_unit_year) self.learning_component_year_practical = LearningComponentYearFactory( type=learning_component_year_type.PRACTICAL_EXERCISES, acronym="PP", learning_unit_year=self.learning_unit_year)
def test_valid_post_request_with_postponement_and_existing_proposal(self): luy_next_year = LearningUnitYearFactory( learning_unit=self.learning_unit_year.learning_unit, academic_year=AcademicYearFactory(year=self.an_academic_year.year + 1), learning_container_year=self.learning_container_year, acronym="LOSIS4512", subtype=learning_unit_year_subtypes.FULL, attribution_procedure=attribution_procedure.INTERNAL_TEAM, credits=15, campus=CampusFactory(organization=OrganizationFactory(type=organization_type.MAIN)), internship_subtype=None, ) ProposalLearningUnitFactory( learning_unit_year=luy_next_year ) credits = 17 form_data = self._get_valid_form_data() form_data['credits'] = credits form_data['container_type'] = learning_container_year_types.COURSE form_data['postponement'] = 1 # This values triggers postponement switch in view response = self.client.post(self.url, data=form_data) expected_redirection = reverse("learning_unit", args=[self.learning_unit_year.id]) self.assertRedirects(response, expected_redirection) self.learning_unit_year.refresh_from_db() self.assertEqual(self.learning_unit_year.credits, credits) msg = [m.message for m in get_messages(response.wsgi_request) if m.level == messages.SUCCESS] self.assertEqual( msg[0], _('The learning unit has been updated (the report has not been done from %(year)s because the learning ' 'unit is in proposal).') % {'year': luy_next_year.academic_year} )
def setUp(self): self.academic_year = create_current_academic_year() self.next_academic_year = AcademicYearFactory(year=self.academic_year.year + 1) self.learning_container_year = LearningContainerYearFactory(academic_year=self.academic_year, common_title='common title', language=LanguageFactory(code='EN', name='English'), campus=CampusFactory(name='MIT')) self.learning_unit_year = _create_learning_unit_year_with_components(self.learning_container_year, create_lecturing_component=True, create_pratical_component=True) an_entity = EntityFactory() self.entity_version = EntityVersionFactory(entity=an_entity, parent=None, end_date=None, acronym="DRT") self.allocation_entity = _create_entity_container_with_entity_components( self.learning_unit_year, entity_container_year_link_type.ALLOCATION_ENTITY, an_entity ) self.requirement_entity = _create_entity_container_with_entity_components( self.learning_unit_year, entity_container_year_link_type.REQUIREMENT_ENTITY, an_entity, repartition_lecturing=30, repartition_practical_exercises=10 ) self.add_requirement_entity_1 = _create_entity_container_with_entity_components( self.learning_unit_year, entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1, an_entity, repartition_lecturing=10, repartition_practical_exercises=5 )
def setUpTestData(cls, **kwargs): cls.education_group_type = kwargs.pop('education_group_type') cls.campus = CampusFactory(organization__type=organization_type.MAIN) cls.academic_year = AcademicYearFactory() new_entity_version = MainEntityVersionFactory() cls.form_data = { "acronym": "ACRO4569", "partial_acronym": "PACR8974", "education_group_type": cls.education_group_type.id, "title": "Test data", "main_teaching_campus": cls.campus.id, "academic_year": cls.academic_year.id, "management_entity": new_entity_version.pk, "remark": "This is a test!!" } cls.parent_education_group_year = EducationGroupYearFactory( academic_year=cls.academic_year) # Append version to management/administration entity cls.entity_version = EntityVersionFactory( entity=cls.parent_education_group_year.management_entity) if cls.education_group_type.category == TRAINING: EntityVersionFactory( entity=cls.parent_education_group_year.administration_entity) # Create user and attached it to management entity person = PersonFactory() PersonEntityFactory( person=person, entity=cls.parent_education_group_year.management_entity) cls.user = person.user
def _get_valid_post_data(category): entity_version = MainEntityVersionFactory() education_group_type = EducationGroupTypeFactory(category=category) campus = CampusFactory(organization__type=organization_type.MAIN) current_academic_year = create_current_academic_year() fake_education_group_year = EducationGroupYearFactory.build( academic_year=current_academic_year, management_entity=entity_version.entity, main_teaching_campus=campus, education_group_type=education_group_type, education_group__start_year=current_academic_year.year, constraint_type=CREDITS, ) AuthorizedRelationshipFactory(child_type=fake_education_group_year.education_group_type) post_data = { 'main_teaching_campus': str(fake_education_group_year.main_teaching_campus.id), 'management_entity': str(entity_version.id), 'remark_english': str(fake_education_group_year.remark_english), 'title_english': str(fake_education_group_year.title_english), 'partial_acronym': str(fake_education_group_year.partial_acronym), 'end_year': str(fake_education_group_year.education_group.end_year), 'start_year': str(fake_education_group_year.education_group.start_year), 'title': str(fake_education_group_year.title), 'credits': str(fake_education_group_year.credits), 'academic_year': str(fake_education_group_year.academic_year.id), 'constraint_type': CREDITS, 'max_constraint': str(fake_education_group_year.max_constraint), 'min_constraint': str(fake_education_group_year.min_constraint), 'remark': str(fake_education_group_year.remark), 'acronym': str(fake_education_group_year.acronym), 'active': str(fake_education_group_year.active), 'schedule_type': str(fake_education_group_year.schedule_type), } return fake_education_group_year, post_data
def _create_learning_unit_year_with_components(l_container, create_lecturing_component=True, create_pratical_component=True): language = LanguageFactory(code='EN', name='English') a_learning_unit_year = LearningUnitYearFactory( learning_container_year=l_container, acronym=l_container.acronym, academic_year=l_container.academic_year, status=True, language=language, campus=CampusFactory(name='MIT')) if create_lecturing_component: a_component = LearningComponentYearFactory( learning_container_year=l_container, type=learning_component_year_type.LECTURING, planned_classes=1) LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component) if create_pratical_component: a_component = LearningComponentYearFactory( learning_container_year=l_container, type=learning_component_year_type.PRACTICAL_EXERCISES, planned_classes=1) LearningUnitComponentFactory(learning_unit_year=a_learning_unit_year, learning_component_year=a_component) return a_learning_unit_year
def setUp(self): current_academic_year = create_current_academic_year() an_organization = OrganizationFactory(type=organization_type.MAIN) learning_container_year = LearningContainerYearFactory( academic_year=current_academic_year, container_type=learning_container_year_types.COURSE, ) self.learning_unit_year = LearningUnitYearFakerFactory( credits=5, subtype=learning_unit_year_subtypes.FULL, academic_year=current_academic_year, learning_container_year=learning_container_year, campus=CampusFactory(organization=an_organization, is_administration=True)) self.entity_container_year = EntityContainerYearFactory( learning_container_year=self.learning_unit_year. learning_container_year, type=entity_container_year_link_type.REQUIREMENT_ENTITY) today = datetime.date.today() an_entity = EntityFactory(organization=an_organization) self.entity_version = EntityVersionFactory( entity=an_entity, entity_type=entity_type.SCHOOL, start_date=today, end_date=today.replace(year=today.year + 1))
def get_valid_external_learning_unit_form_data(academic_year, person, learning_unit_year=None): entities = create_entities_hierarchy() PersonEntityFactory(person=person, entity=entities['root_entity'], with_child=True) requesting_entity = entities['child_one_entity_version'] organization = OrganizationFactory(type=organization_type.MAIN) campus = CampusFactory(organization=organization) language = LanguageFactory(code='FR') if not learning_unit_year: container_year = LearningContainerYearFactory(academic_year=academic_year) learning_unit_year = LearningUnitYearFactory.build( acronym='EOSIS1111', academic_year=academic_year, learning_container_year=container_year, subtype=learning_unit_year_subtypes.FULL, campus=campus, language=language ) return { # Learning unit year data model form 'acronym_0': learning_unit_year.acronym[0], 'acronym_1': learning_unit_year.acronym[1:], 'acronym_2': "A", 'academic_year': learning_unit_year.academic_year.id, 'specific_title': learning_unit_year.specific_title, 'specific_title_english': learning_unit_year.specific_title_english, 'credits': learning_unit_year.credits, 'status': learning_unit_year.status, 'campus': learning_unit_year.campus.id, 'language': learning_unit_year.language.pk, 'periodicity': learning_unit_year.periodicity, # Learning unit data model form 'faculty_remark': learning_unit_year.learning_unit.faculty_remark, # Learning container year data model form 'common_title': learning_unit_year.learning_container_year.common_title, 'common_title_english': learning_unit_year.learning_container_year.common_title_english, 'is_vacant': learning_unit_year.learning_container_year.is_vacant, # External learning unit model form 'requirement_entity': requesting_entity.id, 'allocation_entity': requesting_entity.id, 'external_acronym': 'Gorzyne', 'external_credits': '5', # Learning component year data model form 'component-TOTAL_FORMS': '2', 'component-INITIAL_FORMS': '0', 'component-MAX_NUM_FORMS': '2', 'component-0-hourly_volume_total_annual': 20, 'component-0-hourly_volume_partial_q1': 10, 'component-0-hourly_volume_partial_q2': 10, 'component-0-planned_classes': 1, 'component-1-hourly_volume_total_annual': 20, 'component-1-hourly_volume_partial_q1': 10, 'component-1-hourly_volume_partial_q2': 10, 'component-1-planned_classes': 1, }
def get_valid_form_data(learning_unit_year_partim): acronym_splited = acronym_field.split_acronym( learning_unit_year_partim.acronym) return { # Learning unit year data model form 'acronym_2': 'B', 'subtype': learning_unit_year_partim.subtype, 'specific_title': learning_unit_year_partim.specific_title, 'specific_title_english': learning_unit_year_partim.specific_title_english, 'credits': learning_unit_year_partim.credits, 'session': learning_unit_year_partim.session, 'quadrimester': learning_unit_year_partim.quadrimester, 'status': learning_unit_year_partim.status, 'language': learning_unit_year_partim.language.id, 'campus': CampusFactory(name='Louvain-la-Neuve', organization__type=organization_type.MAIN).pk, 'periodicity': learning_unit_year_partim.periodicity, # Learning unit data model form 'faculty_remark': learning_unit_year_partim.learning_unit.faculty_remark, 'other_remark': learning_unit_year_partim.learning_unit.other_remark, # Learning component year data model form 'component-TOTAL_FORMS': '2', 'component-INITIAL_FORMS': '0', 'component-MAX_NUM_FORMS': '2', 'component-0-hourly_volume_total_annual': 20, 'component-0-hourly_volume_partial_q1': 10, 'component-0-hourly_volume_partial_q2': 10, 'component-0-planned_classes': 1, 'component-1-hourly_volume_total_annual': 20, 'component-1-hourly_volume_partial_q1': 10, 'component-1-hourly_volume_partial_q2': 10, 'component-1-planned_classes': 1, }
def test_fill_acronym_initial_letter_instance(self): luy = LearningUnitYearFullFactory(campus=CampusFactory()) form = LearningUnitYearForExternalModelForm(person=self.person, data=None, subtype=FULL, instance=luy, initial={}) self.assertEqual(form.data['acronym_0'], luy.acronym[0])
def test_init(self): campus = CampusFactory() address = OrganizationAddressFactory(is_main=True, organization=campus.organization) luy = LearningUnitYearFullFactory(campus=campus) form = LearningUnitYearForExternalModelForm( person=self.person, data=None, subtype=FULL, instance=luy, initial={}) self.assertEqual(form.fields["country_external_institution"].initial, address.country.pk)
def setUp(self): self.super_user = SuperUserFactory() self.url = reverse("campus-autocomplete") self.organization = OrganizationFactory(name="Université de Louvain") self.organization_address = OrganizationAddressFactory( organization=self.organization, country__iso_code='BE', is_main=True) self.campus = CampusFactory(organization=self.organization)
def setUpTestData(cls): cls.initial_language = LanguageFactory(code='FR') cls.initial_campus = CampusFactory(name='Louvain-la-Neuve', organization__type=organization_type.MAIN) cls.current_academic_year = create_current_academic_year() # Creation of a LearningContainerYear and all related models cls.learn_unit_structure = GenerateContainer(cls.current_academic_year, cls.current_academic_year) start_year = AcademicYearFactory(year=cls.current_academic_year.year - 3) end_year = AcademicYearFactory(year=cls.current_academic_year.year + 7) cls.acs = GenerateAcademicYear(start_year=start_year, end_year=end_year).academic_years
def setUpTestData(cls): cls.super_user = SuperUserFactory() cls.url = reverse("campus-autocomplete") cls.organization = OrganizationFactory(name="Université de Louvain") cls.organization_address = OrganizationAddressFactory( organization=cls.organization, country__iso_code='BE', is_main=True ) cls.campus = CampusFactory(organization=cls.organization)
def setUp(self): self.person = PersonFactory() self.permission = Permission.objects.get( codename="can_propose_learningunit") self.person.user.user_permissions.add(self.permission) self.permission_2 = Permission.objects.get( codename="can_access_learningunit") self.person.user.user_permissions.add(self.permission_2) an_organization = OrganizationFactory(type=organization_type.MAIN) current_academic_year = create_current_academic_year() learning_container_year = LearningContainerYearFactory( acronym="LOSIS1212", academic_year=current_academic_year, container_type=learning_container_year_types.COURSE, ) self.learning_unit_year = LearningUnitYearFakerFactory( acronym=learning_container_year.acronym, subtype=learning_unit_year_subtypes.FULL, academic_year=current_academic_year, learning_container_year=learning_container_year, quadrimester=None, specific_title_english="title english", campus=CampusFactory(organization=an_organization, is_administration=True)) self.learning_container_year = self.learning_unit_year.learning_container_year an_entity = EntityFactory(organization=an_organization) self.entity_version = EntityVersionFactory( entity=an_entity, entity_type=entity_type.SCHOOL, start_date=current_academic_year.start_date, end_date=current_academic_year.end_date) self.requirement_entity = EntityContainerYearFactory( learning_container_year=self.learning_container_year, entity=self.entity_version.entity, type=entity_container_year_link_type.REQUIREMENT_ENTITY) self.allocation_entity = EntityContainerYearFactory( learning_container_year=self.learning_container_year, entity=self.entity_version.entity, type=entity_container_year_link_type.ALLOCATION_ENTITY) self.additional_requirement_entity_1 = EntityContainerYearFactory( learning_container_year=self.learning_container_year, entity=self.entity_version.entity, type=entity_container_year_link_type. ADDITIONAL_REQUIREMENT_ENTITY_1) self.additional_requirement_entity_2 = EntityContainerYearFactory( learning_container_year=self.learning_container_year, entity=self.entity_version.entity, type=entity_container_year_link_type. ADDITIONAL_REQUIREMENT_ENTITY_2) PersonEntityFactory(person=self.person, entity=self.entity_version.entity)
def setUp(self): self.academic_year = create_current_academic_year() self.learning_unit_year_1 = LearningUnitYearFactory( academic_year=self.academic_year, acronym='XLDR1001') self.external_lu_1 = ExternalLearningUnitYearFactory( external_acronym='XLDR1001', learning_unit_year=self.learning_unit_year_1) self.learning_unit_year_2 = LearningUnitYearFactory( academic_year=self.academic_year, acronym='XLDR1002') self.external_lu_2 = ExternalLearningUnitYearFactory( external_acronym='XLDR1002', learning_unit_year=self.learning_unit_year_2) self.a_be_country = CountryFactory(iso_code='BE') self.be_organization_adr_city1 = OrganizationAddressFactory( country=self.a_be_country, city=NAMEN) self.be_campus_1 = CampusFactory( organization=self.be_organization_adr_city1.organization) self.learning_container_year = LearningContainerYearFactory( academic_year=self.academic_year) self.learning_unit_year_3 = LearningUnitYearFactory( learning_container_year=self.learning_container_year, academic_year=self.academic_year, campus=self.be_campus_1) self.external_lu_BE_1 = ExternalLearningUnitYearFactory( learning_unit_year=self.learning_unit_year_3) self.be_organization_adr_city2 = OrganizationAddressFactory( country=self.a_be_country, city='Bruxelles') self.be_campus_2 = CampusFactory( organization=self.be_organization_adr_city2.organization) self.learning_container_year_4 = LearningContainerYearFactory( academic_year=self.academic_year) self.external_lu_BE_2 = ExternalLearningUnitYearFactory( learning_unit_year=LearningUnitYearFactory( learning_container_year=self.learning_container_year_4, academic_year=self.academic_year, campus=self.be_campus_2))
def setUpTestData(cls): cls.current_academic_year = create_current_academic_year() cls.learning_container_year = LearningContainerYearFactory(academic_year=cls.current_academic_year) cls.learning_unit_year = LearningUnitYearFactory(academic_year=cls.current_academic_year, learning_container_year=cls.learning_container_year, learning_unit__periodicity=ANNUAL, subtype=FULL, credits=25, status=False) cls.learning_unit_year_partim_1 = LearningUnitYearFactory(academic_year=cls.current_academic_year, learning_container_year=cls.learning_container_year, learning_unit__periodicity=ANNUAL, subtype=PARTIM, credits=20, status=False) cls.learning_unit_year_partim_2 = LearningUnitYearFactory(academic_year=cls.current_academic_year, learning_container_year=cls.learning_container_year, learning_unit__periodicity=ANNUAL, subtype=PARTIM, credits=18, status=False) cls.organization = OrganizationFactory(type=organization_type.MAIN) a_campus = CampusFactory(organization=cls.organization) an_entity = EntityFactory(organization=cls.organization) cls.an_entity_version = EntityVersionFactory(entity=an_entity, entity_type=entity_type.SCHOOL, parent=None, end_date=None, start_date=datetime.date.today() - datetime.timedelta(days=5)) cls.person = PersonEntityFactory(entity=an_entity).person language = LanguageFactory() cls.form_data = { "academic_year": str(cls.current_academic_year.id), "container_type": str(learning_container_year_types.COURSE), "subtype": str(learning_unit_year_subtypes.FULL), "acronym": "OSIS1452", "credits": "45", "common_title": "OSIS", "first_letter": "L", "periodicity": learning_unit_periodicity.ANNUAL, "campus": str(a_campus.id), "requirement_entity": str(cls.an_entity_version.id), "allocation_entity": str(cls.an_entity_version.id), "language": str(language.id) } cls.initial_data = { "academic_year": str(cls.current_academic_year.id), "container_type": str(learning_container_year_types.COURSE), "subtype": str(learning_unit_year_subtypes.FULL), "acronym": "OSIS1452", "first_letter": "L", "status": True }
def test_dropdown_init(self): country = CountryFactory() organization_1 = OrganizationFactory(name="organization 1") organization_2 = OrganizationFactory(name="organization 2") organization_3 = OrganizationFactory(name="organization 3") OrganizationAddressFactory(organization=organization_1, country=country, city=NAMUR) OrganizationAddressFactory(organization=organization_2, country=country, city=NAMUR) OrganizationAddressFactory(organization=organization_3, country=country, city=CINEY) CampusFactory(organization=organization_1) campus_2 = CampusFactory(organization=organization_1) campus_3 = CampusFactory(organization=organization_2) form = ExternalLearningUnitYearForm({ 'city': NAMUR, 'country': country, "campus": campus_2 }) form._init_dropdown_list() self.assertEqual(form.fields['campus'].choices[0], (None, '---------')) self.assertEqual(form.fields['campus'].choices[1][1], 'organization 1') self.assertEqual(form.fields['campus'].choices[2], (campus_3.id, 'organization 2')) self.assertEqual(form.fields['city'].choices, [(None, '---------'), (CINEY, CINEY), (NAMUR, NAMUR)])
def setUpTestData(cls): cls.person = PersonFactory() starting_year = AcademicYearFactory(year=YEAR_LIMIT_LUE_MODIFICATION) end_year = AcademicYearFactory(year=YEAR_LIMIT_LUE_MODIFICATION + 6) academic_years = GenerateAcademicYear(starting_year, end_year).academic_years cls.academic_year = academic_years[1] cls.language = LanguageFactory(code='FR') organization = OrganizationFactory(type=organization_type.MAIN) cls.campus = CampusFactory(organization=organization) cls.language = LanguageFactory(code='FR') cls.container_year = LearningContainerYearFactory( academic_year=cls.academic_year, container_type=EXTERNAL) cls.learning_unit = LearningUnitFactory(start_year=cls.academic_year)
def setUpTestData(cls): cls.current_academic_year = create_current_academic_year() cls.organization = OrganizationFactory(type=organization_type.MAIN) a_campus = CampusFactory(organization=cls.organization) an_entity = EntityFactory(organization=cls.organization) cls.an_entity_version = EntityVersionFactory( entity=an_entity, entity_type=entity_type.SCHOOL, parent=None, end_date=None, start_date=datetime.date.today() - datetime.timedelta(days=5)) cls.person = PersonEntityFactory(entity=an_entity).person language = LanguageFactory() cls.form_data = { "academic_year": str(cls.current_academic_year.id), "container_type": str(learning_container_year_types.COURSE), "subtype": str(learning_unit_year_subtypes.FULL), "acronym": "OSIS1452", "credits": "45", "specific_title": "OSIS", "first_letter": "L", "periodicity": learning_unit_periodicity.ANNUAL, "campus": str(a_campus.id), "requirement_entity": str(cls.an_entity_version.id), "allocation_entity": str(cls.an_entity_version.id), "language": language.pk } cls.initial_data = { "academic_year": str(cls.current_academic_year.id), "container_type": str(learning_container_year_types.COURSE), "subtype": str(learning_unit_year_subtypes.FULL), "acronym": "OSIS1452", "first_letter": "L", "status": True } cls.faculty_user = UserFactory() cls.faculty_user.groups.add( Group.objects.get(name=FACULTY_MANAGER_GROUP)) cls.faculty_person = PersonFactory(user=cls.faculty_user) cls.faculty_user.user_permissions.add( Permission.objects.get(codename='can_propose_learningunit')) PersonEntityFactory(entity=an_entity, person=cls.faculty_person)
def setUp(self): self.person = PersonFactory() self.academic_year = create_current_academic_year() self.language = LanguageFactory(code='FR') organization = OrganizationFactory(type=organization_type.MAIN) campus = CampusFactory(organization=organization) language = LanguageFactory(code='FR') container_year = LearningContainerYearFactory(academic_year=self.academic_year, container_type=EXTERNAL) self.learning_unit = LearningUnitFactory(start_year=self.academic_year.year) self.learning_unit_year = LearningUnitYearFactory( acronym='EOSIS1111', academic_year=self.academic_year, learning_unit=self.learning_unit, learning_container_year=container_year, subtype=learning_unit_year_subtypes.FULL, campus=campus, language=language, internship_subtype=None )
def setUp(self): self.initial_language = LanguageFactory(code='FR') self.initial_campus = CampusFactory(name='Louvain-la-Neuve', organization__type=organization_type.MAIN) self.current_academic_year = create_current_academic_year() self.person = PersonFactory() self.post_data = get_valid_form_data(self.current_academic_year, person=self.person) # Creation of a LearningContainerYear and all related models self.learn_unit_structure = GenerateContainer(self.current_academic_year.year, self.current_academic_year.year) self.learning_unit_year = LearningUnitYear.objects.get( learning_unit=self.learn_unit_structure.learning_unit_full, academic_year=self.current_academic_year ) self.acs = GenerateAcademicYear( start_year=self.current_academic_year.year - 3, end_year=self.current_academic_year.year + 7).academic_years del self.acs[3] for ac in self.acs: LearningUnitYearFactory(academic_year=ac, learning_unit=self.learning_unit_year.learning_unit) self.acs.insert(3, self.current_academic_year)
def setUp(cls, **kwargs): cls.education_group_type = kwargs.pop('education_group_type') cls.campus = CampusFactory(organization__type=organization_type.MAIN) cls.academic_year = AcademicYearFactory() new_entity_version = MainEntityVersionFactory() cls.form_data = { "acronym": "ACRO4569", "partial_acronym": "PACR8974", "education_group_type": cls.education_group_type.id, "title": "Test data", "main_teaching_campus": cls.campus.id, "academic_year": cls.academic_year.id, "management_entity": new_entity_version.pk, "remark": "This is a test!!" } cls.parent_education_group_year = EducationGroupYearFactory( academic_year=cls.academic_year) cls.entity_version = EntityVersionFactory( entity=cls.parent_education_group_year.management_entity)
def setUp(self, **kwargs): self.education_group_type = kwargs.pop('education_group_type') self.campus = CampusFactory(organization__type=organization_type.MAIN) self.academic_year = AcademicYearFactory() new_entity_version = MainEntityVersionFactory() self.form_data = { "acronym": "ACRO4569", "partial_acronym": "PACR8974", "education_group_type": self.education_group_type.id, "title": "Test data", "main_teaching_campus": self.campus.id, "academic_year": self.academic_year.id, "management_entity": new_entity_version.pk, "remark": "This is a test!!" } self.parent_education_group_year = EducationGroupYearFactory(academic_year=self.academic_year) # Append version to management/administration entity self.entity_version = EntityVersionFactory(entity=self.parent_education_group_year.management_entity) if self.education_group_type.category == TRAINING: EntityVersionFactory(entity=self.parent_education_group_year.administration_entity)
def setUp(self): self.person = PersonFactory() starting_year = YEAR_LIMIT_LUE_MODIFICATION academic_years = GenerateAcademicYear(starting_year, starting_year + 6).academic_years self.academic_year = academic_years[1] self.language = LanguageFactory(code='FR') organization = OrganizationFactory(type=organization_type.MAIN) campus = CampusFactory(organization=organization) language = LanguageFactory(code='FR') container_year = LearningContainerYearFactory( academic_year=self.academic_year, container_type=EXTERNAL) self.learning_unit = LearningUnitFactory( start_year=self.academic_year.year) self.learning_unit_year = LearningUnitYearFactory( acronym='EOSIS1111', academic_year=self.academic_year, learning_unit=self.learning_unit, learning_container_year=container_year, subtype=learning_unit_year_subtypes.FULL, campus=campus, language=language, internship_subtype=None)
def test_check_postponement_conflict_learning_unit_year_case_camp_diff( self): # Copy the same container + change academic year + campus another_learning_unit_year = _build_copy(self.learning_unit_year) another_learning_unit_year.academic_year = self.next_academic_year another_learning_unit_year.campus = CampusFactory(name='Paris') another_learning_unit_year.save() error_list = business_edition._check_postponement_conflict_on_learning_unit_year( self.learning_unit_year, another_learning_unit_year) self.assertIsInstance(error_list, list) self.assertEqual(len(error_list), 1) generic_error = "The value of field '%(field)s' is different between year %(year)s - %(value)s " \ "and year %(next_year)s - %(next_value)s" # Error : Campus diff error_campus = _(generic_error) % { 'field': _('campus'), 'year': self.learning_unit_year.academic_year, 'value': getattr(self.learning_unit_year, 'campus'), 'next_year': another_learning_unit_year.academic_year, 'next_value': getattr(another_learning_unit_year, 'campus') } self.assertIn(error_campus, error_list)
def setUpTestData(cls): today = datetime.date.today() an_academic_year = create_current_academic_year() learning_container_year = LearningContainerYearFactory( academic_year=an_academic_year, container_type=learning_container_year_types.COURSE, type_declaration_vacant=vacant_declaration_type.DO_NOT_ASSIGN, ) cls.learning_unit_year = LearningUnitYearFactory( learning_container_year=learning_container_year, acronym="LOSIS4512", academic_year=an_academic_year, subtype=learning_unit_year_subtypes.FULL, attribution_procedure=attribution_procedure.INTERNAL_TEAM, credits=15, campus=CampusFactory(organization=OrganizationFactory( type=organization_type.MAIN)), internship_subtype=None, ) cls.partim_learning_unit = LearningUnitYearFactory( learning_container_year=learning_container_year, acronym="LOSIS4512A", academic_year=an_academic_year, subtype=learning_unit_year_subtypes.PARTIM, credits=10, campus=CampusFactory(organization=OrganizationFactory( type=organization_type.MAIN))) cls.requirement_entity_container = EntityContainerYearFactory( learning_container_year=learning_container_year, type=entity_container_year_link_type.REQUIREMENT_ENTITY) cls.requirement_entity_container.entity.organization.type = organization_type.MAIN cls.requirement_entity_container.entity.organization.save() cls.requirement_entity = EntityVersionFactory( entity=cls.requirement_entity_container.entity, entity_type=entity_type.SCHOOL, start_date=today.replace(year=1900), end_date=None) cls.allocation_entity_container = EntityContainerYearFactory( learning_container_year=learning_container_year, type=entity_container_year_link_type.ALLOCATION_ENTITY) cls.allocation_entity = EntityVersionFactory( entity=cls.allocation_entity_container.entity, start_date=today.replace(year=1900), end_date=None) cls.additional_entity_container_1 = EntityContainerYearFactory( learning_container_year=learning_container_year, type=entity_container_year_link_type. ADDITIONAL_REQUIREMENT_ENTITY_1) cls.additional_entity_1 = EntityVersionFactory( entity=cls.additional_entity_container_1.entity, start_date=today.replace(year=1900), end_date=None) cls.additional_entity_container_2 = EntityContainerYearFactory( learning_container_year=learning_container_year, type=entity_container_year_link_type. ADDITIONAL_REQUIREMENT_ENTITY_2) cls.additional_entity_2 = EntityVersionFactory( entity=cls.additional_entity_container_2.entity, start_date=today.replace(year=1900), end_date=None) cls.person = PersonEntityFactory( entity=cls.requirement_entity_container.entity).person cls.user = cls.person.user cls.user.user_permissions.add( Permission.objects.get(codename="can_edit_learningunit"), Permission.objects.get(codename="can_access_learningunit")) cls.url = reverse(update_learning_unit, args=[cls.learning_unit_year.id])
def _setup_common_data(self): self.language = LanguageFactory(code='FR', name='French') self.campus = CampusFactory(name='Louvain-la-Neuve')