Пример #1
0
    def setUpTestData(cls):
        cls.current_academic_year = create_current_academic_year()
        cls.next_academic_year = AcademicYearFactory(year=cls.current_academic_year.year + 1)

        cls.person = CentralManagerFactory()
        cls.person.user.user_permissions.add(Permission.objects.get(codename="change_educationgroup"))
        cls.person.user.user_permissions.add(Permission.objects.get(codename="can_access_education_group"))

        cls.education_group = EducationGroupFactory(end_year=cls.next_academic_year)
        cls.education_group_year = TrainingFactory(academic_year=cls.current_academic_year,
                                                   education_group=cls.education_group)

        cls.next_education_group_year = TrainingFactory(
            academic_year=cls.next_academic_year,
            education_group=cls.education_group,
            management_entity=cls.education_group_year.management_entity
        )

        PersonEntityFactory(person=cls.person, entity=cls.education_group_year.management_entity)

        cls.group_element_year = GroupElementYearFactory(
            parent=cls.education_group_year,
            child_branch__academic_year=cls.education_group_year.academic_year
        )
        cls.url = reverse(
            "postpone_education_group",
            kwargs={
                "root_id": cls.next_education_group_year.pk,
                "education_group_year_id": cls.next_education_group_year.pk,
            }
        )

        cls.redirect_url = reverse("education_group_read",
                                   args=[cls.next_education_group_year.pk, cls.next_education_group_year.pk])
Пример #2
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)
Пример #3
0
    def setUp(self):
        self.current_academic_year = create_current_academic_year()
        self.next_academic_year = AcademicYearFactory(year=self.current_academic_year.year + 1)

        self.person = CentralManagerFactory()
        self.person.user.user_permissions.add(Permission.objects.get(codename="change_educationgroup"))
        self.person.user.user_permissions.add(Permission.objects.get(codename="can_access_education_group"))

        self.client.force_login(self.person.user)

        self.education_group = EducationGroupFactory(end_year=self.next_academic_year.year)
        self.education_group_year = TrainingFactory(academic_year=self.current_academic_year,
                                                    education_group=self.education_group)

        self.next_education_group_year = TrainingFactory(
            academic_year=self.next_academic_year,
            education_group=self.education_group,
            management_entity=self.education_group_year.management_entity
        )

        PersonEntityFactory(person=self.person, entity=self.education_group_year.management_entity)

        self.group_element_year = GroupElementYearFactory(parent=self.education_group_year)
        self.url = reverse(
            "postpone_education_group",
            kwargs={
                "root_id": self.next_education_group_year.pk,
                "education_group_year_id": self.next_education_group_year.pk,
            }
        )

        self.redirect_url = reverse("education_group_read",
                                    args=[self.next_education_group_year.pk, self.next_education_group_year.pk])
Пример #4
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)
Пример #5
0
 def setUp(self):
     self.data = {
         'title': 'Métamorphose',
         'title_english': 'Transfiguration',
         'education_group_type': self.education_group_type.pk,
         'credits': 42,
         'acronym': 'CRSCHOIXDVLD',
         'partial_acronym': 'LDVLD101R',
         'management_entity': self.management_entity_version.pk,
         'administration_entity': MainEntityVersionFactory().pk,
         'main_teaching_campus': "",
         'academic_year': create_current_academic_year().pk,
         'active': ACTIVE,
         'schedule_type': DAILY,
         "internship": internship_presence.NO,
         "primary_language": LanguageFactory().pk,
         "start_year": 2010,
         "constraint_type": "",
         "diploma_printing_title": 'Diploma title'
     }
     self.administration_entity_version = MainEntityVersionFactory()
     self.education_group_year = TrainingFactory(
         academic_year=create_current_academic_year(),
         education_group_type__name=education_group_types.TrainingType.
         BACHELOR,
         management_entity=self.management_entity_version.entity,
         administration_entity=self.administration_entity_version.entity,
     )
     PersonEntityFactory(person=self.person,
                         entity=self.education_group_year.management_entity)
Пример #6
0
    def test_bulk_publish(self, mock_publish):
        training_1 = TrainingFactory()
        training_2 = TrainingFactory()

        result = _bulk_publish([training_1, training_2])
        self.assertIsInstance(result, list)
        self.assertListEqual(result, [True, True])
Пример #7
0
    def setUp(self):

        self.education_group_year = TrainingFactory(
            academic_year=create_current_academic_year())
        self.education_group_type = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)

        EntityVersionFactory(
            entity=self.education_group_year.administration_entity)
        EntityVersionFactory(
            entity=self.education_group_year.management_entity)
        self.list_acs = GenerateAcademicYear(get_current_year(),
                                             get_current_year() +
                                             40).academic_years

        self.data = {
            'title': 'Métamorphose',
            'title_english': 'Transfiguration',
            'education_group_type': self.education_group_type.pk,
            'credits': 42,
            'acronym': 'CRSCHOIXDVLD',
            'partial_acronym': 'LDVLD101R',
            'management_entity': MainEntityVersionFactory().pk,
            'administration_entity': MainEntityVersionFactory().pk,
            'main_teaching_campus': "",
            'academic_year': create_current_academic_year().pk,
            'active': ACTIVE,
            'schedule_type': DAILY,
            "internship": internship_presence.NO,
            "primary_language": LanguageFactory().pk,
            "start_year": 2010,
            "constraint_type": "",
        }
Пример #8
0
    def test_delete_case_remove_mandatory_structure_case_reused_item_which_are_mandatory(
            self):
        """
        In this test, we ensure that the mandatory elem is not removed if it is reused in another structure
        """
        education_group_year = TrainingFactory(
            academic_year=self.academic_year)

        child_mandatory = GroupFactory(
            academic_year=self.academic_year,
            education_group_type__name=GroupType.COMMON_CORE.name)
        AuthorizedRelationshipFactory(
            parent_type=education_group_year.education_group_type,
            child_type=child_mandatory.education_group_type,
            min_count_authorized=1,
        )
        link_parent_child = GroupElementYearFactory(
            parent=education_group_year, child_branch=child_mandatory)

        # Create another training
        another_training = TrainingFactory(academic_year=self.academic_year)
        GroupElementYearFactory(parent=another_training,
                                child_branch=child_mandatory)

        delete.start(education_group_year)
        with self.assertRaises(EducationGroupYear.DoesNotExist):
            EducationGroupYear.objects.get(pk=education_group_year.pk)
        with self.assertRaises(GroupElementYear.DoesNotExist):
            GroupElementYear.objects.get(pk=link_parent_child.pk)

        self.assertEqual(child_mandatory,
                         EducationGroupYear.objects.get(pk=child_mandatory.pk))
Пример #9
0
    def test_is_current_academic_year_in_range_of_editable_education_group_year_case_in_range(self):
        """This test ensure that we modify OF which lower than N+1"""
        training_n1 = TrainingFactory(academic_year__year=self.current_academic_year.year + 1)
        training = TrainingFactory(academic_year=self.current_academic_year)

        for education_group_year in [training_n1, training]:
            perm = CommonEducationGroupStrategyPerms(self.person.user, education_group_year)
            self.assertTrue(perm._is_current_academic_year_in_range_of_editable_education_group_year())
Пример #10
0
    def setUpTestData(cls):
        cls.user = UserFactory()
        cls.url = reverse('education_group_api_v1:training-list')

        cls.academic_year = AcademicYearFactory(year=2018)
        TrainingFactory(acronym='BIR1BA', partial_acronym='LBIR1000I', academic_year=cls.academic_year)
        TrainingFactory(acronym='AGRO1BA', partial_acronym='LAGRO2111C', academic_year=cls.academic_year)
        TrainingFactory(acronym='MED12M', partial_acronym='LMED12MA', academic_year=cls.academic_year)
Пример #11
0
    def setUp(self):
        self.current_academic_year = create_current_academic_year()

        self.education_group_year = GroupFactory()

        EntityVersionFactory(
            entity=self.education_group_year.management_entity,
            start_date=self.education_group_year.academic_year.start_date)

        EntityVersionFactory(
            entity=self.education_group_year.administration_entity,
            start_date=self.education_group_year.academic_year.start_date)

        AuthorizedRelationshipFactory(
            parent_type=self.education_group_year.education_group_type,
            child_type=self.education_group_year.education_group_type)

        self.url = reverse(
            update_education_group,
            args=[self.education_group_year.pk, self.education_group_year.pk])
        self.person = PersonFactory()

        self.client.force_login(self.person.user)
        permission = Permission.objects.get(codename='change_educationgroup')
        self.person.user.user_permissions.add(permission)
        self.perm_patcher = mock.patch(
            "base.business.education_groups.perms.is_eligible_to_change_education_group",
            return_value=True)
        self.mocked_perm = self.perm_patcher.start()

        self.an_training_education_group_type = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)

        self.training_education_group_year = TrainingFactory(
            academic_year=self.current_academic_year,
            education_group_type=self.an_training_education_group_type)

        AuthorizedRelationshipFactory(
            parent_type=self.an_training_education_group_type,
            child_type=self.an_training_education_group_type,
        )

        EntityVersionFactory(
            entity=self.training_education_group_year.management_entity,
            start_date=self.education_group_year.academic_year.start_date)

        EntityVersionFactory(
            entity=self.training_education_group_year.administration_entity,
            start_date=self.education_group_year.academic_year.start_date)

        self.training_url = reverse(update_education_group,
                                    args=[
                                        self.training_education_group_year.pk,
                                        self.training_education_group_year.pk
                                    ])

        self.domains = [DomainFactory() for x in range(10)]
Пример #12
0
    def setUpTestData(cls):
        """
            DROI2M
            |--Common Core
               |-- Learning unit year
            |--Finality list choice
               |-- DROI2MS/IU
                  |--Common core
        """
        cls.academic_year = AcademicYearFactory(year=2018)
        cls.training = TrainingFactory(
            acronym='DROI2M',
            partial_acronym='LBROI200M',
            academic_year=cls.academic_year,
            education_group_type__name=TrainingType.PGRM_MASTER_120.name)
        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.finality_list_choice = GroupFactory(
            education_group_type__name=GroupType.FINALITY_120_LIST_CHOICE.name,
            academic_year=cls.academic_year)
        GroupElementYearFactory(parent=cls.training,
                                child_branch=cls.finality_list_choice,
                                child_leaf=None)
        cls.training_ms = TrainingFactory(
            acronym='DROI2MS/IU',
            partial_acronym='LIURE200S',
            academic_year=cls.academic_year,
            education_group_type__name=TrainingType.MASTER_MS_120)
        GroupElementYearFactory(parent=cls.finality_list_choice,
                                child_branch=cls.training_ms,
                                child_leaf=None)
        cls.common_core_ms = GroupFactory(
            education_group_type__name=GroupType.COMMON_CORE.name,
            academic_year=cls.academic_year)
        GroupElementYearFactory(parent=cls.training_ms,
                                child_branch=cls.common_core_ms,
                                child_leaf=None)
        cls.person = PersonFactory()
        url_kwargs = {
            'acronym': cls.training.acronym,
            'year': cls.training.academic_year.year
        }
        cls.url = reverse('education_group_api_v1:' + TrainingTreeView.name,
                          kwargs=url_kwargs)
Пример #13
0
    def test_is_lower_than_limit_edg_year_case_greater(self):
        """This test ensure that we modify OF which greater or equal than limit year"""
        training_limit_year = TrainingFactory(
            academic_year__year=settings.YEAR_LIMIT_EDG_MODIFICATION + 1)
        training_greater = TrainingFactory(
            academic_year__year=settings.YEAR_LIMIT_EDG_MODIFICATION)

        for education_group_year in [training_limit_year, training_greater]:
            with self.subTest(msg=education_group_year):
                perm = CommonEducationGroupStrategyPerms(
                    self.person.user, education_group_year)
                self.assertFalse(perm._is_lower_than_limit_edg_year())
Пример #14
0
 def test_raise_validation_acronym_invalid(self):
     random_acronym = string_generator()
     external_ids = [
         'osis.education_group_type_2M180', 'osis.education_group_type_2M1',
         'osis.education_group_type_3DP'
     ]
     for ext_id in external_ids:
         with self.subTest(type=ext_id):
             e = TrainingFactory(acronym=random_acronym,
                                 academic_year=self.current_acy,
                                 education_group_type__external_id=ext_id)
             with self.assertRaises(ValidationError):
                 e.clean_acronym()
Пример #15
0
    def setUp(self):
        self.current_academic_year = create_current_academic_year()
        self.next_academic_year = AcademicYearFactory(year=self.current_academic_year.year + 1)

        self.education_group = EducationGroupFactory(end_year=self.next_academic_year.year)

        self.current_education_group_year = TrainingFactory(education_group=self.education_group,
                                                            academic_year=self.current_academic_year)

        self.current_group_element_year = GroupElementYearFactory(parent=self.current_education_group_year)

        self.next_education_group_year = TrainingFactory(education_group=self.education_group,
                                                         academic_year=self.next_academic_year)
Пример #16
0
    def setUp(self):
        current_ac = create_current_academic_year()
        self.education_group_year = TrainingFactory(academic_year=current_ac)
        self.person = FacultyManagerFactory("delete_educationgroup",
                                            "change_educationgroup",
                                            "add_educationgroup")
        PersonEntityFactory(person=self.person,
                            entity=self.education_group_year.management_entity)

        # Create an academic calendar in order to check permission [Faculty can modify when period is opened]
        self.academic_calendar = AcademicCalendarFactory(
            reference=EDUCATION_GROUP_EDITION,
            start_date=timezone.now(),
            end_date=timezone.now() + timedelta(weeks=+1),
            academic_year=current_ac,
        )

        self.client.force_login(user=self.person.user)
        self.url = reverse(
            'delete_education_group',
            args=[self.education_group_year.id, self.education_group_year.id])
        self.context = {
            "person": self.person,
            "root": self.education_group_year,
            "education_group_year": self.education_group_year,
            "request": RequestFactory().get("")
        }
Пример #17
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)
Пример #18
0
    def test_do_not_duplicate_11BA(self):
        TrainingFactory(education_group_type__name=TrainingType.BACHELOR.name,
                        acronym="OSIS11BA")

        postponement = EducationGroupAutomaticPostponementToN6()

        self.assertQuerysetEqual(postponement.queryset, [])
Пример #19
0
    def test_permission_denied_when_learning_unit_not_contained_in_training(self):
        other_education_group_year = TrainingFactory(academic_year=self.academic_year)
        url = reverse("learning_unit_prerequisite_update",
                      args=[other_education_group_year.id, self.learning_unit_year_child.id])

        response = self.client.get(url)
        self.assertEqual(response.status_code, HttpResponseForbidden.status_code)
Пример #20
0
    def test_is_eligible_case_raising_exception(self, mock_is_eligible):
        person = PersonWithPermissionsFactory()
        perm = CommonEducationGroupStrategyPerms(person.user,
                                                 TrainingFactory())

        with self.assertRaises(PermissionDenied):
            perm.is_eligible(raise_exception=True)
Пример #21
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)
Пример #22
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)
        ]
Пример #23
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))
Пример #24
0
    def test_training_template_used(self):
        training = TrainingFactory()
        url = reverse("education_group_read", args=[training.pk, training.pk])
        expected_template = "education_group/identification_training_details.html"

        response = self.client.get(url)
        self.assertTemplateUsed(response, expected_template)
Пример #25
0
    def setUpTestData(cls):
        super().setUpTestData()

        cls.current_academic_year = AcademicYearFactory(current=True)
        cls.generated_ac_years = AcademicYearFactory.produce(
            base_year=cls.current_academic_year.year,
            number_past=0,
            number_future=7)
        cls.entity_version = MainEntityVersionFactory(
            entity_type=entity_type.SECTOR)
        cls.central_manager = CentralManagerFactory()
        PersonEntityFactory(person=cls.central_manager,
                            entity=cls.entity_version.entity)
        cls.training = TrainingFactory(
            management_entity=cls.entity_version.entity,
            administration_entity=cls.entity_version.entity,
            academic_year=cls.current_academic_year)
        cls.form_data = model_to_dict_fk(cls.training,
                                         exclude=('secondary_domains', ))
        cls.form_data.update({
            'primary_language':
            cls.form_data['primary_language_id'],
            'administration_entity':
            cls.entity_version.pk,
            'management_entity':
            cls.entity_version.pk
        })
Пример #26
0
    def test_ensure_is_eligible_case_permission_denied(
            self, mock_linked_to_management, mock_is_current_in_range):
        perm = CommonEducationGroupStrategyPerms(self.person.user,
                                                 TrainingFactory())

        with self.assertRaises(PermissionDenied):
            perm._is_eligible()
Пример #27
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)
Пример #28
0
 def setUpTestData(cls):
     cls.academic_year = AcademicYearFactory()
     cls.parent = TrainingFactory(
         academic_year=cls.academic_year,
         education_group_type__learning_unit_child_allowed=True)
     cls.child_leaf = LearningUnitYearFactory()
     cls.child_branch = MiniTrainingFactory(academic_year=cls.academic_year)
Пример #29
0
    def test_delete_case_no_mandatory_structure(self):
        education_group_year = TrainingFactory(
            academic_year=self.academic_year)
        delete.start(education_group_year)

        with self.assertRaises(EducationGroupYear.DoesNotExist):
            EducationGroupYear.objects.get(pk=education_group_year.pk)
Пример #30
0
    def test_have_contents_case_no_contents_which_because_mandatory_structure(
            self):
        """
        In this test, we ensure that all of his children are mandatory groups and they are empty.
        It must be consider as empty
        """
        education_group_year = TrainingFactory(
            academic_year=self.academic_year)
        for education_group_type in [
                GroupType.COMMON_CORE.name,
                GroupType.FINALITY_120_LIST_CHOICE.name
        ]:
            child = GroupFactory(
                academic_year=self.academic_year,
                education_group_type__name=education_group_type)

            AuthorizedRelationshipFactory(
                parent_type=education_group_year.education_group_type,
                child_type=child.education_group_type,
                min_count_authorized=1,
            )
            GroupElementYearFactory(parent=education_group_year,
                                    child_branch=child)
        self.assertFalse(
            delete._have_contents_which_are_not_mandatory(
                education_group_year))