예제 #1
0
    def setUpTestData(cls):
        """
        |LBIOL212O - Cours au choix
        |--Common Core
               |-- Learning unit year
        """
        cls.academic_year = AcademicYearFactory(year=2018)
        cls.mini_training = MiniTrainingFactory(
            acronym="CCHOIXM60",
            partial_acronym='LBIOL212O',
            academic_year=cls.academic_year)
        cls.common_core = GroupFactory(
            education_group_type__name=GroupType.COMMON_CORE.name,
            academic_year=cls.academic_year)
        GroupElementYearFactory(parent=cls.mini_training,
                                child_branch=cls.common_core,
                                child_leaf=None)
        cls.learning_unit_year = LearningUnitYearFactory(
            academic_year=cls.academic_year,
            learning_container_year__academic_year=cls.academic_year)
        GroupElementYearFactory(parent=cls.common_core,
                                child_branch=None,
                                child_leaf=cls.learning_unit_year)

        cls.person = PersonFactory()
        url_kwargs = {
            'partial_acronym': cls.mini_training.partial_acronym,
            'year': cls.mini_training.academic_year.year
        }
        cls.url = reverse('education_group_api_v1:' +
                          MiniTrainingTreeView.name,
                          kwargs=url_kwargs)
예제 #2
0
    def setUp(self):
        self.current_academic_year = create_current_academic_year()
        self.person = PersonFactory()
        self.education_group_year_1 = EducationGroupYearFactory()
        self.education_group_year_2 = EducationGroupYearFactory()
        self.education_group_year_3 = EducationGroupYearFactory()
        self.learning_unit_year_1 = LearningUnitYearFactory()

        self.learning_component_year_1 = LearningComponentYearFactory(
            learning_container_year=self.learning_unit_year_1.
            learning_container_year,
            hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=10)

        self.learning_component_year_2 = LearningComponentYearFactory(
            learning_container_year=self.learning_unit_year_1.
            learning_container_year,
            hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=10)

        self.learning_unit_component_1 = LearningUnitComponentFactory(
            learning_component_year=self.learning_component_year_1,
            learning_unit_year=self.learning_unit_year_1)

        self.learning_unit_component_2 = LearningUnitComponentFactory(
            learning_component_year=self.learning_component_year_2,
            learning_unit_year=self.learning_unit_year_1)

        self.learning_unit_year_without_container = LearningUnitYearFactory(
            learning_container_year=None)

        self.group_element_year_1 = GroupElementYearFactory(
            parent=self.education_group_year_1,
            child_branch=self.education_group_year_2)

        self.group_element_year_2 = GroupElementYearFactory(
            parent=self.education_group_year_1,
            child_branch=None,
            child_leaf=self.learning_unit_year_1)

        self.group_element_year_3 = GroupElementYearFactory(
            parent=self.education_group_year_1,
            child_branch=self.education_group_year_3)

        self.group_element_year_without_container = GroupElementYearFactory(
            parent=self.education_group_year_1,
            child_branch=None,
            child_leaf=self.learning_unit_year_without_container)

        self.user = UserFactory()
        self.person = PersonFactory(user=self.user)
        self.user.user_permissions.add(
            Permission.objects.get(codename="can_access_education_group"))

        self.url = reverse("education_group_content",
                           args=[
                               self.education_group_year_1.id,
                               self.education_group_year_1.id,
                           ])
        self.client.force_login(self.user)
예제 #3
0
    def setUp(self):
        # Create 2m pgrm structure as
        #   2M
        #   |--FINALITY_LIST
        #      |--2MS
        #      |--2MD

        self.master_120 = TrainingFactory(
            academic_year=self.academic_year_2018,
            education_group_type__name=TrainingType.PGRM_MASTER_120.name,
            education_group__end_year=None
        )
        self.finality_group = GroupFactory(
            academic_year=self.academic_year_2018,
            education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name,
            education_group__end_year=None
        )
        GroupElementYearFactory(parent=self.master_120, child_branch=self.finality_group)

        self.master_120_specialized = GroupFactory(
            academic_year=self.academic_year_2018,
            education_group_type__name=TrainingType.MASTER_MS_120.name,
            education_group__end_year=None
        )
        GroupElementYearFactory(parent=self.finality_group, child_branch=self.master_120_specialized)
        self.master_120_didactic = GroupFactory(
            academic_year=self.academic_year_2018,
            education_group_type__name=TrainingType.MASTER_MD_120.name,
            education_group__end_year=self.academic_year_2019
        )
        GroupElementYearFactory(parent=self.finality_group, child_branch=self.master_120_didactic)
예제 #4
0
    def test_postpone_with_same_child_branch_existing_in_N1(self):
        n1_child_branch = EducationGroupYearFactory(
            academic_year=self.next_academic_year,
            education_group=self.current_group_element_year.child_branch.
            education_group,
        )
        n_child_branch = GroupElementYearFactory(
            parent=self.current_group_element_year.child_branch,
            child_branch__academic_year=self.current_academic_year,
            child_branch__education_group__end_year=None)

        GroupElementYearFactory(parent=self.next_education_group_year,
                                child_branch=n1_child_branch)

        AuthorizedRelationshipFactory(
            parent_type=self.next_education_group_year.education_group_type,
            child_type=n1_child_branch.education_group_type,
            min_count_authorized=1)

        self.postponer = PostponeContent(self.current_education_group_year)

        new_root = self.postponer.postpone()

        self.assertEqual(new_root, self.next_education_group_year)
        self.assertEqual(new_root.groupelementyear_set.count(), 1)
        new_child_branch = new_root.groupelementyear_set.get().child_branch
        self.assertEqual(
            new_child_branch.groupelementyear_set.get().child_branch.
            education_group, n_child_branch.child_branch.education_group)
    def test_referenced_child_with_max_limit(self):
        child = EducationGroupYearFactory()

        GroupElementYearFactory(parent=self.parent, child_branch=child)

        AuthorizedRelationshipFactory(
            parent_type=self.parent.education_group_type,
            child_type=child.education_group_type,
            max_count_authorized=1,
        )

        ref_group = GroupElementYearFactory(parent=self.child_branch)
        AuthorizedRelationshipFactory(
            parent_type=self.parent.education_group_type,
            child_type=ref_group.child_branch.education_group_type,
        )

        ref_group.child_branch.education_group_type = child.education_group_type
        ref_group.child_branch.save()

        form = GroupElementYearForm(
            data={'link_type': LinkTypes.REFERENCE.name},
            parent=self.parent,
            child_branch=self.child_branch)

        self.assertFalse(form.is_valid())

        self.assertEqual(form.errors['link_type'], [
            _("The number of children of type(s) \"%(child_types)s\" for \"%(parent)s\" "
              "has already reached the limit.") % {
                  'child_types': child.education_group_type,
                  'parent': self.parent
              }
        ])
    def test_if_structure_is_postponed(self):
        parent = EducationGroupYearFactory(
            education_group=self.education_group,
            academic_year=self.academic_years[-2],
        )
        mandatory_child = GroupFactory(academic_year=self.academic_years[-2], )
        not_mandatory_child = GroupFactory(
            academic_year=self.academic_years[-2], )
        GroupElementYearFactory(parent=parent, child_branch=mandatory_child)
        GroupElementYearFactory(parent=parent,
                                child_branch=not_mandatory_child)
        AuthorizedRelationshipFactory(
            parent_type=parent.education_group_type,
            child_type=mandatory_child.education_group_type,
            min_count_authorized=1)
        AuthorizedRelationshipFactory(
            parent_type=parent.education_group_type,
            child_type=not_mandatory_child.education_group_type,
            min_count_authorized=0)

        self.assertEqual(EducationGroupYear.objects.count(), 3)

        result, errors = EducationGroupAutomaticPostponementToN6().postpone()

        self.assertEqual(len(result), 1)
        self.assertFalse(errors)

        self.assertEqual(result[0].education_group, self.education_group)
        self.assertEqual(result[0].groupelementyear_set.count(), 1)
예제 #7
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory(current=True)
        cls.education_group_year = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        # Create contents of education group years [3 elements]
        cls.group_element_year_1 = GroupElementYearFactory(
            parent=cls.education_group_year,
            child_branch__academic_year=cls.academic_year)
        cls.group_element_year_2 = GroupElementYearFactory(
            parent=cls.education_group_year,
            child_branch__academic_year=cls.academic_year)
        cls.group_element_year_3 = GroupElementYearFactory(
            parent=cls.education_group_year,
            child_branch__academic_year=cls.academic_year)

        cls.person = CentralManagerFactory()
        cls.person.user.user_permissions.add(
            Permission.objects.get(codename="can_access_education_group"))
        cls.url = reverse("education_groups_management")
        cls.post_valid_data = {
            "root_id": cls.education_group_year.id,
            "element_id": cls.education_group_year.id,
            "group_element_year_id": cls.group_element_year_3.id,
            'action': 'up',
        }
예제 #8
0
    def test_get_option_list_case_ignore_finality_list_choice(self):
        """
        This test ensure that the tree will be pruned when a child if type of finality list choice and option
        isn't considered as part of tree
        """
        option_1 = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group_type__name=MiniTrainingType.OPTION.name)
        GroupElementYearFactory(parent=self.root, child_branch=option_1)

        for finality_type in [
                GroupType.FINALITY_120_LIST_CHOICE.name,
                GroupType.FINALITY_180_LIST_CHOICE.name
        ]:
            finality_group = EducationGroupYearFactory(
                academic_year=self.academic_year,
                education_group_type__name=finality_type)
            GroupElementYearFactory(parent=self.root,
                                    child_branch=finality_group)
            GroupElementYearFactory(
                parent=finality_group,
                child_branch=EducationGroupYearFactory(
                    academic_year=self.academic_year,
                    education_group_type__name=MiniTrainingType.OPTION.name))

        node = EducationGroupHierarchy(self.root)
        self.assertListEqual(node.get_option_list(), [option_1])
예제 #9
0
    def setUp(self):
        self.current_academic_year = AcademicYearFactory(year=2017)
        self.learning_container_luy1 = LearningContainerYearFactory(
            academic_year=self.current_academic_year)
        self.learning_unit_yr_1 = LearningUnitYearFactory(
            academic_year=self.current_academic_year,
            learning_container_year=self.learning_container_luy1,
            credits=50)
        self.learning_unit_yr_2 = LearningUnitYearFactory()

        self.proposal_creation_1 = ProposalLearningUnitFactory(
            state=proposal_state.ProposalState.ACCEPTED.name,
            type=proposal_type.ProposalType.CREATION.name,
        )
        self.proposal_creation_2 = ProposalLearningUnitFactory(
            state=proposal_state.ProposalState.ACCEPTED.name,
            type=proposal_type.ProposalType.CREATION.name,
        )
        direct_parent_type = EducationGroupTypeFactory(
            name='Bachelor', category=education_group_categories.TRAINING)

        self.an_education_group_parent = EducationGroupYearFactory(
            academic_year=self.current_academic_year,
            education_group_type=direct_parent_type,
            acronym=ROOT_ACRONYM)
        self.group_element_child = GroupElementYearFactory(
            parent=self.an_education_group_parent,
            child_branch=None,
            child_leaf=self.learning_unit_yr_1)
        self.an_education_group = EducationGroupYearFactory(
            academic_year=self.current_academic_year,
            acronym=PARENT_ACRONYM,
            title=PARENT_TITLE,
            partial_acronym=PARENT_PARTIAL_ACRONYM)

        self.group_element_child2 = GroupElementYearFactory(
            parent=self.an_education_group,
            child_branch=self.group_element_child.parent,
        )
        generatorContainer = GenerateContainer(datetime.date.today().year - 2,
                                               datetime.date.today().year)
        self.learning_unit_year_with_entities = generatorContainer.generated_container_years[
            0].learning_unit_year_full
        entities = [
            EntityVersionFactory(
                start_date=datetime.datetime(1900, 1, 1),
                end_date=None,
                entity_type=entity_type.FACULTY,
                entity__organization__type=organization_type.MAIN)
            for _ in range(4)
        ]
        self.learning_unit_year_with_entities.entities = {
            'REQUIREMENT_ENTITY': entities[0],
            'ALLOCATION_ENTITY': entities[1]
        }
        self.proposal_creation_3 = ProposalLearningUnitFactory(
            learning_unit_year=self.learning_unit_year_with_entities,
            state=proposal_state.ProposalState.ACCEPTED.name,
            type=proposal_type.ProposalType.CREATION.name,
        )
예제 #10
0
    def test_context_data_when_education_group_year_root_is_not_a_training(
            self):
        education_group_year_group = GroupFactory(
            academic_year=self.academic_year)
        GroupElementYearFactory(parent=self.education_group_year_parents[0],
                                child_branch=education_group_year_group)
        GroupElementYearFactory(parent=education_group_year_group,
                                child_leaf=self.learning_unit_year_child,
                                child_branch=None)

        url = reverse("learning_unit_prerequisite",
                      args=[
                          education_group_year_group.id,
                          self.learning_unit_year_child.id
                      ])

        response = self.client.get(url)
        self.assertCountEqual(response.context_data["formations"],
                              self.education_group_year_parents)

        actual_prerequisites = next(
            filter(
                lambda egy: egy.id == self.education_group_year_parents[0].id,
                response.context_data["formations"])).prerequisites
        self.assertEqual(actual_prerequisites, [self.prerequisite])

        actual_prerequisites = next(
            filter(
                lambda egy: egy.id == self.education_group_year_parents[1].id,
                response.context_data["formations"])).prerequisites
        self.assertEqual(actual_prerequisites, [])
예제 #11
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory()
        cls.person = PersonFactory()
        cls.education_group_year_1 = EducationGroupYearFactory(title_english="", academic_year=cls.academic_year)
        cls.education_group_year_2 = EducationGroupYearFactory(title_english="", academic_year=cls.academic_year)
        cls.education_group_year_3 = EducationGroupYearFactory(title_english="", academic_year=cls.academic_year)
        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_unit_year=cls.learning_unit_year_1, hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=10)
        cls.learning_component_year_2 = LearningComponentYearFactory(
            learning_unit_year=cls.learning_unit_year_1, hourly_volume_partial_q1=10,
            hourly_volume_partial_q2=10)
        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,
            ]
        )
예제 #12
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory(current=True)
        cls.learning_container_year = LearningContainerYearFactory(
            container_type=LearningContainerYearType.COURSE.name,
            academic_year=cls.academic_year)
        cls.person = PersonWithPermissionsFactory('can_access_learningunit')
        cls.learning_unit_year = LearningUnitYearFullFactory(
            learning_container_year=cls.learning_container_year,
            academic_year=cls.academic_year)

        cls.education_group_year = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        cls.group_element_year = GroupElementYearFactory(
            parent=cls.education_group_year,
            child_branch=None,
            child_leaf=cls.learning_unit_year)

        cls.education_group_year_formation_parent = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        GroupElementYearFactory(
            parent=cls.education_group_year_formation_parent,
            child_branch=cls.education_group_year)

        cls.education_group_year_formation_great_parent_1 = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        GroupElementYearFactory(
            parent=cls.education_group_year_formation_great_parent_1,
            child_branch=cls.education_group_year_formation_parent)
        cls.education_group_year_formation_great_parent_2 = EducationGroupYearFactory(
            academic_year=cls.academic_year)
        GroupElementYearFactory(
            parent=cls.education_group_year_formation_great_parent_2,
            child_branch=cls.education_group_year_formation_parent)
예제 #13
0
    def setUpTestData(cls):
        cls.academic_year_2017 = AcademicYearFactory(year=2017)
        cls.academic_year_2018 = AcademicYearFactory(year=2018)
        cls.academic_year_2019 = AcademicYearFactory(year=2019)
        cls.academic_year_2020 = AcademicYearFactory(year=2020)
        cls.academic_year_2021 = AcademicYearFactory(year=2021)
        cls.master_120 = TrainingFactory(
            education_group_type__name=TrainingType.PGRM_MASTER_120.name,
            academic_year=cls.academic_year_2018,
            education_group__end_year=cls.academic_year_2020
        )

        cls.finality_group = GroupFactory(
            education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name,
            academic_year=cls.academic_year_2018,
            education_group__end_year=cls.academic_year_2020
        )
        GroupElementYearFactory(parent=cls.master_120, child_branch=cls.finality_group)

        cls.master_120_specialized = TrainingFactory(
            education_group_type__name=TrainingType.MASTER_MS_120.name,
            academic_year=cls.academic_year_2018,
            education_group__end_year=cls.academic_year_2020
        )
        GroupElementYearFactory(parent=cls.finality_group, child_branch=cls.master_120_specialized)
예제 #14
0
 def setUpTestData(cls):
     """
     |--Common Core
            |-- Learning unit year
            |-- Sub group
     """
     cls.academic_year = AcademicYearFactory(year=2018)
     cls.common_core = GroupFactory(
         education_group_type__name=GroupType.COMMON_CORE.name,
         academic_year=cls.academic_year)
     cls.learning_unit_year = LearningUnitYearFactory(
         academic_year=cls.academic_year,
         learning_container_year__academic_year=cls.academic_year)
     GroupElementYearFactory(parent=cls.common_core,
                             child_branch=None,
                             child_leaf=cls.learning_unit_year)
     cls.sub_group = GroupFactory(
         education_group_type__name=GroupType.SUB_GROUP.name,
         academic_year=cls.academic_year)
     GroupElementYearFactory(parent=cls.common_core,
                             child_branch=cls.sub_group,
                             child_leaf=None)
     cls.person = PersonFactory()
     url_kwargs = {
         'partial_acronym': cls.common_core.partial_acronym,
         'year': cls.common_core.academic_year.year
     }
     cls.url = reverse('education_group_api_v1:' + GroupTreeView.name,
                       kwargs=url_kwargs)
예제 #15
0
    def setUpTestData(cls):
        academic_year = AcademicYearFactory()
        minor_list_type = EducationGroupTypeFactory(
            category=education_group_categories.GROUP,
            name=education_group_types.GroupType.MINOR_LIST_CHOICE.name,
        )
        common_type = EducationGroupTypeFactory(
            category=education_group_categories.GROUP,
            name=education_group_types.GroupType.COMMON_CORE,
        )

        cls.base_1 = GroupFactory(education_group_type=common_type,
                                  acronym="BASE",
                                  academic_year=academic_year)
        child_1 = GroupFactory(education_group_type=common_type,
                               acronym="CHILD",
                               academic_year=academic_year)
        minor_list_choice = GroupFactory(education_group_type=minor_list_type,
                                         acronym="MINOR LIST",
                                         academic_year=academic_year)

        minor_content_1 = MiniTrainingFactory(
            education_group_type=minor_list_type, academic_year=academic_year)
        minor_content_2 = MiniTrainingFactory(
            education_group_type=minor_list_type, academic_year=academic_year)

        cls.groupe_element_yr_1 = GroupElementYearFactory(
            parent=cls.base_1, child_branch=minor_list_choice)
        cls.groupe_element_yr_2 = GroupElementYearFactory(parent=cls.base_1,
                                                          child_branch=child_1)
        cls.groupe_element_yr_3 = GroupElementYearFactory(
            parent=minor_list_choice, child_branch=minor_content_1)
        cls.groupe_element_yr_4 = GroupElementYearFactory(
            parent=minor_list_choice, child_branch=minor_content_2)
예제 #16
0
    def test_delete_get_with_protected_objects(self):
        # Create protected data
        OfferEnrollmentFactory(education_group_year=self.education_group_year1)
        GroupElementYearFactory(parent=self.education_group_year1,
                                child_branch__academic_year=self.current_ac)
        GroupElementYearFactory(parent=self.education_group_year1,
                                child_branch__academic_year=self.current_ac)

        count_enrollment = 1
        msg_offer_enrollment = ngettext_lazy(
            "%(count_enrollment)d student is enrolled in the offer.",
            "%(count_enrollment)d students are enrolled in the offer.",
            count_enrollment) % {
                "count_enrollment": count_enrollment
            }
        msg_pgrm_content = _(
            "The content of the education group is not empty.")

        protected_messages = [{
            'education_group_year':
            self.education_group_year1,
            'messages': [msg_offer_enrollment, msg_pgrm_content]
        }]
        response = self.client.get(self.url)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.context["protected_messages"],
                         protected_messages)
        self.assertTemplateUsed(response,
                                "education_group/protect_delete.html")
예제 #17
0
    def setUpTestData(cls):
        today = datetime.date.today()
        academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        cls.education_group_parent = EducationGroupYearFactory(
            acronym="Parent", academic_year=academic_year)
        cls.education_group_child_1 = EducationGroupYearFactory(
            acronym="Child_1", academic_year=academic_year)
        cls.education_group_child_2 = EducationGroupYearFactory(
            acronym="Child_2", academic_year=academic_year)

        GroupElementYearFactory(parent=cls.education_group_parent,
                                child_branch=cls.education_group_child_1)
        GroupElementYearFactory(parent=cls.education_group_parent,
                                child_branch=cls.education_group_child_2)

        cls.education_group_language_parent = \
            EducationGroupLanguageFactory(education_group_year=cls.education_group_parent)
        cls.education_group_language_child_1 = \
            EducationGroupLanguageFactory(education_group_year=cls.education_group_child_1)

        cls.user = UserFactory()
        cls.user.user_permissions.add(
            Permission.objects.get(codename="can_access_education_group"))
        cls.url = reverse("education_group_read",
                          args=[cls.education_group_child_1.id])
예제 #18
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)
        ]
예제 #19
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory()
        cls.master_120 = TrainingFactory(
            education_group_type__name=TrainingType.PGRM_MASTER_120.name,
            academic_year=cls.academic_year)

        cls.option_in_parent = MiniTrainingFactory(
            acronym="OPT1",
            education_group_type__name=MiniTrainingType.OPTION.name,
            academic_year=cls.academic_year)
        cls.master_120_link_option = GroupElementYearFactory(
            parent=cls.master_120, child_branch=cls.option_in_parent)

        # Create finality structure
        cls.finality_group = GroupFactory(
            education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name,
            academic_year=cls.academic_year)
        GroupElementYearFactory(parent=cls.master_120,
                                child_branch=cls.finality_group)

        cls.master_120_specialized = GroupFactory(
            education_group_type__name=TrainingType.MASTER_MS_120.name,
            academic_year=cls.academic_year)
        GroupElementYearFactory(parent=cls.finality_group,
                                child_branch=cls.master_120_specialized)
예제 #20
0
    def setUpTestData(cls):
        """
            BIR1BA
            |--Common Core
               |-- Learning Unit Year
        """
        cls.academic_year = AcademicYearFactory(year=2018)
        cls.training = TrainingFactory(acronym='BIR1BA',
                                       partial_acronym='LBIR1000I',
                                       academic_year=cls.academic_year)
        cls.common_core = GroupFactory(
            education_group_type__name=GroupType.COMMON_CORE.name,
            academic_year=cls.academic_year)
        GroupElementYearFactory(parent=cls.training,
                                child_branch=cls.common_core,
                                child_leaf=None)

        cls.learning_unit_year = LearningUnitYearFactory(
            academic_year=cls.academic_year,
            learning_container_year__academic_year=cls.academic_year)
        GroupElementYearFactory(parent=cls.common_core,
                                child_branch=None,
                                child_leaf=cls.learning_unit_year)
        cls.person = PersonFactory()
        url_kwargs = {
            'acronym': cls.learning_unit_year.acronym,
            'year': cls.learning_unit_year.academic_year.year
        }
        cls.url = reverse('learning_unit_api_v1:' +
                          EducationGroupRootsList.name,
                          kwargs=url_kwargs)
예제 #21
0
    def test_init_already_postponed_content(self):
        gr = GroupElementYearFactory(parent=self.next_education_group_year,
                                     child_branch__academic_year=self.
                                     next_education_group_year.academic_year)

        with self.assertRaises(NotPostponeError) as cm:
            self.postponer = PostponeContent(self.current_education_group_year)
        self.assertEqual(str(cm.exception),
                         _("The content has already been postponed."))

        AuthorizedRelationshipFactory(
            parent_type=self.next_education_group_year.education_group_type,
            child_type=gr.child_branch.education_group_type,
            min_count_authorized=1)

        self.postponer = PostponeContent(self.current_education_group_year)

        GroupElementYearFactory(
            parent=gr.child_branch,
            child_branch__academic_year=gr.child_branch.academic_year)

        with self.assertRaises(NotPostponeError) as cm:
            self.postponer = PostponeContent(self.current_education_group_year)
        self.assertEqual(str(cm.exception),
                         _("The content has already been postponed."))
예제 #22
0
    def test_should_copy_data_from_previous_year(self):
        previous_academic_year = AcademicYearFactory(
            year=self.egy.academic_year.year - 1)
        previous_egy = EducationGroupYearFactory(
            education_group_type=self.master_type,
            acronym="TEST2M",
            partial_acronym="LTEST100B",
            academic_year=previous_academic_year,
            education_group=self.egy.education_group,
        )
        previous_child = EducationGroupYearFactory(
            education_group_type=self.finality_type,
            partial_acronym="LTEST503G",
            academic_year=previous_academic_year,
        )
        previous_grp_ele = GroupElementYearFactory(parent=previous_egy,
                                                   child_branch=previous_child)

        current_child = EducationGroupYearFactory(
            education_group_type=self.finality_type,
            partial_acronym="LTEST504G",
            academic_year=self.current_academic_year,
        )
        current_grp_ele = GroupElementYearFactory(parent=self.egy,
                                                  child_branch=current_child)
        children_egys = create_initial_group_element_year_structure(
            [previous_egy, self.egy, self.egy_next_year])

        self.assertEqual(
            current_child.partial_acronym, children_egys[self.egy_next_year.id]
            [0].child_branch.partial_acronym)
예제 #23
0
    def test_postpone_with_same_child_branch_existing_in_N1_without_relationship(
            self):
        """
        When the postponed child has a min_count_authorized relation to 1,
        we have to check if the link to the existing egy is correctly created.
        """
        n1_gr = GroupElementYearFactory(
            parent=self.next_education_group_year,
            child_branch__education_group=self.current_group_element_year.
            child_branch.education_group,
            child_branch__academic_year=self.next_academic_year,
        )
        AuthorizedRelationshipFactory(
            parent_type=self.next_education_group_year.education_group_type,
            child_type=n1_gr.child_branch.education_group_type,
            min_count_authorized=1)

        n_1_gr = GroupElementYearFactory(
            parent=self.current_group_element_year.child_branch,
            child_branch__academic_year=self.current_academic_year)

        n1_1_child = EducationGroupYearFactory(
            education_group=n_1_gr.child_branch.education_group,
            academic_year=self.next_academic_year,
        )

        self.postponer = PostponeContent(self.current_education_group_year)

        new_root = self.postponer.postpone()

        self.assertEqual(
            new_root.groupelementyear_set.first().child_branch.
            groupelementyear_set.first().child_branch, n1_1_child)
예제 #24
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory()
        cls.grp_ele_leaf = GroupElementYearFactory(
            parent__education_group_type=GroupEducationGroupTypeFactory(),
            parent__academic_year=cls.academic_year,
            child_branch=None,
            child_leaf=LearningUnitYearFactory(
                academic_year=cls.academic_year))
        cls.second_grp_ele_leaf = GroupElementYearFactory(
            parent=cls.grp_ele_leaf.parent,
            child_branch=None,
            child_leaf=LearningUnitYearFactory(
                academic_year=cls.academic_year))
        cls.grp_ele_root = GroupElementYearFactory(
            child_branch=cls.grp_ele_leaf.parent,
            parent__academic_year=cls.academic_year,
        )

        cls.other_grp_ele_root = GroupElementYearFactory(
            parent__academic_year=cls.academic_year,
            child_branch__education_group_type=GroupEducationGroupTypeFactory(
            ),
            child_branch__academic_year=cls.academic_year)
        cls.other_grp_ele_intermediary = GroupElementYearFactory(
            parent=cls.other_grp_ele_root.child_branch,
            child_branch=cls.grp_ele_root.child_branch)
예제 #25
0
    def setUpTestData(cls):
        academic_year = AcademicYearFactory(current=True)
        cls.education_group_parent = EducationGroupYearFactory(
            acronym="Parent", academic_year=academic_year)
        cls.education_group_child_1 = EducationGroupYearFactory(
            acronym="Child_1", academic_year=academic_year)
        cls.education_group_child_2 = EducationGroupYearFactory(
            acronym="Child_2", academic_year=academic_year)

        GroupElementYearFactory(parent=cls.education_group_parent,
                                child_branch=cls.education_group_child_1)
        GroupElementYearFactory(parent=cls.education_group_parent,
                                child_branch=cls.education_group_child_2)

        cls.education_group_language_parent = \
            EducationGroupLanguageFactory(education_group_year=cls.education_group_parent)
        cls.education_group_language_child_1 = \
            EducationGroupLanguageFactory(education_group_year=cls.education_group_child_1)

        cls.user = PersonWithPermissionsFactory(
            "can_access_education_group").user
        cls.url = reverse("education_group_read",
                          args=[
                              cls.education_group_parent.id,
                              cls.education_group_child_1.id
                          ])
예제 #26
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])
예제 #27
0
    def test_ordered_by_acronym(self):
        group_1 = GroupElementYearFactory(
            parent=EducationGroupYearFactory(acronym='XDRT1234'),
            child_branch=None,
            child_leaf=self.learning_unit_year)
        group_2 = GroupElementYearFactory(
            parent=EducationGroupYearFactory(acronym='BMED1000'),
            child_branch=None,
            child_leaf=self.learning_unit_year)
        group_3 = GroupElementYearFactory(
            parent=EducationGroupYearFactory(acronym='LDROI1001'),
            child_branch=None,
            child_leaf=self.learning_unit_year)
        LearningUnitEnrollmentFactory(
            learning_unit_year=self.learning_unit_year,
            offer_enrollment__education_group_year=group_1.parent)
        LearningUnitEnrollmentFactory(
            learning_unit_year=self.learning_unit_year,
            offer_enrollment__education_group_year=group_2.parent)
        LearningUnitEnrollmentFactory(
            learning_unit_year=self.learning_unit_year,
            offer_enrollment__education_group_year=group_3.parent)

        result = find_with_enrollments_count(self.learning_unit_year)
        expected_list_order = [group_2.parent, group_3.parent, group_1.parent]
        self.assertEqual(list(result), expected_list_order)
예제 #28
0
 def setUpTestData(cls):
     cls.person = PersonFactory()
     cls.education_group_year_1 = EducationGroupYearFactory()
     cls.education_group_year_2 = EducationGroupYearFactory()
     cls.education_group_year_3 = EducationGroupYearFactory()
     cls.learning_unit_year_1 = LearningUnitYearFactory()
     cls.learning_unit_year_2 = LearningUnitYearFactory()
     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.a_superuser = SuperUserFactory()
예제 #29
0
def generate_learning_unit_year_with_associated_education_group(
        academic_year, same_faculty=True, same_entity=True):
    luy = LearningUnitYearFactory(
        academic_year=academic_year,
        learning_container_year__academic_year=academic_year)

    entity_container_year = EntityContainerYearFactory(
        learning_container_year=luy.learning_container_year,
        type=entity_container_year_link_type.REQUIREMENT_ENTITY)

    entity_version = EntityVersionFactory(entity=entity_container_year.entity,
                                          entity_type=entity_type.SCHOOL)
    parent_entity = EntityVersionFactory(entity=entity_version.parent,
                                         parent=None,
                                         entity_type=entity_type.FACULTY)

    if not same_entity:
        entity_version = parent_entity
    if not same_faculty:
        entity_version = EntityVersionFactory(entity_type=entity_type.FACULTY)

    offer_year_entity = OfferYearEntityFactory(
        entity=entity_version.entity,
        education_group_year__academic_year=academic_year)

    GroupElementYearFactory(
        child_branch=offer_year_entity.education_group_year, parent=None)
    GroupElementYearFactory(child_branch=None,
                            child_leaf=luy,
                            parent=offer_year_entity.education_group_year)

    return luy
예제 #30
0
    def test_have_contents_case_have_contents_because_mandatory_structure_is_present_multiple_times(
            self):
        """
        In this test, we ensure that we have two elements of one type which are mandatory in the basic structure.
        ==> We must consider as it have contents
        """
        education_group_year = TrainingFactory(
            academic_year=self.academic_year)
        subgroup_1 = GroupFactory(
            academic_year=self.academic_year,
            education_group_type__name=GroupType.SUB_GROUP.name)
        GroupElementYearFactory(parent=education_group_year,
                                child_branch=subgroup_1)

        subgroup_2 = GroupFactory(
            academic_year=self.academic_year,
            education_group_type=subgroup_1.education_group_type,
        )
        GroupElementYearFactory(parent=education_group_year,
                                child_branch=subgroup_2)

        AuthorizedRelationshipFactory(
            parent_type=education_group_year.education_group_type,
            child_type=subgroup_1.education_group_type,
            min_count_authorized=1,
        )
        self.assertTrue(
            delete._have_contents_which_are_not_mandatory(
                education_group_year))