Пример #1
0
    def test_post_data_prerequisite_learning_units_not_found(self):
        luy_1 = LearningUnitYearFactory(acronym='LDROI1200',
                                        academic_year=self.academic_year)
        GroupElementYearChildLeafFactory(
            parent=self.education_group_year_parents[0], child_leaf=luy_1)
        luy_2 = LearningUnitYearFactory(acronym='LEDPH1200',
                                        academic_year=self.academic_year)
        GroupElementYearChildLeafFactory(
            parent=self.education_group_year_parents[0], child_leaf=luy_2)
        luy_3 = LearningUnitYearFactory(acronym='LSINF1111',
                                        academic_year=self.academic_year)
        GroupElementYearChildLeafFactory(
            parent=self.education_group_year_parents[0], child_leaf=luy_3)

        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'})
Пример #2
0
    def setUpTestData(cls):
        cls.parent_egy = EducationGroupYearFactory()
        cls.education_group_types = EducationGroupTypeFactory.create_batch(3)
        GroupElementYearFactory.create_batch(
            3,
            parent=cls.parent_egy,
            child_branch__education_group_type=cls.education_group_types[0])
        GroupElementYearFactory.create_batch(
            2,
            parent=cls.parent_egy,
            child_branch__education_group_type=cls.education_group_types[1])
        GroupElementYearChildLeafFactory.create_batch(2, parent=cls.parent_egy)

        cls.reference_group_element_year_children = GroupElementYearFactory(
            parent=cls.parent_egy,
            child_branch__education_group_type=cls.education_group_types[0],
            link_type=LinkTypes.REFERENCE.name)
        GroupElementYearFactory.create_batch(
            2,
            parent=cls.reference_group_element_year_children.child_branch,
            child_branch__education_group_type=cls.education_group_types[1])
        GroupElementYearFactory(
            parent=cls.reference_group_element_year_children.child_branch,
            child_branch__education_group_type=cls.education_group_types[2])

        cls.child = EducationGroupYearFactory(
            education_group_type=cls.education_group_types[0])
        GroupElementYearFactory.create_batch(
            2,
            parent=cls.child,
            child_branch__education_group_type=cls.education_group_types[2])
Пример #3
0
    def setUpTestData(cls):
        cls.root = TrainingFactory(
            academic_year__current=True,
            education_group_type=EducationGroupTypeFactory(
                name=education_group_types.TrainingType.MASTER_MA_120.name))
        cls.children_level_0 = GroupElementYearFactory.create_batch(
            1,
            parent=cls.root,
            child_branch__education_group_type__group=True,
            child_branch__academic_year=cls.root.academic_year)

        cls.children_level_1 = GroupElementYearFactory.create_batch(
            3,
            parent=cls.children_level_0[0].child_branch,
            child_branch__education_group_type__group=True,
            child_branch__academic_year=cls.root.academic_year)
        cls.children_level_2 = GroupElementYearFactory.create_batch(
            1,
            parent=cls.children_level_1[0].child_branch,
            child_branch__education_group_type__group=True,
            child_branch__academic_year=cls.root.academic_year)
        cls.lu_children_level_2 = GroupElementYearChildLeafFactory.create_batch(
            2,
            parent=cls.children_level_1[1].child_branch,
            child_leaf__academic_year=cls.root.academic_year)

        cls.lu_children_level_3 = GroupElementYearChildLeafFactory.create_batch(
            2,
            parent=cls.children_level_2[0].child_branch,
            child_leaf__academic_year=cls.root.academic_year)
Пример #4
0
    def test_post_data_complex_prerequisite_OR(self):
        luy_1 = LearningUnitYearFactory(acronym='LSINF1111',
                                        academic_year=self.academic_year)
        GroupElementYearChildLeafFactory(
            parent=self.education_group_year_parents[0], child_leaf=luy_1)
        luy_2 = LearningUnitYearFactory(acronym='LDROI1200',
                                        academic_year=self.academic_year)
        GroupElementYearChildLeafFactory(
            parent=self.education_group_year_parents[0], child_leaf=luy_2)
        luy_3 = LearningUnitYearFactory(acronym='LEDPH1200',
                                        academic_year=self.academic_year)
        GroupElementYearChildLeafFactory(
            parent=self.education_group_year_parents[0], child_leaf=luy_3)

        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")
Пример #5
0
    def setUpTestData(cls):
        cls.education_group_year = EducationGroupYearFactory()
        cls.child_leaves = GroupElementYearChildLeafFactory.create_batch(
            2, parent=cls.education_group_year, is_mandatory=True)
        for node, acronym in zip(
                cls.child_leaves,
            ["LCORS124" + str(i) for i in range(0, len(cls.child_leaves))]):
            node.child_leaf.acronym = acronym
            node.child_leaf.save()

        cls.luy_children = [child.child_leaf for child in cls.child_leaves]
        cls.workbook_contains = \
            EducationGroupYearLearningUnitsContainedToExcel(cls.education_group_year, CustomXlsForm({}))._to_workbook()
        cls.sheet_contains = cls.workbook_contains.worksheets[0]

        generator_container = GenerateContainer(
            cls.education_group_year.academic_year,
            cls.education_group_year.academic_year)
        cls.luy = generator_container.generated_container_years[
            0].learning_unit_year_full

        cls.lecturing_component = LecturingLearningComponentYearFactory(
            learning_unit_year=cls.luy)
        cls.practical_component = PracticalLearningComponentYearFactory(
            learning_unit_year=cls.luy)
        cls.person_1 = PersonFactory(last_name='Dupont',
                                     first_name="Marcel",
                                     email="*****@*****.**")
        cls.person_2 = PersonFactory(last_name='Marseillais',
                                     first_name="Pol",
                                     email="*****@*****.**")
        cls.tutor_1 = TutorFactory(person=cls.person_1)
        cls.tutor_2 = TutorFactory(person=cls.person_2)
        cls.attribution_1 = AttributionNewFactory(
            tutor=cls.tutor_1,
            learning_container_year=cls.luy.learning_container_year)
        cls.charge_lecturing = AttributionChargeNewFactory(
            attribution=cls.attribution_1,
            learning_component_year=cls.lecturing_component)
        cls.charge_practical = AttributionChargeNewFactory(
            attribution=cls.attribution_1,
            learning_component_year=cls.practical_component)
        cls.attribution_2 = AttributionNewFactory(
            tutor=cls.tutor_2,
            learning_container_year=cls.luy.learning_container_year)
        cls.charge_lecturing = AttributionChargeNewFactory(
            attribution=cls.attribution_2,
            learning_component_year=cls.lecturing_component)
        cls.charge_practical = AttributionChargeNewFactory(
            attribution=cls.attribution_2,
            learning_component_year=cls.practical_component)
        cls.gey = GroupElementYearChildLeafFactory(child_leaf=cls.luy)
Пример #6
0
    def test_return_true_if_child_is_learning_unit_and_user_is_central_manager(
            self):
        GroupElementYearChildLeafFactory(parent=self.group_element_year.parent)
        person_entity = PersonEntityFactory(
            entity=self.group_element_year.parent.management_entity,
            person=CentralManagerFactory())

        self.assertTrue(
            can_update_group_element_year(person_entity.person.user,
                                          self.group_element_year))
Пример #7
0
    def test_return_true_if_child_is_learning_unit_and_user_is_central_manager(
            self):
        central_manager = create_person_with_permission_and_group(
            CENTRAL_MANAGER_GROUP, 'change_educationgroup')
        GroupElementYearChildLeafFactory(parent=self.group_element_year.parent)
        person_entity = PersonEntityFactory(
            entity=self.group_element_year.parent.management_entity,
            person=central_manager)

        self.assertTrue(
            can_update_group_element_year(person_entity.person.user,
                                          self.group_element_year))
Пример #8
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")
Пример #9
0
    def test_post_data_simple_prerequisite(self):
        luy_1 = LearningUnitYearFactory(acronym='LSINF1111',
                                        academic_year=self.academic_year)
        GroupElementYearChildLeafFactory(
            parent=self.education_group_year_parents[0], child_leaf=luy_1)

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

        redirect_url = reverse("learning_unit_prerequisite",
                               args=[
                                   self.education_group_year_parents[0].id,
                                   self.learning_unit_year_child.id
                               ])
        self.assertRedirects(response, redirect_url)

        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")
Пример #10
0
 def test_can_detach_if_duplicate_luy(self):
     GroupElementYearChildLeafFactory(
         parent=self.children_level_1[0].child_branch,
         child_leaf=self.lu_children_level_2[0].child_leaf)
     strategy = DetachEducationGroupYearStrategy(self.children_level_1[1])
     self.assertIsNone(strategy._check_detach_prerequisite_rules())