Exemple #1
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory()
        cls.education_group_year_root = TrainingFactory(academic_year=cls.academic_year)
        cls.education_group_year_childs = [MiniTrainingFactory(academic_year=cls.academic_year) for _ in range(0, 3)]

        cls.group_element_years_root_to_child = [
            GroupElementYearFactory(parent=cls.education_group_year_root,
                                    child_leaf=None,
                                    child_branch=cls.education_group_year_childs[i])
            for i in range(0, len(cls.education_group_year_childs))
        ]

        cls.group_element_years_child_0 = [
            GroupElementYearFactory(parent=cls.education_group_year_childs[0],
                                    child_leaf=LearningUnitYearFakerFactory(
                                        learning_container_year__academic_year=cls.academic_year),
                                    child_branch=None)
            for i in range(0, 2)
        ]

        cls.group_element_years_child_2 = [
            GroupElementYearFactory(parent=cls.education_group_year_childs[2],
                                    child_leaf=LearningUnitYearFakerFactory(
                                        learning_container_year__academic_year=cls.academic_year),
                                    child_branch=None)
            for i in range(0, 4)
        ]

        cls.all_learning_units_acronym = [
            gey.child_leaf.acronym for gey in itertools.chain(cls.group_element_years_child_0,
                                                              cls.group_element_years_child_2)
        ]
Exemple #2
0
 def setUp(self):
     self.luy = LearningUnitYearFakerFactory(learning_container_year__academic_year=self.current_academic_year,
                                        learning_container_year__container_type=COURSE,
                                        subtype=FULL)
     self.entity_container_year = EntityContainerYearFactory(
         learning_container_year=self.luy.learning_container_year,
         type=entity_container_year_link_type.REQUIREMENT_ENTITY)
     self.person_entity = PersonEntityFactory(person=self.person, entity=self.entity_container_year.entity)
Exemple #3
0
    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
        }
Exemple #4
0
 def setUp(self):
     requirement_entity = EntityFactory()
     self.luy = LearningUnitYearFakerFactory(
         learning_container_year__academic_year=self.current_academic_year,
         learning_container_year__container_type=COURSE,
         subtype=FULL,
         learning_container_year__requirement_entity=requirement_entity)
     self.person_entity = PersonEntityFactory(person=self.person,
                                              entity=requirement_entity)
Exemple #5
0
    def test_should_return_acronym_of_learnings_units_not_present_in_education_group_year(self):
        luy_outside = LearningUnitYearFakerFactory(learning_container_year__academic_year=self.academic_year)
        luy_outside_2 = LearningUnitYearFakerFactory(learning_container_year__academic_year=self.academic_year)
        learning_units_acronym = [luy_outside.acronym] + self.all_learning_units_acronym
        self.assertEqual(get_learning_units_which_are_outside_of_education_group(self.education_group_year_root,
                                                                                 learning_units_acronym),
                         [luy_outside.acronym])

        learning_units_acronym = [luy_outside.acronym, luy_outside_2.acronym] + self.all_learning_units_acronym
        self.assertCountEqual(get_learning_units_which_are_outside_of_education_group(self.education_group_year_root,
                                                                                      learning_units_acronym),
                              [luy_outside.acronym, luy_outside_2.acronym])
    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)
Exemple #7
0
    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))
Exemple #8
0
    def setUp(self):
        today = datetime.datetime.today()
        twenty_days = datetime.timedelta(days=20)

        #Take same academic year as the one in the associated xls file
        an_academic_year = AcademicYearFactory(year=2017)

        a_learning_unit_year = LearningUnitYearFakerFactory(
            academic_year=an_academic_year, acronym=LEARNING_UNIT_ACRONYM)

        tutor = TutorFactory()

        an_academic_calendar = AcademicCalendarFactory(
            academic_year=an_academic_year,
            start_date=today - twenty_days,
            end_date=today + twenty_days,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        SessionExamCalendarFactory(number_session=number_session.ONE,
                                   academic_calendar=an_academic_calendar)
        AttributionFactory(learning_unit_year=a_learning_unit_year,
                           tutor=tutor)
        a_session_exam = SessionExamFactory(
            number_session=number_session.ONE,
            learning_unit_year=a_learning_unit_year)

        self.person_student_1 = PersonFactory(email=EMAIL_1)
        person_student_2 = PersonFactory(email=EMAIL_2)

        student_1 = StudentFactory(registration_id=REGISTRATION_ID_1,
                                   person=self.person_student_1)
        student_2 = StudentFactory(registration_id=REGISTRATION_ID_2,
                                   person=person_student_2)

        an_offer_year = OfferYearFactory(academic_year=an_academic_year,
                                         acronym=OFFER_ACRONYM)
        offer_enrollment_1 = OfferEnrollmentFactory(offer_year=an_offer_year,
                                                    student=student_1)
        offer_enrollment_2 = OfferEnrollmentFactory(offer_year=an_offer_year,
                                                    student=student_2)

        learning_unit_enrollment_1 = LearningUnitEnrollmentFactory(
            learning_unit_year=a_learning_unit_year,
            offer_enrollment=offer_enrollment_1)
        learning_unit_enrollment_2 = LearningUnitEnrollmentFactory(
            learning_unit_year=a_learning_unit_year,
            offer_enrollment=offer_enrollment_2)

        ExamEnrollmentFactory(
            session_exam=a_session_exam,
            learning_unit_enrollment=learning_unit_enrollment_1)
        ExamEnrollmentFactory(
            session_exam=a_session_exam,
            learning_unit_enrollment=learning_unit_enrollment_2)

        user = tutor.person.user
        self.client = Client()
        self.client.force_login(user=user)
        self.url = reverse(
            'upload_encoding',
            kwargs={'learning_unit_year_id': a_learning_unit_year.id})
Exemple #9
0
    def test_can_only_propose_modification_for_lu_which_is_not_in_proposition_on_different_year(self):
        past_luy_with_proposal = LearningUnitYearFakerFactory(
            learning_container_year__academic_year=self.past_academic_year,
            learning_unit=self.luy.learning_unit
        )
        ProposalLearningUnitFactory(learning_unit_year=past_luy_with_proposal)

        self.assertFalse(is_eligible_to_create_modification_proposal(self.luy, self.person))
Exemple #10
0
    def test_check_proposal_edition_ok(self):
        past_luy = LearningUnitYearFakerFactory(
            academic_year=self.past_academic_year,
            learning_container_year__academic_year=self.past_academic_year,
            learning_unit=self.luy.learning_unit)
        ProposalLearningUnitFactory(learning_unit_year=self.luy)

        self.assertTrue(_check_proposal_edition(past_luy, False))
Exemple #11
0
    def setUp(self):
        today = datetime.date.today()
        academic_year = AcademicYearFakerFactory(start_date=today-datetime.timedelta(days=3), year=today.year,
                                                 end_date=today + datetime.timedelta(days=5))
        self.summary_course_submission_calendar = \
            AcademicCalendarFactory(academic_year=academic_year,
                                    start_date=academic_year.start_date,
                                    end_date=academic_year.end_date,
                                    reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        self.tutor = TutorFactory()

        learning_container_year = LearningContainerYearFactory(academic_year=academic_year)
        self.learning_unit_year = LearningUnitYearFakerFactory(academic_year=academic_year,
                                                               learning_container_year=learning_container_year)
        self.attribution = AttributionFactory(learning_unit_year=self.learning_unit_year, summary_responsible=True,
                                              tutor=self.tutor)

        self.url = reverse('learning_unit_summary_edit', args=[self.learning_unit_year.id])
        self.client.force_login(self.tutor.person.user)
Exemple #12
0
    def test_check_proposal_edition_ok(self):
        past_luy = LearningUnitYearFakerFactory(
            academic_year=self.past_academic_year,
            learning_container_year__academic_year=self.past_academic_year,
            learning_unit=self.luy.learning_unit)

        ProposalLearningUnitFactory(learning_unit_year=self.luy)
        self.assertTrue(
            _check_proposal_edition(
                past_luy,
                create_person_with_permission_and_group(FACULTY_MANAGER_GROUP),
                False))
Exemple #13
0
    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)
Exemple #14
0
    def setUp(self):
        self.learning_unit_year_1 = LearningUnitYearFakerFactory()
        self.person_lu_1 = PersonFactory()
        self.tutor_lu1_1 = TutorFactory(person=self.person_lu_1)
        self.attribution_lu1 = AttributionFactory(learning_unit_year=self.learning_unit_year_1, tutor=self.tutor_lu1_1)
        self.learning_unit_year_1.summary_status=False
        self.learning_unit_year_1.summary_responsibles=[self.attribution_lu1]

        self.learning_unit_year_2 = LearningUnitYearFakerFactory()
        self.person_lu_2 = PersonFactory()
        self.tutor_lu1_2_1 = TutorFactory(person=self.person_lu_2)
        self.person_lu_3 = PersonFactory()
        self.tutor_lu2_2_2 = TutorFactory(person=self.person_lu_3)
        self.attribution_lu2_1 = AttributionFactory(learning_unit_year=self.learning_unit_year_2, tutor=self.tutor_lu1_2_1)
        self.attribution_lu2_2 = AttributionFactory(learning_unit_year=self.learning_unit_year_2, tutor=self.tutor_lu2_2_2)
        self.learning_unit_year_2.summary_status=False
        self.learning_unit_year_2.summary_responsibles=[self.attribution_lu2_1, self.attribution_lu2_2]

        self.learning_unit_year_3 = LearningUnitYearFakerFactory()
        self.attribution_lu3 = AttributionFactory(learning_unit_year=self.learning_unit_year_3, tutor=self.tutor_lu1_1)
        self.learning_unit_year_3.summary_status=False
        self.learning_unit_year_3.summary_responsibles=[self.attribution_lu3]
def generate_exam_enrollments(year, with_different_offer=False):
    number_enrollments = 2
    academic_year = AcademicYearFactory(year=year)

    an_academic_calendar = AcademicCalendarFactory(
        academic_year=academic_year,
        start_date=(datetime.datetime.today() -
                    datetime.timedelta(days=20)).date(),
        end_date=(datetime.datetime.today() +
                  datetime.timedelta(days=20)).date(),
        reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
    session_exam_calendar = SessionExamCalendarFactory(
        number_session=number_session.ONE,
        academic_calendar=an_academic_calendar)

    learning_unit_year = LearningUnitYearFakerFactory(
        academic_year=academic_year,
        learning_container_year__academic_year=academic_year,
        acronym=LEARNING_UNIT_ACRONYM)
    attribution = AttributionFactory(learning_unit_year=learning_unit_year)

    if with_different_offer:
        session_exams = [
            SessionExamFactory(number_session=number_session.ONE,
                               learning_unit_year=learning_unit_year,
                               offer_year__academic_year=academic_year)
            for _ in range(0, number_enrollments)
        ]
    else:
        session_exams = [
            SessionExamFactory(number_session=number_session.ONE,
                               learning_unit_year=learning_unit_year,
                               offer_year__academic_year=academic_year)
        ] * number_enrollments
    offer_years = [session_exam.offer_year for session_exam in session_exams]

    exam_enrollments = list()
    for i in range(0, number_enrollments):
        student = StudentFactory()
        offer_enrollment = OfferEnrollmentFactory(offer_year=offer_years[i],
                                                  student=student)
        learning_unit_enrollment = LearningUnitEnrollmentFactory(
            learning_unit_year=learning_unit_year,
            offer_enrollment=offer_enrollment)
        exam_enrollments.append(
            ExamEnrollmentFactory(
                session_exam=session_exams[i],
                learning_unit_enrollment=learning_unit_enrollment,
                enrollment_state=exam_enrollment_state.ENROLLED,
                date_enrollment=an_academic_calendar.start_date))
    return locals()
Exemple #16
0
    def setUpTestData(cls):
        academic_year = create_current_academic_year()
        cls.summary_course_submission_calendar = AcademicCalendarFactory(
            academic_year=academic_year,
            start_date=academic_year.start_date,
            end_date=academic_year.end_date,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        cls.tutor = TutorFactory()

        cls.learning_unit_year = LearningUnitYearFakerFactory(academic_year=academic_year)
        cls.attribution = AttributionFactory(learning_unit_year=cls.learning_unit_year, summary_responsible=True,
                                             tutor=cls.tutor)

        cls.url = reverse('learning_unit_summary', args=[cls.learning_unit_year.id])
Exemple #17
0
    def setUp(self):
        self.a_superuser = SuperUserFactory()
        self.person = PersonFactory(user=self.a_superuser,
                                    language=LANGUAGE_CODE_FR)
        self.client.force_login(self.a_superuser)

        academic_year = create_current_academic_year()
        self.summary_course_submission_calendar = AcademicCalendarFactory(
            academic_year=academic_year,
            start_date=academic_year.start_date,
            end_date=academic_year.end_date,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        self.tutor = TutorFactory(person=self.person)

        self.learning_unit_year = LearningUnitYearFakerFactory(academic_year=academic_year)
        self.attribution = AttributionFactory(learning_unit_year=self.learning_unit_year, summary_responsible=True,
                                              tutor=self.tutor)
Exemple #18
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory()
        cls.education_group_year_parents = [TrainingFactory(academic_year=cls.academic_year) for _ in range(0, 2)]
        cls.learning_unit_year_child = LearningUnitYearFakerFactory(
            learning_container_year__academic_year=cls.academic_year
        )
        cls.group_element_years = [
            GroupElementYearFactory(parent=cls.education_group_year_parents[i],
                                    child_leaf=cls.learning_unit_year_child,
                                    child_branch=None)
            for i in range(0, 2)
        ]
        cls.person = CentralManagerFactory("change_educationgroup", 'can_access_education_group')
        PersonEntityFactory(person=cls.person,
                            entity=cls.education_group_year_parents[0].management_entity)

        cls.url = reverse("learning_unit_prerequisite_update",
                          args=[cls.education_group_year_parents[0].id, cls.learning_unit_year_child.id])
Exemple #19
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory()
        cls.education_group_year_parents = [TrainingFactory(academic_year=cls.academic_year) for _ in range(0, 2)]
        cls.learning_unit_year_child = LearningUnitYearFakerFactory(
            learning_container_year__academic_year=cls.academic_year
        )
        cls.group_element_years = [
            GroupElementYearFactory(parent=cls.education_group_year_parents[i],
                                    child_leaf=cls.learning_unit_year_child,
                                    child_branch=None)
            for i in range(0, 2)
        ]

        cls.prerequisite = PrerequisiteFactory(
            learning_unit_year=cls.learning_unit_year_child,
            education_group_year=cls.education_group_year_parents[0]
        )
        cls.person = PersonWithPermissionsFactory("can_access_education_group")
        cls.url = reverse("learning_unit_prerequisite",
                          args=[cls.education_group_year_parents[0].id, cls.learning_unit_year_child.id])
Exemple #20
0
    def setUpTestData(cls):
        cls.a_superuser = SuperUserFactory()
        cls.person = PersonFactory(user=cls.a_superuser,
                                   language=LANGUAGE_CODE_FR)
        academic_year = create_current_academic_year()
        cls.summary_course_submission_calendar = AcademicCalendarFactory(
            academic_year=academic_year,
            start_date=academic_year.start_date,
            end_date=academic_year.end_date,
            reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        cls.tutor = TutorFactory(person=cls.person)
        # FIXME CHANGE LEARNINGUNITYEARFACTORY FOR AVOID MULTI ACADEMIC YEAR
        cls.learning_container_year = LearningContainerYearFactory(
            academic_year=academic_year)
        cls.learning_unit_year = LearningUnitYearFakerFactory(
            academic_year=academic_year,
            learning_container_year=cls.learning_container_year)
        cls.attribution = AttributionFactory(
            learning_unit_year=cls.learning_unit_year,
            summary_responsible=True,
            tutor=cls.tutor)
Exemple #21
0
 def test_get_learning_unit_yr_list_with_summary_already_updated(self):
     learning_unit_year_updated = LearningUnitYearFakerFactory()
     learning_unit_year_updated.summary_status=True
     learning_units = get_responsible_and_learning_unit_yr_list([learning_unit_year_updated])
     self.assertCountEqual(learning_units, [])
class TestLearningUnitModificationProposal(TestCase):
    def setUp(self):
        today = datetime.date.today()

        self.person = PersonFactory()
        an_organization = OrganizationFactory(type=organization_type.MAIN)
        self.learning_unit_year = LearningUnitYearFakerFactory(acronym="LOSIS1212",
                                                               subtype=learning_unit_year_subtypes.FULL)
        self.learning_unit_year.academic_year.start_date = today - datetime.timedelta(days=15)
        self.learning_unit_year.academic_year.end_date = today + datetime.timedelta(days=15)
        self.learning_unit_year.academic_year.year = today.year
        self.learning_unit_year.academic_year.save()
        self.learning_unit_year.learning_container_year.container_type = learning_container_year_types.COURSE
        self.learning_unit_year.learning_container_year.save()
        self.learning_unit_year.learning_container_year.campus.organization = an_organization
        self.learning_unit_year.learning_container_year.campus.is_administration = True
        self.learning_unit_year.learning_container_year.campus.save()

        an_entity = EntityFactory(organization=an_organization)
        self.entity_version = EntityVersionFactory(entity=an_entity, entity_type=entity_type.SCHOOL,
                                                   start_date=today - datetime.timedelta(days=25),
                                                   end_date=today.replace(year=today.year + 1))
        self.requirement_entity = EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.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_unit_year.learning_container_year,
            entity=self.entity_version.entity,
            type=entity_container_year_link_type.ALLOCATION_ENTITY
        )
        self.additional_entity_1= EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.learning_container_year,
            entity=self.entity_version.entity,
            type=entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1
        )
        self.additional_entity_2 = EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.learning_container_year,
            entity=self.entity_version.entity,
            type=entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2
        )

        self.person_entity = PersonEntityFactory(person=self.person, entity=an_entity, with_child=True)

        self.client.force_login(self.person.user)
        self.url = reverse('learning_unit_modification_proposal', args=[self.learning_unit_year.id])

        self.form_data = {
            "academic_year": self.learning_unit_year.academic_year.id,
            "first_letter": self.learning_unit_year.acronym[0],
            "acronym": self.learning_unit_year.acronym[1:],
            "title": self.learning_unit_year.title,
            "title_english": self.learning_unit_year.title_english,
            "container_type": self.learning_unit_year.learning_container_year.container_type,
            "internship_subtype": "",
            "credits": self.learning_unit_year.credits,
            "periodicity": self.learning_unit_year.learning_unit.periodicity,
            "status": self.learning_unit_year.status,
            "language": self.learning_unit_year.learning_container_year.language.id,
            "quadrimester": "",
            "campus": self.learning_unit_year.learning_container_year.campus.id,
            "requirement_entity": self.entity_version.id,
            "allocation_entity": self.entity_version.id,
            "additional_entity_1": self.entity_version.id,
            "additional_entity_2": self.entity_version.id,
            "folder_entity": self.entity_version.id,
            "folder_id": "1",
        }

    def test_user_not_logged(self):
        self.client.logout()
        response = self.client.get(self.url)

        self.assertRedirects(response, '/login/?next={}'.format(self.url))

    def test_with_non_existent_learning_unit_year(self):
        self.learning_unit_year.delete()
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseNotFound.status_code)
        self.assertTemplateUsed(response, "page_not_found.html")

    def test_with_none_person(self):
        self.person.delete()
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseNotFound.status_code)
        self.assertTemplateUsed(response, "page_not_found.html")

    def test_get_request(self):
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponse.status_code)
        self.assertTemplateUsed(response, 'proposal/learning_unit_modification.html')
        self.assertEqual(response.context['learning_unit_year'], self.learning_unit_year)
        self.assertEqual(response.context['experimental_phase'], True)
        self.assertEqual(response.context['person'], self.person)

        self.assertIsInstance(response.context['form'], LearningUnitProposalModificationForm)
        form_initial = response.context['form'].initial
        self.assertEqual(form_initial['academic_year'], self.learning_unit_year.academic_year.pk)
        self.assertEqual(form_initial['first_letter'], self.learning_unit_year.acronym[0])
        self.assertEqual(form_initial['acronym'], self.learning_unit_year.acronym[1:])
        self.assertEqual(form_initial['title'], self.learning_unit_year.title)
        self.assertEqual(form_initial['container_type'], self.learning_unit_year.
                         learning_container_year.container_type)
        self.assertEqual(form_initial['subtype'], self.learning_unit_year.subtype)
        self.assertEqual(form_initial['credits'], self.learning_unit_year.credits)
        self.assertEqual(form_initial['periodicity'], self.learning_unit_year.learning_unit.periodicity)
        self.assertEqual(form_initial['status'], self.learning_unit_year.status)
        self.assertEqual(form_initial['language'], self.learning_unit_year.learning_container_year.language)
        self.assertEqual(form_initial['requirement_entity'], self.entity_version)
        self.assertEqual(form_initial['allocation_entity'], self.entity_version)
        self.assertEqual(form_initial['additional_entity_1'], self.entity_version)
        self.assertEqual(form_initial['additional_entity_2'], self.entity_version)
        self.assertEqual(form_initial['campus'], self.learning_unit_year.learning_container_year.campus)

    def test_post_request_with_invalid_form(self):
        response = self.client.post(self.url, data={})

        self.assertEqual(response.status_code, HttpResponse.status_code)
        self.assertTemplateUsed(response, 'proposal/learning_unit_modification.html')
        self.assertEqual(response.context['learning_unit_year'], self.learning_unit_year)
        self.assertEqual(response.context['experimental_phase'], True)
        self.assertEqual(response.context['person'], self.person)
        self.assertIsInstance(response.context['form'], LearningUnitProposalModificationForm)

    def test_post_request(self):
        response = self.client.post(self.url, data=self.form_data)

        redirected_url = reverse('learning_unit', args=[self.learning_unit_year.id])
        self.assertRedirects(response, redirected_url, fetch_redirect_response=False)

        folder = proposal_folder.find_by_entity_and_folder_id(self.entity_version.entity, 1)
        a_proposal_learning_unit = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)
        self.assertTrue(folder)
        self.assertTrue(a_proposal_learning_unit)
        self.assertEqual(a_proposal_learning_unit.author, self.person)

        messages = [str(message) for message in get_messages(response.wsgi_request)]
        self.assertIn(_("success_modification_proposal").format(proposal_type.ProposalType.MODIFICATION.name,
                                                                self.learning_unit_year.acronym),
                      list(messages))

    def test_transformation_proposal_request(self):
        self.form_data["acronym"] = "OSIS1452"
        self.client.post(self.url, data=self.form_data)

        a_proposal_learning_unit = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)
        self.assertEqual(a_proposal_learning_unit.type, proposal_type.ProposalType.TRANSFORMATION.name)

    def test_modification_proposal_request(self):
        self.form_data["title"] = "New title"
        self.form_data["title_english"] = "New english title"
        self.client.post(self.url, data=self.form_data)

        a_proposal_learning_unit = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)
        self.assertEqual(a_proposal_learning_unit.type, proposal_type.ProposalType.MODIFICATION.name)

    def test_transformation_and_modification_proposal_request(self):
        self.form_data["acronym"] = "OSIS1452"
        self.form_data["title"] = "New title"
        self.form_data["title_english"] = "New english title"
        self.client.post(self.url, data=self.form_data)

        a_proposal_learning_unit = proposal_learning_unit.find_by_learning_unit_year(self.learning_unit_year)
        self.assertEqual(a_proposal_learning_unit.type, proposal_type.ProposalType.TRANSFORMATION_AND_MODIFICATION.name)

    def test_learning_unit_must_be_full(self):
        self.learning_unit_year.subtype = learning_unit_year_subtypes.PARTIM
        self.learning_unit_year.save()

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, "access_denied.html")

    def test_proposal_already_exists(self):
        ProposalLearningUnitFactory(learning_unit_year=self.learning_unit_year)
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, "access_denied.html")

    def test_academic_year_inferior_to_current(self):
        today = datetime.date.today()
        self.learning_unit_year.academic_year = \
            AcademicYearFakerFactory(year=today.year-1, start_date=today.replace(day=1, year=today.year-1),
                                     end_date=today.replace(day=20, year=today.year-1))
        self.learning_unit_year.save()

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, "access_denied.html")

    def test_not_linked_to_entity(self):
        self.person_entity.delete()
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, "access_denied.html")

    def test_not_linked_to_requirement_entity(self):
        today = datetime.date.today()
        an_entity = EntityFactory(organization=OrganizationFactory(type=organization_type.MAIN))
        an_entity_version = EntityVersionFactory(entity=an_entity, entity_type=entity_type.SCHOOL,
                                                 start_date=today - datetime.timedelta(days=25),
                                                 end_date=today.replace(year=today.year + 1))

        self.requirement_entity.entity = an_entity_version.entity
        self.requirement_entity.save()

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, "access_denied.html")

    def test_linked_to_parent_entity(self):
        today = datetime.date.today()
        parent_entity = EntityFactory(organization=OrganizationFactory(type=organization_type.MAIN))
        EntityVersionFactory(entity=parent_entity, entity_type=entity_type.SCHOOL,
                             start_date=today - datetime.timedelta(days=25),
                             end_date=today.replace(year=today.year + 1))

        self.entity_version.parent = parent_entity
        self.entity_version.save()

        self.person_entity.entity = parent_entity
        self.person_entity.save()

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponse.status_code)
        self.assertTemplateUsed(response, 'proposal/learning_unit_modification.html')

    def test_linked_to_child_entity(self):
        today = datetime.date.today()
        child_entity = EntityFactory(organization=OrganizationFactory(type=organization_type.MAIN))
        EntityVersionFactory(entity=child_entity, entity_type=entity_type.SCHOOL,
                             start_date=today - datetime.timedelta(days=25),
                             end_date=today.replace(year=today.year + 1),
                             parent=self.entity_version.entity)

        self.person_entity.entity = child_entity
        self.person_entity.save()

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, "access_denied.html")
Exemple #23
0
class TestLearningUnitSummaryEdit(TestCase):
    def setUp(self):
        today = datetime.date.today()
        academic_year = AcademicYearFakerFactory(start_date=today-datetime.timedelta(days=3), year=today.year,
                                                 end_date=today + datetime.timedelta(days=5))
        self.summary_course_submission_calendar = \
            AcademicCalendarFactory(academic_year=academic_year,
                                    start_date=academic_year.start_date,
                                    end_date=academic_year.end_date,
                                    reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION)

        self.tutor = TutorFactory()

        learning_container_year = LearningContainerYearFactory(academic_year=academic_year)
        self.learning_unit_year = LearningUnitYearFakerFactory(academic_year=academic_year,
                                                               learning_container_year=learning_container_year)
        self.attribution = AttributionFactory(learning_unit_year=self.learning_unit_year, summary_responsible=True,
                                              tutor=self.tutor)

        self.url = reverse('learning_unit_summary_edit', args=[self.learning_unit_year.id])
        self.client.force_login(self.tutor.person.user)

    def test_user_is_not_logged(self):
        self.client.logout()
        response = self.client.get(self.url)

        self.assertRedirects(response, "/login/?next={}".format(self.url))

    def test_summary_course_submission_calendar_is_not_opened(self):
        today = datetime.date.today()
        self.summary_course_submission_calendar.start_date = today-datetime.timedelta(days=5)
        self.summary_course_submission_calendar.end_date = today - datetime.timedelta(days=3)
        self.summary_course_submission_calendar.save()
        response = self.client.get(self.url)

        self.assertRedirects(response, reverse("outside_summary_submission_period"))

    def test_summary_course_submission_calendar_is_not_set(self):
        self.summary_course_submission_calendar.delete()
        response = self.client.get(self.url)

        self.assertRedirects(response, reverse("outside_summary_submission_period"))

    def test_user_is_not_a_tutor(self):
        person = PersonFactory()
        self.client.force_login(person.user)

        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, 'access_denied.html')

    def test_when_learning_unit_year_does_not_exist(self):
        self.learning_unit_year.delete()
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseNotFound.status_code)
        self.assertTemplateUsed(response, 'page_not_found.html')

    def test_when_user_is_not_attributed_to_the_learning_unit(self):
        self.attribution.delete()
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, 'access_denied.html')

    def test_when_user_is_not_summary_responsible_of_the_learning_unit(self):
        self.attribution.summary_responsible = False
        self.attribution.save()
        response = self.client.get(self.url)

        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
        self.assertTemplateUsed(response, 'access_denied.html')

    def test_valid_get_request(self):
        language = "en"
        text_label = TextLabelFactory()
        response = self.client.get(self.url, data={"language": language, "label": text_label.label})

        self.assertTemplateUsed(response, "my_osis/educational_information_edit.html")

        context = response.context
        self.assertEqual(context["learning_unit_year"], self.learning_unit_year)
        self.assertTrue(context["form"])
        self.assertEqual(context["text_label_translated"], None)
        self.assertEqual(context["language_translated"], ('en', _('English')))

    def test_valid_get_request_with_translated_text_labels(self):
        language = "fr-be"
        self.tutor.person.language = language
        self.tutor.person.save()
        trans_text_label = TranslatedTextLabelFactory()
        response = self.client.get(self.url, data={"language": language, "label": trans_text_label.text_label.label})

        self.assertTemplateUsed(response, "my_osis/educational_information_edit.html")

        context = response.context
        self.assertEqual(context["learning_unit_year"], self.learning_unit_year)
        self.assertTrue(context["form"])
        self.assertEqual(context["text_label_translated"], trans_text_label)
        self.assertEqual(context["language_translated"], ('fr-be', _('French')))

    def test_invalid_post_request(self):
        response = self.client.post(self.url, data={"trans_text": "Hello world!!"})
        self.assertRedirects(response, reverse("learning_unit_summary", args=[self.learning_unit_year.id]))

    def test_valid_post_request(self):
        new_text = "Hello world!!"
        translated_text = TranslatedTextFactory()
        response = self.client.post(self.url, data={"trans_text": new_text, "cms_id": translated_text.id})

        self.assertRedirects(response, reverse("learning_unit_summary", args=[self.learning_unit_year.id]))
        translated_text.refresh_from_db()
        self.assertEqual(translated_text.text, new_text)
Exemple #24
0
    def test_cannot_propose_modification_of_past_learning_unit(self):
        past_luy = LearningUnitYearFakerFactory(
            learning_container_year__academic_year=self.past_academic_year)

        self.assertFalse(
            is_eligible_to_create_modification_proposal(past_luy, self.person))
Exemple #25
0
class TestIsEligibleToCreateModificationProposal(TestCase):
    @classmethod
    def setUpTestData(cls):
        cls.current_academic_year = create_current_academic_year()
        cls.past_academic_year = AcademicYearFactory(
            start_date=cls.current_academic_year.start_date -
            datetime.timedelta(days=365),
            end_date=cls.current_academic_year.end_date -
            datetime.timedelta(days=365),
            year=cls.current_academic_year.year - 1)
        cls.person = PersonFactory()

    def setUp(self):
        self.luy = LearningUnitYearFakerFactory(
            learning_container_year__academic_year=self.current_academic_year,
            learning_container_year__container_type=COURSE,
            subtype=FULL)
        self.entity_container_year = EntityContainerYearFactory(
            learning_container_year=self.luy.learning_container_year,
            type=entity_container_year_link_type.REQUIREMENT_ENTITY)
        self.person_entity = PersonEntityFactory(
            person=self.person, entity=self.entity_container_year.entity)

    def test_cannot_propose_modification_of_past_learning_unit(self):
        past_luy = LearningUnitYearFakerFactory(
            learning_container_year__academic_year=self.past_academic_year)

        self.assertFalse(
            is_eligible_to_create_modification_proposal(past_luy, self.person))

    def test_cannot_propose_modification_of_partim(self):
        self.luy.subtype = PARTIM
        self.luy.save()

        self.assertFalse(
            is_eligible_to_create_modification_proposal(self.luy, self.person))

    def test_can_only_propose_modification_for_course_internship_and_dissertation(
            self):
        other_types = (OTHER_COLLECTIVE, OTHER_INDIVIDUAL, MASTER_THESIS,
                       EXTERNAL)
        for luy_container_type in other_types:
            with self.subTest(luy_container_type=luy_container_type):
                self.luy.learning_container_year.container_type = luy_container_type
                self.luy.learning_container_year.save()
                self.assertFalse(
                    is_eligible_to_create_modification_proposal(
                        self.luy, self.person))

    def test_can_only_propose_modification_for_luy_which_is_not_currently_in_proposition(
            self):
        ProposalLearningUnitFactory(learning_unit_year=self.luy)

        self.assertFalse(
            is_eligible_to_create_modification_proposal(self.luy, self.person))

    def test_can_only_propose_modification_for_lu_which_is_not_in_proposition_on_different_year(
            self):
        past_luy_with_proposal = LearningUnitYearFakerFactory(
            learning_container_year__academic_year=self.past_academic_year,
            learning_unit=self.luy.learning_unit)
        ProposalLearningUnitFactory(learning_unit_year=past_luy_with_proposal)

        self.assertFalse(
            is_eligible_to_create_modification_proposal(self.luy, self.person))

    def test_cannot_propose_modification_for_luy_for_which_person_is_not_linked_to_entity(
            self):
        self.person_entity.delete()

        self.assertFalse(
            is_eligible_to_create_modification_proposal(self.luy, self.person))

    def test_all_requirements_are_met_to_propose_modification(self):
        for luy_container_type in FACULTY_UPDATABLE_CONTAINER_TYPES:
            with self.subTest(luy_container_type=luy_container_type):
                self.luy.learning_container_year.container_type = luy_container_type
                self.luy.learning_container_year.save()
                self.assertTrue(
                    is_eligible_to_create_modification_proposal(
                        self.luy, self.person))
    def setUp(self):
        today = datetime.date.today()

        self.person = PersonFactory()
        an_organization = OrganizationFactory(type=organization_type.MAIN)
        self.learning_unit_year = LearningUnitYearFakerFactory(acronym="LOSIS1212",
                                                               subtype=learning_unit_year_subtypes.FULL)
        self.learning_unit_year.academic_year.start_date = today - datetime.timedelta(days=15)
        self.learning_unit_year.academic_year.end_date = today + datetime.timedelta(days=15)
        self.learning_unit_year.academic_year.year = today.year
        self.learning_unit_year.academic_year.save()
        self.learning_unit_year.learning_container_year.container_type = learning_container_year_types.COURSE
        self.learning_unit_year.learning_container_year.save()
        self.learning_unit_year.learning_container_year.campus.organization = an_organization
        self.learning_unit_year.learning_container_year.campus.is_administration = True
        self.learning_unit_year.learning_container_year.campus.save()

        an_entity = EntityFactory(organization=an_organization)
        self.entity_version = EntityVersionFactory(entity=an_entity, entity_type=entity_type.SCHOOL,
                                                   start_date=today - datetime.timedelta(days=25),
                                                   end_date=today.replace(year=today.year + 1))
        self.requirement_entity = EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.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_unit_year.learning_container_year,
            entity=self.entity_version.entity,
            type=entity_container_year_link_type.ALLOCATION_ENTITY
        )
        self.additional_entity_1= EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.learning_container_year,
            entity=self.entity_version.entity,
            type=entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1
        )
        self.additional_entity_2 = EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.learning_container_year,
            entity=self.entity_version.entity,
            type=entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2
        )

        self.person_entity = PersonEntityFactory(person=self.person, entity=an_entity, with_child=True)

        self.client.force_login(self.person.user)
        self.url = reverse('learning_unit_modification_proposal', args=[self.learning_unit_year.id])

        self.form_data = {
            "academic_year": self.learning_unit_year.academic_year.id,
            "first_letter": self.learning_unit_year.acronym[0],
            "acronym": self.learning_unit_year.acronym[1:],
            "title": self.learning_unit_year.title,
            "title_english": self.learning_unit_year.title_english,
            "container_type": self.learning_unit_year.learning_container_year.container_type,
            "internship_subtype": "",
            "credits": self.learning_unit_year.credits,
            "periodicity": self.learning_unit_year.learning_unit.periodicity,
            "status": self.learning_unit_year.status,
            "language": self.learning_unit_year.learning_container_year.language.id,
            "quadrimester": "",
            "campus": self.learning_unit_year.learning_container_year.campus.id,
            "requirement_entity": self.entity_version.id,
            "allocation_entity": self.entity_version.id,
            "additional_entity_1": self.entity_version.id,
            "additional_entity_2": self.entity_version.id,
            "folder_entity": self.entity_version.id,
            "folder_id": "1",
        }
Exemple #27
0
class TestSave(TestCase):
    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
        }

    def test_learning_unit_proposal_form_get_as_faculty_manager(self):
        self.person.user.groups.add(
            Group.objects.get(name=FACULTY_MANAGER_GROUP))
        form = LearningUnitProposalModificationForm(self.form_data,
                                                    person=self.person)
        self.assertTrue(form.fields['state'].disabled)

    def test_learning_unit_proposal_form_get_as_central_manager(self):
        self.person.user.groups.add(
            Group.objects.get(name=CENTRAL_MANAGER_GROUP))
        form = LearningUnitProposalModificationForm(self.form_data,
                                                    person=self.person)
        self.assertFalse(form.fields['state'].disabled)

    def test_invalid_form(self):
        del self.form_data['requirement_entity']

        form = LearningUnitProposalModificationForm(self.form_data,
                                                    self.person)
        with self.assertRaises(ValueError):
            form.save(self.learning_unit_year, PROPOSAL_TYPE, PROPOSAL_STATE)

    def test_learning_unit_update(self):
        form = LearningUnitProposalModificationForm(self.form_data,
                                                    self.person)
        form.save(self.learning_unit_year, PROPOSAL_TYPE, PROPOSAL_STATE)

        self.learning_unit_year.refresh_from_db()

        self.assertEqual(self.learning_unit_year.learning_unit.periodicity,
                         self.form_data['periodicity'])

    def test_learning_unit_year_update(self):
        form = LearningUnitProposalModificationForm(self.form_data,
                                                    person=self.person)
        form.save(self.learning_unit_year, PROPOSAL_TYPE, PROPOSAL_STATE)
        self.learning_unit_year.refresh_from_db()
        self._assert_acronym_has_changed_in_proposal()
        self._assert_common_titles_stored_in_container()
        self.assertFalse(self.learning_unit_year.status)
        self.assertEqual(self.learning_unit_year.credits,
                         Decimal(self.form_data['credits']))
        self.assertEqual(self.learning_unit_year.quadrimester,
                         self.form_data['quadrimester'])
        self.assertEqual(self.learning_unit_year.specific_title,
                         self.form_data["specific_title"])
        self.assertEqual(self.learning_unit_year.specific_title_english,
                         self.form_data["specific_title_english"])

    def _assert_acronym_has_changed_in_proposal(self):
        self.assertEqual(
            self.learning_unit_year.acronym,
            "{}{}".format(self.form_data['first_letter'],
                          self.form_data['acronym']))

    def _assert_common_titles_stored_in_container(self):
        self.assertNotEqual(self.learning_unit_year.specific_title,
                            self.form_data['common_title'])
        self.assertNotEqual(self.learning_unit_year.specific_title_english,
                            self.form_data['common_title_english'])
        self.assertEqual(
            self.learning_unit_year.learning_container_year.common_title,
            self.form_data['common_title'])
        self.assertEqual(
            self.learning_unit_year.learning_container_year.
            common_title_english, self.form_data['common_title_english'])

    def test_learning_container_update(self):
        form = LearningUnitProposalModificationForm(self.form_data,
                                                    self.person)
        form.save(self.learning_unit_year, PROPOSAL_TYPE, PROPOSAL_STATE)

        self.learning_unit_year.refresh_from_db()
        learning_container_year = self.learning_unit_year.learning_container_year

        self.assertEqual(
            learning_container_year.acronym,
            "{}{}".format(self.form_data['first_letter'],
                          self.form_data['acronym']))
        self.assertEqual(learning_container_year.common_title,
                         self.form_data['common_title'])
        self.assertEqual(learning_container_year.common_title_english,
                         self.form_data['common_title_english'])
        self.assertEqual(learning_container_year.language, self.language)
        self.assertEqual(learning_container_year.campus, self.campus)

    def test_requirement_entity(self):
        form = LearningUnitProposalModificationForm(self.form_data,
                                                    self.person)
        form.save(self.learning_unit_year, PROPOSAL_TYPE, PROPOSAL_STATE)

        self.entity_container_year.refresh_from_db()
        self.assertEqual(self.entity_container_year.entity,
                         self.entity_version.entity)

    def test_with_all_entities_set(self):
        today = datetime.date.today()
        entity_1 = EntityFactory(organization=OrganizationFactory(
            type=organization_type.MAIN))
        additional_entity_version_1 = EntityVersionFactory(
            entity_type=entity_type.SCHOOL,
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            entity=entity_1)
        entity_2 = EntityFactory(organization=OrganizationFactory(
            type=organization_type.MAIN))
        additional_entity_version_2 = EntityVersionFactory(
            entity_type=entity_type.SCHOOL,
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            entity=entity_2)
        self.form_data["allocation_entity"] = self.entity_version.id
        self.form_data[
            "additional_requirement_entity_1"] = additional_entity_version_1.id
        self.form_data[
            "additional_requirement_entity_2"] = additional_entity_version_2.id

        form = LearningUnitProposalModificationForm(self.form_data,
                                                    self.person)
        form.save(self.learning_unit_year, PROPOSAL_TYPE, PROPOSAL_STATE)

        entities_by_type = \
            entity_container_year.find_entities_grouped_by_linktype(self.learning_unit_year.learning_container_year)

        expected_entities = {
            entity_container_year_link_type.REQUIREMENT_ENTITY:
            self.entity_version.entity,
            entity_container_year_link_type.ALLOCATION_ENTITY:
            self.entity_version.entity,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1:
            additional_entity_version_1.entity,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2:
            additional_entity_version_2.entity
        }
        self.assertDictEqual(entities_by_type, expected_entities)

    def test_modify_learning_container_subtype(self):
        self.form_data[
            "container_type"] = learning_container_year_types.INTERNSHIP
        self.form_data[
            "internship_subtype"] = internship_subtypes.TEACHING_INTERNSHIP

        form = LearningUnitProposalModificationForm(self.form_data,
                                                    self.person)
        form.save(self.learning_unit_year, PROPOSAL_TYPE, PROPOSAL_STATE)

        self.learning_unit_year.refresh_from_db()

        self.assertEqual(
            self.learning_unit_year.learning_container_year.container_type,
            learning_container_year_types.INTERNSHIP)
        self.assertEqual(self.learning_unit_year.internship_subtype,
                         internship_subtypes.TEACHING_INTERNSHIP)

    def test_creation_proposal_learning_unit(self):
        initial_data_expected = {
            "learning_container_year": {
                "id":
                self.learning_unit_year.learning_container_year.id,
                "acronym":
                self.learning_unit_year.acronym,
                "common_title":
                self.learning_unit_year.learning_container_year.common_title,
                "common_title_english":
                self.learning_unit_year.learning_container_year.
                common_title_english,
                "container_type":
                self.learning_unit_year.learning_container_year.container_type,
                "campus":
                self.learning_unit_year.learning_container_year.campus.id,
                "language":
                self.learning_unit_year.learning_container_year.language.pk,
                "in_charge":
                self.learning_unit_year.learning_container_year.in_charge
            },
            "learning_unit_year": {
                "id": self.learning_unit_year.id,
                "acronym": self.learning_unit_year.acronym,
                "specific_title": self.learning_unit_year.specific_title,
                "specific_title_english":
                self.learning_unit_year.specific_title_english,
                "internship_subtype":
                self.learning_unit_year.internship_subtype,
                "credits": self.learning_unit_year.credits,
                "quadrimester": self.learning_unit_year.quadrimester,
                "status": self.learning_unit_year.status
            },
            "learning_unit": {
                "id": self.learning_unit_year.learning_unit.id,
                "periodicity":
                self.learning_unit_year.learning_unit.periodicity,
                'end_year': self.learning_unit_year.learning_unit.end_year
            },
            "entities": {
                entity_container_year_link_type.REQUIREMENT_ENTITY:
                self.entity_container_year.entity.id,
                entity_container_year_link_type.ALLOCATION_ENTITY:
                None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1:
                None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2:
                None
            }
        }

        form = LearningUnitProposalModificationForm(self.form_data,
                                                    self.person)
        form.save(self.learning_unit_year, PROPOSAL_TYPE, PROPOSAL_STATE)

        a_proposal_learning_unt = proposal_learning_unit.find_by_learning_unit_year(
            self.learning_unit_year)

        self.assertEqual(a_proposal_learning_unt.type, PROPOSAL_TYPE)
        self.assertEqual(a_proposal_learning_unt.state, PROPOSAL_STATE)
        self.assertEqual(a_proposal_learning_unt.author, self.person)

        self.assertDictEqual(a_proposal_learning_unt.initial_data,
                             initial_data_expected)

    def test_when_setting_additional_entity_to_none(self):
        EntityContainerYearFactory(
            learning_container_year=self.learning_unit_year.
            learning_container_year,
            type=entity_container_year_link_type.ALLOCATION_ENTITY)
        EntityContainerYearFactory(learning_container_year=self.
                                   learning_unit_year.learning_container_year,
                                   type=entity_container_year_link_type.
                                   ADDITIONAL_REQUIREMENT_ENTITY_1)
        form = LearningUnitProposalModificationForm(self.form_data,
                                                    self.person)
        form.save(self.learning_unit_year, PROPOSAL_TYPE, PROPOSAL_STATE)

        with self.assertRaises(ObjectDoesNotExist):
            EntityContainerYear.objects.get(
                learning_container_year=self.learning_unit_year.
                learning_container_year,
                type=entity_container_year_link_type.
                ADDITIONAL_REQUIREMENT_ENTITY_1)

    def test_internship_subtype(self):
        self.form_data[
            "internship_subtype"] = internship_subtypes.TEACHING_INTERNSHIP
        form = LearningUnitProposalModificationForm(self.form_data,
                                                    self.person)

        self.assertFalse(form.is_valid())
        self.assertIn(_("learning_unit_type_is_not_internship"),
                      form.errors["internship_subtype"])
Exemple #28
0
    def setUp(self):
        self.person = PersonFactory()
        an_organization = OrganizationFactory(type=organization_type.MAIN)
        current_academic_year = create_current_academic_year()

        today = datetime.date.today()
        an_entity = EntityFactory(organization=an_organization)
        self.entity_version = EntityVersionFactory(
            entity=an_entity,
            entity_type=entity_type.FACULTY,
            start_date=today.replace(year=1900),
            end_date=None)
        self.an_entity_school = EntityFactory(organization=an_organization)
        self.entity_version_school = EntityVersionFactory(
            entity=self.an_entity_school,
            entity_type=entity_type.SCHOOL,
            start_date=today.replace(year=1900),
            end_date=None)

        learning_container_year = LearningContainerYearFactory(
            academic_year=current_academic_year,
            container_type=learning_container_year_types.COURSE,
            requirement_entity=self.entity_version.entity,
        )
        self.learning_unit_year = LearningUnitYearFakerFactory(
            credits=Decimal(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),
            periodicity=learning_unit_year_periodicity.ANNUAL,
            internship_subtype=None)
        self.person_entity = PersonEntityFactory(person=self.person,
                                                 entity=an_entity)
        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,
            "acronym_0": "L",
            "acronym_1": "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": self.learning_unit_year.credits,
            "periodicity": learning_unit_year_periodicity.BIENNIAL_ODD,
            "status": False,
            "language": self.language.pk,
            "quadrimester": quadrimesters.Q1,
            "campus": self.campus.id,
            "entity": self.entity_version.id,
            "folder_id": "1",
            "state": proposal_state.ProposalState.CENTRAL.name,
            'requirement_entity': self.entity_version.id,
            'allocation_entity': self.entity_version.id,
            'additional_entity_1': self.entity_version.id,
            'additional_entity_2': self.entity_version.id,

            # 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': Decimal(20),
            'component-0-hourly_volume_partial_q1': Decimal(10),
            'component-0-hourly_volume_partial_q2': Decimal(10),
            'component-1-hourly_volume_total_annual': Decimal(20),
            'component-1-hourly_volume_partial_q1': Decimal(10),
            'component-1-hourly_volume_partial_q2': Decimal(10),
            'component-0-planned_classes': 1,
            'component-1-planned_classes': 1,
        }
        FacultyManagerGroupFactory()
        CentralManagerGroupFactory()
Exemple #29
0
class TestSave(TestCase):
    def setUp(self):
        self.person = PersonFactory()
        an_organization = OrganizationFactory(type=organization_type.MAIN)
        current_academic_year = create_current_academic_year()

        today = datetime.date.today()
        an_entity = EntityFactory(organization=an_organization)
        self.entity_version = EntityVersionFactory(
            entity=an_entity,
            entity_type=entity_type.FACULTY,
            start_date=today.replace(year=1900),
            end_date=None)
        self.an_entity_school = EntityFactory(organization=an_organization)
        self.entity_version_school = EntityVersionFactory(
            entity=self.an_entity_school,
            entity_type=entity_type.SCHOOL,
            start_date=today.replace(year=1900),
            end_date=None)

        learning_container_year = LearningContainerYearFactory(
            academic_year=current_academic_year,
            container_type=learning_container_year_types.COURSE,
            requirement_entity=self.entity_version.entity,
        )
        self.learning_unit_year = LearningUnitYearFakerFactory(
            credits=Decimal(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),
            periodicity=learning_unit_year_periodicity.ANNUAL,
            internship_subtype=None)
        self.person_entity = PersonEntityFactory(person=self.person,
                                                 entity=an_entity)
        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,
            "acronym_0": "L",
            "acronym_1": "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": self.learning_unit_year.credits,
            "periodicity": learning_unit_year_periodicity.BIENNIAL_ODD,
            "status": False,
            "language": self.language.pk,
            "quadrimester": quadrimesters.Q1,
            "campus": self.campus.id,
            "entity": self.entity_version.id,
            "folder_id": "1",
            "state": proposal_state.ProposalState.CENTRAL.name,
            'requirement_entity': self.entity_version.id,
            'allocation_entity': self.entity_version.id,
            'additional_entity_1': self.entity_version.id,
            'additional_entity_2': self.entity_version.id,

            # 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': Decimal(20),
            'component-0-hourly_volume_partial_q1': Decimal(10),
            'component-0-hourly_volume_partial_q2': Decimal(10),
            'component-1-hourly_volume_total_annual': Decimal(20),
            'component-1-hourly_volume_partial_q1': Decimal(10),
            'component-1-hourly_volume_partial_q2': Decimal(10),
            'component-0-planned_classes': 1,
            'component-1-planned_classes': 1,
        }
        FacultyManagerGroupFactory()
        CentralManagerGroupFactory()

    def test_learning_unit_proposal_form_get_as_faculty_manager(self):
        self.person.user.groups.add(
            Group.objects.get(name=FACULTY_MANAGER_GROUP))
        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.fields['state'].disabled)

    def test_learning_unit_proposal_form_get_as_central_manager(self):
        self.person.user.groups.add(
            Group.objects.get(name=CENTRAL_MANAGER_GROUP))
        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertFalse(form.fields['state'].disabled)

    def test_learning_unit_proposal_form_get_as_central_manager_with_instance(
            self):
        self.person.user.groups.add(
            Group.objects.get(name=CENTRAL_MANAGER_GROUP))
        proposal = ProposalLearningUnitFactory(
            learning_unit_year=self.learning_unit_year,
            state=ProposalState.FACULTY.name,
            entity=self.entity_version.entity)
        form = ProposalBaseForm(self.form_data,
                                self.person,
                                self.learning_unit_year,
                                proposal=proposal)
        self.assertFalse(form.fields['state'].disabled)
        self.assertEqual(form.fields['state'].initial,
                         ProposalState.FACULTY.name)

    def test_learning_unit_year_update(self):
        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()
        learning_unit_year = LearningUnitYear.objects.get(
            pk=self.learning_unit_year.id)
        self._assert_acronym_has_changed_in_proposal(learning_unit_year)
        self._assert_common_titles_stored_in_container(learning_unit_year)
        self.assertFalse(learning_unit_year.status)
        self.assertEqual(learning_unit_year.credits,
                         Decimal(self.form_data['credits']))
        self.assertEqual(learning_unit_year.quadrimester,
                         self.form_data['quadrimester'])
        self.assertEqual(learning_unit_year.specific_title,
                         self.form_data["specific_title"])
        self.assertEqual(learning_unit_year.specific_title_english,
                         self.form_data["specific_title_english"])
        self.assertEqual(learning_unit_year.language, self.language)
        self.assertEqual(learning_unit_year.campus, self.campus)

    def _assert_acronym_has_changed_in_proposal(self, learning_unit_year):
        self.assertEqual(
            learning_unit_year.acronym,
            "{}{}".format(self.form_data['acronym_0'],
                          self.form_data['acronym_1']))

    def _assert_common_titles_stored_in_container(self, learning_unit_year):
        self.assertNotEqual(learning_unit_year.specific_title,
                            self.form_data['common_title'])
        self.assertNotEqual(learning_unit_year.specific_title_english,
                            self.form_data['common_title_english'])
        self.assertEqual(
            learning_unit_year.learning_container_year.common_title,
            self.form_data['common_title'])
        self.assertEqual(
            learning_unit_year.learning_container_year.common_title_english,
            self.form_data['common_title_english'])

    def test_learning_container_update(self):
        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        learning_unit_year = LearningUnitYear.objects.get(
            pk=self.learning_unit_year.id)
        learning_container_year = learning_unit_year.learning_container_year

        self.assertEqual(
            learning_unit_year.acronym,
            self.form_data['acronym_0'] + self.form_data['acronym_1'])
        self.assertEqual(learning_container_year.common_title,
                         self.form_data['common_title'])
        self.assertEqual(learning_container_year.common_title_english,
                         self.form_data['common_title_english'])

    def test_requirement_entity(self):
        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        container = self.learning_unit_year.learning_container_year
        container.refresh_from_db()
        self.assertEqual(container.requirement_entity,
                         self.entity_version.entity)

    def test_with_all_entities_set(self):
        today = datetime.date.today()
        entity_1 = EntityFactory(organization=OrganizationFactory(
            type=organization_type.MAIN))
        additional_entity_version_1 = EntityVersionFactory(
            entity_type=entity_type.SCHOOL,
            start_date=today.replace(year=1900),
            end_date=today.replace(year=today.year + 1),
            entity=entity_1)
        entity_2 = EntityFactory(organization=OrganizationFactory(
            type=organization_type.MAIN))
        additional_entity_version_2 = EntityVersionFactory(
            entity_type=entity_type.SCHOOL,
            start_date=today.replace(year=1900),
            end_date=today.replace(year=today.year + 1),
            entity=entity_2)
        self.form_data["allocation_entity"] = self.entity_version.id
        self.form_data["additional_entity_1"] = additional_entity_version_1.id
        self.form_data["additional_entity_2"] = additional_entity_version_2.id

        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        self.learning_unit_year.learning_container_year.refresh_from_db()
        entities_by_type = self.learning_unit_year.learning_container_year.get_map_entity_by_type(
        )

        expected_entities = {
            entity_container_year_link_type.REQUIREMENT_ENTITY:
            self.entity_version.entity,
            entity_container_year_link_type.ALLOCATION_ENTITY:
            self.entity_version.entity,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1:
            additional_entity_version_1.entity,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2:
            additional_entity_version_2.entity
        }
        self.assertDictEqual(entities_by_type, expected_entities)

    def test_modify_learning_container_subtype(self):
        self.learning_unit_year.learning_container_year.container_type = learning_container_year_types.INTERNSHIP
        self.learning_unit_year.internship_subtype = internship_subtypes.CLINICAL_INTERNSHIP
        self.learning_unit_year.learning_container_year.save()
        self.learning_unit_year.save()
        self.form_data[
            "container_type"] = learning_container_year_types.INTERNSHIP
        self.form_data[
            "internship_subtype"] = internship_subtypes.TEACHING_INTERNSHIP

        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        self.learning_unit_year.refresh_from_db()

        self.assertEqual(
            self.learning_unit_year.learning_container_year.container_type,
            learning_container_year_types.INTERNSHIP)
        self.assertEqual(self.learning_unit_year.internship_subtype,
                         internship_subtypes.TEACHING_INTERNSHIP)

    def test_creation_proposal_learning_unit(self):
        self.maxDiff = None
        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        a_proposal_learning_unt = proposal_learning_unit.find_by_learning_unit_year(
            self.learning_unit_year)

        self.assertEqual(a_proposal_learning_unt.type, PROPOSAL_TYPE)
        self.assertEqual(a_proposal_learning_unt.state, PROPOSAL_STATE)
        self.assertEqual(a_proposal_learning_unt.author, self.person)
        self.assertDictEqual(a_proposal_learning_unt.initial_data,
                             self._get_initial_data_expected())

    def _get_initial_data_expected(self):
        initial_data_expected = build_initial_data(self.learning_unit_year,
                                                   self.entity_version.entity)
        initial_data_expected["learning_unit_year"]["credits"] = '5.00'
        initial_data_expected['entities'] = {
            entity_container_year_link_type.REQUIREMENT_ENTITY:
            self.entity_version.entity.id,
            entity_container_year_link_type.ALLOCATION_ENTITY:
            None,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1:
            None,
            entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2:
            None
        }
        return initial_data_expected

    def test_when_setting_additional_entity_to_none(self):
        self.form_data['additional_entity_1'] = None
        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        self.learning_unit_year.learning_container_year.refresh_from_db()
        self.assertIsNone(self.learning_unit_year.learning_container_year.
                          additional_entity_1)

    def test_creation_proposal_learning_unit_with_school_entity(self):
        self.entity_version.entity_type = SCHOOL
        self.entity_version.save()
        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue('entity' in form.errors[0])

    def test_creation_proposal_learning_unit_with_not_linked_entity(self):
        self.person_entity.entity = self.an_entity_school
        self.person_entity.save()
        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue('entity' in form.errors[1])
Exemple #30
0
 def setUp(self):
     self.learning_unit_year1 = LearningUnitYearFakerFactory(
         acronym=ACRONYM_1)
     self.learning_unit_year2 = LearningUnitYearFakerFactory(
         acronym=ACRONYM_2)