Ejemplo n.º 1
0
    def test_case_user_which_cannot_managed_learning_unit_not_entity_managed(
            self):
        unauthorized_learning_unit_year = LearningUnitYearFactory()

        response = self.client.get(self.url,
                                   data={
                                       'learning_unit_year':
                                       "learning_unit_year_%d" %
                                       unauthorized_learning_unit_year.pk
                                   })
        self.assertEqual(response.status_code,
                         HttpResponseForbidden.status_code)
Ejemplo n.º 2
0
    def test_can_faculty_manager_modify_end_date_partim(self):
        for container_type in ALL_TYPES:
            lunit_container_yr = LearningContainerYearFactory(
                academic_year=self.academic_yr, container_type=container_type)
            luy = LearningUnitYearFactory(
                academic_year=self.academic_yr,
                learning_container_year=lunit_container_yr,
                subtype=PARTIM)

            self.assertTrue(
                perms._is_learning_unit_year_in_state_to_be_modified(
                    luy, self.person_fac, False))
Ejemplo n.º 3
0
    def test_find_last_entity_version_by_learning_unit_year_id(self):
        an_entity_version = EntityVersionFactory()
        learning_unit_year = LearningUnitYearFactory()
        EntityContainerYearFactory(
            entity=an_entity_version.entity,
            learning_container_year=learning_unit_year.learning_container_year,
            type=REQUIREMENT_ENTITY)

        actual_entity_version = find_last_entity_version_by_learning_unit_year_id(
            learning_unit_year_id=learning_unit_year.id,
            entity_type=REQUIREMENT_ENTITY)
        self.assertEqual(an_entity_version, actual_entity_version)
Ejemplo n.º 4
0
 def setUp(self):
     self.academic_year = AcademicYearFactory(year=timezone.now().year)
     self.l_unit_1 = LearningUnitYearFactory(
         acronym="LBIR1212",
         academic_year=self.academic_year,
         subtype=learning_unit_year_subtypes.FULL)
     component = LearningComponentYearFactory(
         learning_unit_year=self.l_unit_1)
     self.attribution_charge_news = [
         AttributionChargeNewFactory(learning_component_year=component)
         for _ in range(5)
     ]
Ejemplo n.º 5
0
    def setUpTestData(cls):
        cls.language_fr = LanguageFactory(code="FR")
        cls.language_en = LanguageFactory(code="EN")
        cls.user = UserFactory()
        cls.person = PersonWithPermissionsFactory("can_access_learningunit", "can_create_learningunit", user=cls.user)
        cls.a_superuser = SuperUserFactory()
        cls.superperson = PersonFactory(user=cls.a_superuser)

        cls.person_entity = PersonEntityFactory(person=cls.superperson)

        cls.academic_year = create_current_academic_year()
        AcademicYearFactory.produce_in_future(quantity=2)
        cls.luy = LearningUnitYearFactory(
            academic_year=cls.academic_year,
            subtype=learning_unit_year_subtypes.FULL,
            learning_container_year__requirement_entity=cls.person_entity.entity,
        )
        cls.future_luy = LearningUnitYearFactory(
            academic_year=cls.academic_year.next(),
            learning_unit=cls.luy.learning_unit,
        )
Ejemplo n.º 6
0
    def test_post_data_complex_prerequisite_OR(self):
        luy_1 = LearningUnitYearFactory(acronym='LSINF1111',
                                        academic_year=self.academic_year)
        luy_2 = LearningUnitYearFactory(acronym='LDROI1200',
                                        academic_year=self.academic_year)
        luy_3 = LearningUnitYearFactory(acronym='LEDPH1200',
                                        academic_year=self.academic_year)

        form_data = {
            "prerequisite_string": "(LSINF1111 ET LDROI1200) OU LEDPH1200"
        }
        self.client.post(self.url, data=form_data)

        prerequisite = Prerequisite.objects.get(
            learning_unit_year=self.learning_unit_year_child.id,
            education_group_year=self.education_group_year_parents[0].id,
        )

        self.assertTrue(prerequisite)
        self.assertEqual(prerequisite.prerequisite_string,
                         "(LSINF1111 ET LDROI1200) OU LEDPH1200")
Ejemplo n.º 7
0
    def test_post_data_prerequisite_learning_units_not_found(self):
        LearningUnitYearFactory(acronym='LDROI1200')
        LearningUnitYearFactory(acronym='LEDPH1200')
        LearningUnitYearFactory(acronym='LSINF1111')

        form_data = {
            "prerequisite_string":
            "(LDROI1200 ET LEDPH1200) OU LZZZ9876 OU (LZZZ6789 ET LSINF1111)"
        }
        response = self.client.post(self.url, data=form_data)
        errors_prerequisite_string = response.context_data.get(
            'form').errors.get('prerequisite_string')
        self.assertEqual(len(errors_prerequisite_string), 2)
        self.assertEqual(
            str(errors_prerequisite_string[0]),
            _("No match has been found for this learning unit :  %(acronym)s")
            % {'acronym': 'LZZZ9876'})
        self.assertEqual(
            str(errors_prerequisite_string[1]),
            _("No match has been found for this learning unit :  %(acronym)s")
            % {'acronym': 'LZZZ6789'})
Ejemplo n.º 8
0
def create_learning_unit_with_context(academic_year, structure, entity, acronym):
    learning_container_year = LearningContainerYearFactory(academic_year=academic_year, acronym=acronym)
    learning_unit_year = LearningUnitYearFactory(structure=structure,
                                                 acronym=acronym,
                                                 learning_container_year=learning_container_year,
                                                 academic_year=academic_year)

    EntityContainerYearFactory(type=entity_container_year_link_type.ALLOCATION_ENTITY,
                               learning_container_year=learning_container_year,
                               entity=entity)

    return learning_unit_year
Ejemplo n.º 9
0
def _setup_learning_unit_year(learning_unit, learning_container_year, subtype):
    learning_unit_year = LearningUnitYearFactory(
        learning_unit=learning_unit,
        learning_container_year=learning_container_year,
        academic_year=learning_container_year.academic_year,
        subtype=subtype
    )
    learning_unit = learning_unit_year.learning_unit
    learning_unit.learning_container = learning_container_year.learning_container
    learning_unit.save()

    return learning_unit_year
Ejemplo n.º 10
0
    def test_case_update_post_data_correctly_saved(self):
        learning_unit_year_to_update = LearningUnitYearFactory(
            learning_unit=self.learning_unit, learning_container_year=self.learning_container_year, subtype=FULL,
            academic_year=self.current_academic_year
        )

        form = LearningUnitYearModelForm(data=self.post_data, person=self.central_manager, subtype=FULL,
                                         instance=learning_unit_year_to_update)
        self.assertTrue(form.is_valid(), form.errors)
        luy = form.save(learning_container_year=self.learning_container_year, learning_unit=self.learning_unit)

        self.assertEqual(luy, learning_unit_year_to_update)
Ejemplo n.º 11
0
 def setUpTestData(cls):
     cls.luy = LearningUnitYearFactory()
     cls.teaching_materials = TeachingMaterialFactory(
         learning_unit_year=cls.luy)
     cls.person = PersonFactory()
     url_kwargs = {
         'acronym': cls.luy.acronym,
         'year': cls.luy.academic_year.year
     }
     cls.url = reverse(
         'learning_unit_api_v1:learningunitteachingmaterials_read',
         kwargs=url_kwargs)
Ejemplo n.º 12
0
 def test_ids_correctly_converted_to_instances(self):
     group_element = GroupElementYearFactory(
         child_branch=None, child_leaf=LearningUnitYearFactory())
     root_ids_by_object_id = group_element_year.find_learning_unit_formations(
         [group_element.child_leaf])
     result = group_element_year._convert_parent_ids_to_instances(
         root_ids_by_object_id)
     expected_result = {group_element.child_leaf.id: [group_element.parent]}
     self.assertDictEqual(result, expected_result)
     self.assertIsInstance(list(result.keys())[0], int)
     self.assertIsInstance(result[group_element.child_leaf.id][0],
                           EducationGroupYear)
Ejemplo n.º 13
0
 def test_when_existing_proposal_in_epc(self):
     luy = LearningUnitYearFactory(
         academic_year=self.academic_yr,
         learning_unit__existing_proposal_in_epc=True)
     self.assertFalse(perms.is_eligible_for_modification(luy, None))
     self.assertFalse(perms.is_eligible_for_modification_end_date(
         luy, None))
     self.assertFalse(perms.is_eligible_to_create_partim(luy, None))
     self.assertFalse(
         perms.is_eligible_to_create_modification_proposal(luy, None))
     self.assertFalse(
         perms.is_eligible_to_delete_learning_unit_year(luy, None))
Ejemplo n.º 14
0
 def test_creation_case_wrong_learning_unit_data(self, mock_is_valid):
     a_new_learning_unit_partim = LearningUnitYearFactory.build(
         academic_year=self.current_academic_year,
         acronym=FULL_ACRONYM + 'B',
         subtype=learning_unit_year_subtypes.PARTIM,
         language=self.learning_unit_year_full.language)
     post_data = get_valid_form_data(a_new_learning_unit_partim)
     form = _instanciate_form(
         learning_unit_full=self.learning_unit_year_full.learning_unit,
         academic_year=self.learning_unit_year_full.academic_year,
         post_data=post_data)
     self.assertFalse(form.is_valid())
Ejemplo n.º 15
0
 def setUpTestData(cls):
     cls.academic_year = AcademicYearFactory(current=True)
     cls.l_unit_1 = LearningUnitYearFactory(
         acronym="LBIR1212",
         academic_year=cls.academic_year,
         subtype=learning_unit_year_subtypes.FULL)
     component = LearningComponentYearFactory(
         learning_unit_year=cls.l_unit_1)
     cls.attribution_charge_news = [
         AttributionChargeNewFactory(learning_component_year=component)
         for _ in range(5)
     ]
Ejemplo n.º 16
0
    def test_luy_to_duplicate_with_error(self, mock_method):
        mock_method.side_effect = Mock(side_effect=Error("test error"))

        luy_with_error = LearningUnitYearFactory(
            learning_unit=self.learning_unit,
            academic_year=self.academic_years[-2],
        )
        self.assertEqual(LearningUnitYear.objects.count(), 1)

        result, errors = LearningUnitAutomaticPostponement().postpone()
        self.assertEqual(errors, [luy_with_error.learning_unit])
        self.assertEqual(len(result), 0)
Ejemplo n.º 17
0
    def test_not_is_eligible_to_modify_by_proposal(self, mock_perm):
        learning_unit_yr = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            subtype=learning_unit_year_subtypes.FULL,
            learning_container_year=self.lcy)
        person_faculty_manager = FacultyManagerFactory()

        with self.assertRaises(PermissionDenied) as perm_ex:
            is_eligible_to_modify_by_proposal(learning_unit_yr,
                                              person_faculty_manager, True)
            self.assertEqual('{}'.format(perm_ex.exception),
                             MSG_NOT_ELIGIBLE_TO_PUT_IN_PROPOSAL_ON_THIS_YEAR)
Ejemplo n.º 18
0
    def test_post_data_modify_existing_prerequisite(self):
        LearningUnitYearFactory(acronym='LSINF1111',
                                academic_year=self.academic_year)
        luy_2 = LearningUnitYearFactory(acronym='LSINF1112',
                                        academic_year=self.academic_year)
        GroupElementYearChildLeafFactory(
            parent=self.education_group_year_parents[0], child_leaf=luy_2)

        form_data = {"prerequisite_string": "LSINF1111"}
        self.client.post(self.url, data=form_data)

        form_data = {"prerequisite_string": "LSINF1112"}
        self.client.post(self.url, data=form_data)

        prerequisite = Prerequisite.objects.get(
            learning_unit_year=self.learning_unit_year_child.id,
            education_group_year=self.education_group_year_parents[0].id,
        )

        self.assertTrue(prerequisite)
        self.assertEqual(prerequisite.prerequisite_string, "LSINF1112")
Ejemplo n.º 19
0
 def test_is_eligible_to_modify_by_proposal(self, mock_perm):
     lu = LearningUnitFactory(existing_proposal_in_epc=False)
     learning_unit_yr = LearningUnitYearFactory(
         academic_year=self.next_academic_yr,
         subtype=learning_unit_year_subtypes.FULL,
         learning_unit=lu,
         learning_container_year=self.lcy)
     ProposalLearningUnitFactory(learning_unit_year=learning_unit_yr)
     person_faculty_manager = FacultyManagerFactory()
     self.assertTrue(
         is_eligible_to_modify_by_proposal(learning_unit_yr,
                                           person_faculty_manager, True))
Ejemplo n.º 20
0
    def test_can_delete_learning_unit_year_with_faculty_manager_role(self):
        # Faculty manager can only delete other type than COURSE/INTERNSHIP/DISSERTATION
        person = PersonFactory()
        add_to_group(person.user, FACULTY_MANAGER_GROUP)
        entity_version = EntityVersionFactory(entity_type=entity_type.FACULTY,
                                              acronym="SST",
                                              start_date=datetime.date(
                                                  year=1990, month=1, day=1),
                                              end_date=None)
        PersonEntityFactory(person=person,
                            entity=entity_version.entity,
                            with_child=True)

        # Creation UE
        learning_unit = LearningUnitFactory()
        l_containeryear = LearningContainerYearFactory(
            academic_year=self.academic_year,
            container_type=learning_container_year_types.COURSE)
        EntityContainerYearFactory(
            learning_container_year=l_containeryear,
            entity=entity_version.entity,
            type=entity_container_year_link_type.REQUIREMENT_ENTITY)
        learning_unit_year = LearningUnitYearFactory(
            learning_unit=learning_unit,
            academic_year=self.academic_year,
            learning_container_year=l_containeryear,
            subtype=learning_unit_year_subtypes.FULL)

        # Cannot remove FULL COURSE
        self.assertFalse(
            base.business.learning_units.perms.
            is_eligible_to_delete_learning_unit_year(learning_unit_year,
                                                     person))

        # Can remove PARTIM COURSE
        learning_unit_year.subtype = learning_unit_year_subtypes.PARTIM
        learning_unit_year.save()
        self.assertTrue(
            base.business.learning_units.perms.
            is_eligible_to_delete_learning_unit_year(learning_unit_year,
                                                     person))

        # With both role, greatest is taken
        add_to_group(person.user, CENTRAL_MANAGER_GROUP)
        learning_unit_year.subtype = learning_unit_year_subtypes.FULL
        learning_unit_year.save()
        self.assertTrue(
            base.business.learning_units.perms.
            is_eligible_to_delete_learning_unit_year(learning_unit_year,
                                                     person))
Ejemplo n.º 21
0
    def setUp(self):
        # Create academic year
        self.academic_year = AcademicYearFactory(year=2017)
        # Create several learning container year - 2017
        self.lbir1200_2017 = LearningContainerYearFactory(academic_year=self.academic_year, acronym="LBIR1200")
        LearningUnitYearFactory(academic_year=self.academic_year, learning_container_year=self.lbir1200_2017)
        self.lbir1250_2017 = LearningContainerYearFactory(academic_year=self.academic_year, acronym="LBIR1250")
        LearningUnitYearFactory(academic_year=self.academic_year, learning_container_year=self.lbir1250_2017)
        self.lbir1300_2017 = LearningContainerYearFactory(academic_year=self.academic_year, acronym="LBIR1300")
        LearningUnitYearFactory(academic_year=self.academic_year, learning_container_year=self.lbir1300_2017)
        self.lagro1200_2017 = LearningContainerYearFactory(academic_year=self.academic_year, acronym="LAGRO1200")
        LearningUnitYearFactory(academic_year=self.academic_year, learning_container_year=self.lagro1200_2017)

        # Create several learning container year - 2016
        self.academic_year_2016 = AcademicYearFactory(year=2016)
        self.lbir1200_2016 = LearningContainerYearFactory(academic_year=self.academic_year_2016, acronym="LBIR1200")
        LearningUnitYearFactory(academic_year=self.academic_year_2016, learning_container_year=self.lbir1200_2016)
        self.lbir1250_2016 = LearningContainerYearFactory(academic_year=self.academic_year_2016, acronym="LBIR1250")
        LearningUnitYearFactory(academic_year=self.academic_year_2016, learning_container_year=self.lbir1250_2016)

        # Creation Person/Tutor
        Group.objects.create(name="tutors")
        person = PersonFactory(global_id="98363454")
        self.tutor = TutorFactory(person=person)

        applications = [
            _get_application_example(self.lbir1200_2017, '3.5', '35.6'),  # Application 2017
            _get_application_example(self.lbir1300_2017, '7.5', '25'),   # Application 2017
            _get_application_example(self.lbir1200_2016, '2', '30'),  # Application 2016
        ]
        self.attribution = AttributionNewFactory(global_id=person.global_id,
                                                 attributions=_get_attributions_default(),
                                                 applications=applications)
Ejemplo n.º 22
0
    def setUp(self):
        self.academic_year = AcademicYearFactory(
            year=datetime.date.today().year)
        self.academic_calendar = AcademicCalendarFactory.build(
            title="Submission of score encoding - 1",
            start_date=self.academic_year.start_date,
            end_date=self.academic_year.end_date,
            academic_year=self.academic_year,
            reference=academic_calendar_type.SCORES_EXAM_SUBMISSION)
        self.academic_calendar.save(functions=[])
        SessionExamCalendarFactory(academic_calendar=self.academic_calendar,
                                   number_session=number_session.ONE)
        # Offer year CHIM1BA
        self.offer_year = OfferYearFactory(acronym="CHIM1BA",
                                           academic_year=self.academic_year)
        self.learning_unit_year = LearningUnitYearFactory(
            acronym="LBIR1210", academic_year=self.academic_year)
        self._create_context_exam_enrollments(self.learning_unit_year,
                                              self.offer_year, 10, 3)
        self.learning_unit_year_2 = LearningUnitYearFactory(
            acronym="LBIR1211", academic_year=self.academic_year)
        self._create_context_exam_enrollments(self.learning_unit_year_2,
                                              self.offer_year, 5)

        # Offer year DIR2BA
        self.offer_year_2 = OfferYearFactory(acronym="DIR2BA",
                                             academic_year=self.academic_year)
        self._create_context_exam_enrollments(self.learning_unit_year,
                                              self.offer_year_2, 8, 5)
        self.program_manager = ProgramManagerFactory(
            offer_year=self.offer_year)
        ProgramManagerFactory(offer_year=self.offer_year_2,
                              person=self.program_manager.person)
        # Tutor [Tom Dupont] have an attribution to LBIR1210
        person = PersonFactory(last_name="Dupont", first_name="Thierry")
        self.tutor = TutorFactory(person=person)
        test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            score_responsible=True)
Ejemplo n.º 23
0
    def setUpTestData(cls):
        cls.person = PersonFactory()
        cls.education_group_year_1 = EducationGroupYearFactory(title_english="")
        cls.education_group_year_2 = EducationGroupYearFactory(title_english="")
        cls.education_group_year_3 = EducationGroupYearFactory(title_english="")
        cls.learning_unit_year_1 = LearningUnitYearFactory(specific_title_english="")
        cls.learning_unit_year_2 = LearningUnitYearFactory(specific_title_english="")
        cls.learning_component_year_1 = LearningComponentYearFactory(
            learning_container_year=cls.learning_unit_year_1.learning_container_year, hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=10)
        cls.learning_component_year_2 = LearningComponentYearFactory(
            learning_container_year=cls.learning_unit_year_1.learning_container_year, hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=10)
        cls.learning_unit_component_1 = LearningUnitComponentFactory(
            learning_component_year=cls.learning_component_year_1,
            learning_unit_year=cls.learning_unit_year_1)
        cls.learning_unit_component_2 = LearningUnitComponentFactory(
            learning_component_year=cls.learning_component_year_2,
            learning_unit_year=cls.learning_unit_year_1)
        cls.group_element_year_1 = GroupElementYearFactory(parent=cls.education_group_year_1,
                                                           child_branch=cls.education_group_year_2)
        cls.group_element_year_2 = GroupElementYearFactory(parent=cls.education_group_year_2,
                                                           child_branch=None,
                                                           child_leaf=cls.learning_unit_year_1)
        cls.group_element_year_3 = GroupElementYearFactory(parent=cls.education_group_year_1,
                                                           child_branch=cls.education_group_year_3)
        cls.group_element_year_4 = GroupElementYearFactory(parent=cls.education_group_year_3,
                                                           child_branch=None,
                                                           child_leaf=cls.learning_unit_year_2)
        cls.user = UserFactory()
        cls.person = PersonFactory(user=cls.user)
        cls.user.user_permissions.add(Permission.objects.get(codename="can_access_education_group"))

        cls.url = reverse(
            "learning_unit_utilization",
            args=[
                cls.education_group_year_1.id,
                cls.learning_unit_year_1.id,
            ]
        )
Ejemplo n.º 24
0
    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))
Ejemplo n.º 25
0
    def test_check_learning_unit_year_deletion_with_proposal(self):
        l_container_year = LearningContainerYearFactory(acronym="LBIR1212", academic_year=self.academic_year)
        l_unit_1 = LearningUnitYearFactory(acronym="LBIR1212", learning_container_year=l_container_year,
                                           academic_year=self.academic_year, subtype=learning_unit_year_subtypes.FULL)
        ProposalLearningUnitFactory(learning_unit_year=l_unit_1)
        msg = deletion._check_learning_unit_proposal(l_unit_1)

        msg = list(msg.values())
        self.assertEqual(msg, [
            _("%(subtype)s %(acronym)s is in proposal for the year %(year)s") % {'subtype': _('The learning unit'),
                                                                                 'acronym': l_unit_1.acronym,
                                                                                 'year': l_unit_1.academic_year}
        ])
Ejemplo n.º 26
0
 def setUp(self):
     self.education_group_year_1 = EducationGroupYearFactory(credits=10)
     self.education_group_year_2 = EducationGroupYearFactory(credits=20)
     self.learning_unit_year_1 = LearningUnitYearFactory()
     self.group_element_year_1 = GroupElementYearFactory(
         parent=self.education_group_year_1,
         child_branch=self.education_group_year_2,
         is_mandatory=True)
     self.group_element_year_2 = GroupElementYearFactory(
         parent=self.education_group_year_2,
         child_branch=None,
         child_leaf=self.learning_unit_year_1,
         is_mandatory=True)
Ejemplo n.º 27
0
def _setup_learning_unit_year(learning_unit, learning_container_year, subtype):
    common_luy_data = _get_default_common_value_learning_unit_year(learning_container_year, subtype)
    learning_unit_year = LearningUnitYearFactory(
        learning_unit=learning_unit,
        learning_container_year=learning_container_year,
        academic_year=learning_container_year.academic_year,
        subtype=subtype,
        **common_luy_data
    )
    learning_unit = learning_unit_year.learning_unit
    learning_unit.learning_container = learning_container_year.learning_container
    learning_unit.save()
    return learning_unit_year
Ejemplo n.º 28
0
 def _create_learning_unit_year_for_entity(self, an_entity):
     l_container_yr = LearningContainerYearFactory(
         acronym="LBIR1100",
         academic_year=self.current_academic_year,
         container_type=learning_container_year_types.COURSE)
     EntityContainerYearFactory(
         learning_container_year=l_container_yr,
         entity=an_entity,
         type=entity_container_year_link_type.REQUIREMENT_ENTITY)
     return LearningUnitYearFactory(
         acronym="LBIR1100",
         learning_container_year=l_container_yr,
         academic_year=self.current_academic_year)
Ejemplo n.º 29
0
    def test_case_update_internship_subtype_is_disabled(self):
        container = LearningContainerYearFactory(
            container_type=learning_container_year_types.COURSE)
        self.form = LearningUnitYearModelForm(
            data=None,
            person=self.central_manager,
            subtype=PARTIM,
            instance=LearningUnitYearFactory(
                learning_container_year=container))

        self.assertTrue(self.form.fields['internship_subtype'].disabled)

        container.container_type = learning_container_year_types.INTERNSHIP
        container.save()
        self.form = LearningUnitYearModelForm(
            data=None,
            person=self.central_manager,
            subtype=PARTIM,
            instance=LearningUnitYearFactory(
                learning_container_year=container))

        self.assertFalse(self.form.fields['internship_subtype'].disabled)
Ejemplo n.º 30
0
    def test_when_prerequisite_learning_unit_does_not_exist_in_n1(self):
        prerequisite = PrerequisiteFactory(
            learning_unit_year__academic_year=self.current_academic_year,
            education_group_year=self.current_education_group_year)

        PrerequisiteItemFactory(prerequisite=prerequisite, )

        LearningUnitYearFactory(
            learning_unit=prerequisite.learning_unit_year.learning_unit,
            academic_year=self.next_academic_year,
        )

        GroupElementYearFactory(
            parent=self.current_group_element_year.child_branch,
            child_branch=None,
            child_leaf=prerequisite.learning_unit_year)

        GroupElementYearFactory(parent=EducationGroupYearFactory(
            education_group=self.current_group_element_year.child_branch.
            education_group,
            academic_year=self.next_academic_year),
                                child_branch=None,
                                child_leaf=LearningUnitYearFactory(
                                    academic_year=self.next_academic_year))

        self.postponer = PostponeContent(self.current_education_group_year)

        new_root = self.postponer.postpone()

        self.assertIn(
            _("%(learning_unit_year)s is not anymore contained in "
              "%(education_group_year_root)s "
              "=> the prerequisite for %(learning_unit_year)s is not copied.")
            % {
                "education_group_year_root":
                "{} - {}".format(new_root.partial_acronym, new_root.acronym),
                "learning_unit_year":
                prerequisite.learning_unit_year.acronym,
            }, [str(warning) for warning in self.postponer.warnings])