Example #1
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)
Example #2
0
    def setUpTestData(cls):
        cls.parent_type = EducationGroupTypeFactory()
        cls.child_type, cls.other_child_type = EducationGroupTypeFactory.create_batch(2)

        cls.parent_egy = EducationGroupYearFactory(education_group_type=cls.parent_type)
        cls.child_egy = EducationGroupYearFactory(education_group_type=cls.child_type)
        cls.new_link = GroupElementYearFactory.build(child_branch=cls.child_egy)
Example #3
0
    def setUpTestData(cls):
        today = datetime.date.today()
        cls.academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)
        cls.previous_academic_year = AcademicYearFactory(
            start_date=today.replace(year=today.year - 1),
            end_date=today - datetime.timedelta(days=1),
            year=today.year - 1)

        cls.type_training = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)
        cls.type_minitraining = EducationGroupTypeFactory(
            category=education_group_categories.MINI_TRAINING)
        cls.type_group = EducationGroupTypeFactory(
            category=education_group_categories.GROUP)

        oph_entity = EntityFactory()
        envi_entity = EntityFactory()

        cls.education_group_edph2 = EducationGroupYearFactory(
            acronym='EDPH2',
            academic_year=cls.academic_year,
            partial_acronym='EDPH2_SCS',
            education_group_type=cls.type_group,
            management_entity=envi_entity)

        cls.education_group_arke2a = EducationGroupYearFactory(
            acronym='ARKE2A',
            academic_year=cls.academic_year,
            education_group_type=cls.type_training,
            management_entity=oph_entity)

        cls.education_group_hist2a = EducationGroupYearFactory(
            acronym='HIST2A',
            academic_year=cls.academic_year,
            education_group_type=cls.type_group,
            management_entity=oph_entity)

        cls.education_group_arke2a_previous_year = EducationGroupYearFactory(
            acronym='ARKE2A',
            academic_year=cls.previous_academic_year,
            education_group_type=cls.type_training,
            management_entity=oph_entity)

        cls.oph_entity_v = EntityVersionFactory(entity=oph_entity,
                                                parent=envi_entity,
                                                end_date=None)
        cls.envi_entity_v = EntityVersionFactory(entity=envi_entity,
                                                 end_date=None)

        cls.user = PersonFactory().user
        cls.user.user_permissions.add(
            Permission.objects.get(codename="can_access_education_group"))
        cls.form_class = EducationGroupFilter()._meta.form
        cls.url = reverse("education_groups")
Example #4
0
    def setUpTestData(cls):
        cls.category = education_group_categories.GROUP

        cls.subgroup = EducationGroupTypeFactory(name='Subgroup',
                                                 category=cls.category)
        cls.complementary_module = EducationGroupTypeFactory(
            name='Complementary module', category=cls.category)
        cls.options_list = EducationGroupTypeFactory(name='Options list',
                                                     category=cls.category)
    def setUp(self):
        self.category = education_group_categories.GROUP

        self.subgroup = EducationGroupTypeFactory(name='Subgroup',
                                                  category=self.category)
        self.complementary_module = EducationGroupTypeFactory(
            name='Complementary module', category=self.category)
        self.options_list = EducationGroupTypeFactory(name='Options list',
                                                      category=self.category)
Example #6
0
    def setUp(self):
        formation_master_type = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING,
            name=education_group_types.TrainingType.PGRM_MASTER_120,
        )
        self.root = EducationGroupYearFactory(
            acronym='DROI2M',
            education_group_type=formation_master_type,
            academic_year=self.academic_year)

        finality_list_type = EducationGroupTypeFactory(
            category=education_group_categories.GROUP,
            name=education_group_types.GroupType.FINALITY_120_LIST_CHOICE,
        )
        finality_list = EducationGroupYearFactory(
            acronym='LIST FINALITIES',
            education_group_type=finality_list_type,
            academic_year=self.academic_year)

        formation_master_md_type = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING,
            name=education_group_types.TrainingType.MASTER_MD_120,
        )
        formation_master_md = EducationGroupYearFactory(
            acronym='DROI2MD',
            education_group_type=formation_master_md_type,
            academic_year=self.academic_year)

        common_core_type = EducationGroupTypeFactory(
            category=education_group_categories.GROUP,
            name=education_group_types.GroupType.COMMON_CORE,
        )
        common_core = EducationGroupYearFactory(
            acronym='TC DROI2MD',
            education_group_type=common_core_type,
            academic_year=self.academic_year)

        self.link_1 = GroupElementYearFactory(parent=self.root,
                                              child_branch=finality_list,
                                              child_leaf=None)
        self.link_1_bis = GroupElementYearFactory(
            parent=self.root,
            child_branch=EducationGroupYearFactory(
                academic_year=self.academic_year),
            child_leaf=None)
        self.link_2 = GroupElementYearFactory(parent=finality_list,
                                              child_branch=formation_master_md,
                                              child_leaf=None)
        self.link_3 = GroupElementYearFactory(parent=formation_master_md,
                                              child_branch=common_core,
                                              child_leaf=None)
        self.link_4 = GroupElementYearFactory(
            parent=common_core,
            child_leaf=LearningUnitYearFactory(),
            child_branch=None)
Example #7
0
    def setUp(self):
        self.academic_year = AcademicYearFactory()
        self.education_group_type_training = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)

        self.education_group_type_minitraining = EducationGroupTypeFactory(
            category=education_group_categories.MINI_TRAINING)

        self.education_group_type_group = EducationGroupTypeFactory(
            category=education_group_categories.GROUP)

        self.education_group_year_1 = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group_type=self.education_group_type_training)
        self.education_group_year_2 = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group_type=self.education_group_type_minitraining)

        self.education_group_year_3 = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group_type=self.education_group_type_training)
        self.education_group_year_4 = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group_type=self.education_group_type_group)
        self.education_group_year_5 = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group_type=self.education_group_type_group)
        self.education_group_year_6 = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group_type=self.education_group_type_training)

        self.educ_group_year_domain = EducationGroupYearDomainFactory(
            education_group_year=self.education_group_year_2)

        self.entity_version_admin = EntityVersionFactory(
            entity=self.education_group_year_2.administration_entity,
            start_date=self.education_group_year_2.academic_year.start_date,
            parent=None)

        self.offer_year_3 = OfferYearFactory(academic_year=self.academic_year)

        self.entity_version_management = EntityVersionFactory(
            entity=self.education_group_year_3.management_entity,
            start_date=self.education_group_year_3.academic_year.start_date,
            parent=None)

        self.group_element_year_4 = GroupElementYearFactory(
            parent=self.education_group_year_3,
            child_branch=self.education_group_year_1)
        self.group_element_year_5 = GroupElementYearFactory(
            parent=self.education_group_year_6,
            child_branch=self.education_group_year_1)
Example #8
0
    def setUp(self):

        academic_year = AcademicYearFactory()
        self.education_group_type_training = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)
        self.education_group_type_minitraining = EducationGroupTypeFactory(
            category=education_group_categories.MINI_TRAINING)
        self.education_group_type_group = EducationGroupTypeFactory(
            category=education_group_categories.GROUP)

        self.education_group_year_1 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_training)
        self.education_group_year_2 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_minitraining)

        self.education_group_year_3 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_training)
        self.education_group_year_4 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_group)
        self.education_group_year_5 = EducationGroupYearFactory(
            academic_year=academic_year,
            education_group_type=self.education_group_type_group)

        self.offer_year_2 = OfferYearFactory(academic_year=academic_year)
        self.offer_year_domain = OfferYearDomainFactory(
            offer_year=self.offer_year_2,
            education_group_year=self.education_group_year_2)
        self.offer_year_entity_admin = OfferYearEntityFactory(
            offer_year=self.offer_year_2,
            education_group_year=self.education_group_year_2,
            type=offer_year_entity_type.ENTITY_ADMINISTRATION)
        self.entity_version_admin = EntityVersionFactory(
            entity=self.offer_year_entity_admin.entity, parent=None)

        self.offer_year_3 = OfferYearFactory(academic_year=academic_year)
        self.offer_year_entity_management = OfferYearEntityFactory(
            offer_year=self.offer_year_3,
            education_group_year=self.education_group_year_3,
            type=offer_year_entity_type.ENTITY_MANAGEMENT)
        self.entity_version_management = EntityVersionFactory(
            entity=self.offer_year_entity_management.entity, parent=None)

        self.group_element_year_4 = GroupElementYearFactory(
            parent=self.education_group_year_3,
            child_branch=self.education_group_year_1)
        self.group_element_year_5 = GroupElementYearFactory(
            parent=self.education_group_year_3,
            child_branch=self.education_group_year_1)
Example #9
0
 def test_with_filters_case_direct_parent_academic_year_is_different(self):
     current_academic_year = create_current_academic_year()
     root_group_type = EducationGroupTypeFactory(name='Bachelor', category=education_group_categories.TRAINING)
     self.root = EducationGroupYearFactory(academic_year=current_academic_year,
                                           education_group_type=root_group_type)
     child_branch = EducationGroupYearFactory(
         academic_year=AcademicYearFactory(year=current_academic_year.year - 1),
         education_group_type=EducationGroupTypeFactory(category=education_group_categories.GROUP)
     )
     GroupElementYearFactory(parent=self.root, child_branch=child_branch)
     GroupElementYearFactory(parent=child_branch, child_branch=None, child_leaf=self.child_leaf)
     result = group_element_year._find_related_formations([self.child_leaf], self.filters)
     self.assertEqual(result[self.child_leaf.id], [self.root.id])
Example #10
0
    def setUp(self):
        today = datetime.date.today()
        self.academic_year = AcademicYearFactory(
            start_date=today,
            end_date=today.replace(year=today.year + 1),
            year=today.year)

        self.type_training = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)
        self.type_minitraining = EducationGroupTypeFactory(
            category=education_group_categories.MINI_TRAINING)
        self.type_group = EducationGroupTypeFactory(
            category=education_group_categories.GROUP)
Example #11
0
        def setUp(self):
            current_academic_year = create_current_academic_year()
            root_group_type = EducationGroupTypeFactory(name='Bachelor', category=education_group_categories.TRAINING)
            self.root = EducationGroupYearFactory(academic_year=current_academic_year,
                                                  education_group_type=root_group_type)

            group_type = EducationGroupTypeFactory(category=education_group_categories.GROUP)
            self.child_branch = EducationGroupYearFactory(academic_year=current_academic_year,
                                                          education_group_type=group_type)
            GroupElementYearFactory(parent=self.root, child_branch=self.child_branch)

            self.child_leaf = LearningUnitYearFactory(academic_year=current_academic_year)
            GroupElementYearFactory(parent=self.child_branch, child_branch=None, child_leaf=self.child_leaf)
Example #12
0
    def setUpTestData(cls):
        cls.user = UserFactory()
        cls.person = CentralManagerFactory(user=cls.user)

        cls.academic_year = create_current_academic_year()
        cls.education_group_yr = EducationGroupYearFactory(
            acronym='ARKE2A',
            academic_year=cls.academic_year,
            education_group_type=EducationGroupTypeFactory(
                category=education_group_categories.TRAINING),
            management_entity=EntityFactory())

        cls.root_id = cls.education_group_yr.id
        cls.country_be = CountryFactory()

        cls.organization_address = OrganizationAddressFactory(
            country=cls.country_be)
        cls.organization = cls.organization_address.organization
        cls.education_group_organization = EducationGroupOrganizationFactory(
            organization=cls.organization,
            education_group_year=cls.education_group_yr,
            diploma=diploma_coorganization.UNIQUE,
            all_students=True,
        )
        cls.organization_bis = OrganizationFactory()
        cls.address = OrganizationAddressFactory(
            organization=cls.organization_bis, is_main=True)
Example #13
0
    def test_education_group_parent_read(self, mock_find_by_id,
                                         mock_program_manager, mock_render,
                                         mock_decorators):
        mock_decorators.login_required = lambda x: x
        mock_decorators.permission_required = lambda *args, **kwargs: lambda func: func

        education_group_type = EducationGroupTypeFactory(category=TRAINING)

        education_group_year_child = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group_type=education_group_type)
        education_group_year_parent = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group_type=education_group_type)

        GroupElementYearFactory(parent=education_group_year_parent,
                                child_branch=education_group_year_child)
        request = mock.Mock(method='GET')

        from base.views.education_group import education_group_parent_read

        mock_find_by_id.return_value = education_group_year_child
        education_group_parent_read(request, education_group_year_child.id)
        self.assertTrue(mock_render.called)
        request, template, context = mock_render.call_args[0]
        self.assertEqual(template, 'education_group/tab_identification.html')
        self.assertEqual(context['education_group_year'].parent_by_training,
                         education_group_year_parent)
Example #14
0
    def setUp(self):
        self.current_academic_year = create_current_academic_year()
        self.generated_ac_years = GenerateAcademicYear(
            self.current_academic_year.year + 1,
            self.current_academic_year.year + 10)
        self.parent_education_group_year = EducationGroupYearFactory(
            academic_year=self.current_academic_year)
        self.test_categories = [
            education_group_categories.GROUP,
            education_group_categories.TRAINING,
            education_group_categories.MINI_TRAINING,
        ]
        self.education_group_types = [
            EducationGroupTypeFactory(category=category)
            for category in self.test_categories
        ]

        self.organization = OrganizationFactory(type=organization_type.MAIN)
        self.entity = EntityFactory(organization=self.organization)
        self.entity_version = EntityVersionFactory(entity=self.entity,
                                                   entity_type=FACULTY,
                                                   start_date=datetime.now())
        self.language = LanguageFactory()
        self.person = PersonFactory()
        PersonEntityFactory(person=self.person, entity=self.entity)
        self.client.force_login(self.person.user)
        self.perm_patcher = mock.patch(
            "base.business.education_groups.perms._is_eligible_to_add_education_group",
            return_value=True)
        self.mocked_perm = self.perm_patcher.start()
Example #15
0
    def setUp(self):
        self.permissions = [PermissionFactory() for _ in range(10)]

        FieldReferenceFactory(
            content_type=ContentType.objects.get(app_label="base",
                                                 model="educationgroupyear"),
            field_name="main_teaching_campus",
            context=TRAINING_DAILY_MANAGEMENT,
            permissions=self.permissions,
        )

        FieldReferenceFactory(
            content_type=ContentType.objects.get(app_label="base",
                                                 model="educationgroupyear"),
            field_name="partial_acronym",
            context="",
            permissions=self.permissions,
        )

        person = PersonFactory()
        self.user_with_perm = person.user
        self.user_with_perm.user_permissions.add(self.permissions[2])

        person = PersonFactory()
        self.user_without_perm = person.user
        self.user_without_perm.user_permissions.add(PermissionFactory())

        self.education_group_type = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)
Example #16
0
    def setUpTestData(cls):
        cls.academic_year = AcademicYearFactory()
        create_current_academic_year()
        cls.parent_education_group_year = EducationGroupYearFactory(
            academic_year=cls.academic_year)

        cls.test_categories = [
            education_group_categories.GROUP,
            education_group_categories.TRAINING,
            education_group_categories.MINI_TRAINING,
        ]

        cls.education_group_types = [
            EducationGroupTypeFactory(category=category)
            for category in cls.test_categories
        ]

        cls.auth_rels = [
            AuthorizedRelationshipFactory(
                parent_type=cls.parent_education_group_year.
                education_group_type,
                child_type=eg_type,
                min_count_authorized=0,
                max_count_authorized=1,
            ) for eg_type in cls.education_group_types
        ]

        cls.person = PersonFactory()
Example #17
0
def _get_valid_post_data(category):
    entity_version = MainEntityVersionFactory()
    education_group_type = EducationGroupTypeFactory(category=category)
    campus = CampusFactory(organization__type=organization_type.MAIN)
    current_academic_year = create_current_academic_year()
    fake_education_group_year = EducationGroupYearFactory.build(
        academic_year=current_academic_year,
        management_entity=entity_version.entity,
        main_teaching_campus=campus,
        education_group_type=education_group_type,
        education_group__start_year=current_academic_year.year,
        constraint_type=CREDITS,
    )
    AuthorizedRelationshipFactory(child_type=fake_education_group_year.education_group_type)
    post_data = {
        'main_teaching_campus': str(fake_education_group_year.main_teaching_campus.id),
        'management_entity': str(entity_version.id),
        'remark_english': str(fake_education_group_year.remark_english),
        'title_english': str(fake_education_group_year.title_english),
        'partial_acronym': str(fake_education_group_year.partial_acronym),
        'end_year': str(fake_education_group_year.education_group.end_year),
        'start_year': str(fake_education_group_year.education_group.start_year),
        'title': str(fake_education_group_year.title),
        'credits': str(fake_education_group_year.credits),
        'academic_year': str(fake_education_group_year.academic_year.id),
        'constraint_type': CREDITS,
        'max_constraint': str(fake_education_group_year.max_constraint),
        'min_constraint': str(fake_education_group_year.min_constraint),
        'remark': str(fake_education_group_year.remark),
        'acronym': str(fake_education_group_year.acronym),
        'active': str(fake_education_group_year.active),
        'schedule_type': str(fake_education_group_year.schedule_type),
    }
    return fake_education_group_year, post_data
Example #18
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": "",
        }
    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,
        )
Example #20
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)
    def setUp(self):
        self.parent_education_group_year = EducationGroupYearFactory(
            academic_year=self.academic_year)

        self.test_categories = [
            education_group_categories.GROUP,
            education_group_categories.TRAINING,
            education_group_categories.MINI_TRAINING,
        ]

        self.education_group_types = [
            EducationGroupTypeFactory(category=category)
            for category in self.test_categories
        ]

        self.auth_rels = [
            AuthorizedRelationshipFactory(
                parent_type=self.parent_education_group_year.
                education_group_type,
                child_type=eg_type,
                min_count_authorized=0,
                max_count_authorized=1,
            ) for eg_type in self.education_group_types
        ]

        self.person = PersonFactory()

        self.client.force_login(self.person.user)
        self.perm_patcher = mock.patch(
            "base.business.education_groups.perms._is_eligible_to_add_education_group",
            return_value=True)
        self.mocked_perm = self.perm_patcher.start()
Example #22
0
    def test_dump_authorized(self):
        an_authorized_relation_ship = AuthorizedRelationshipFactory(
            parent_type=EducationGroupTypeFactory(
                name=education_group_types.TrainingType.AGGREGATION.name),
            child_type=EducationGroupTypeFactory(
                name=education_group_types.TrainingType.CERTIFICATE.name))
        dump_data_alike = serializers.serialize('json', [
            an_authorized_relation_ship,
        ],
                                                use_natural_foreign_keys=True)
        dump_data = json.loads(dump_data_alike)

        self.assertEqual(dump_data[0].get('fields').get('parent_type'),
                         [an_authorized_relation_ship.parent_type.name])
        self.assertEqual(dump_data[0].get('fields').get('child_type'),
                         [an_authorized_relation_ship.child_type.name])
Example #23
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])
Example #24
0
    def setUpTestData(cls):
        academic_year = AcademicYearFactory()
        type_training = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)
        cls.education_group_parent = EducationGroupYearFactory(
            acronym="Parent",
            academic_year=academic_year,
            education_group_type=type_training)
        cls.education_group_child = EducationGroupYearFactory(
            acronym="Child_1",
            academic_year=academic_year,
            education_group_type=type_training)

        GroupElementYearFactory(parent=cls.education_group_parent,
                                child_branch=cls.education_group_child)

        cls.cms_label_for_child = TranslatedTextFactory(
            text_label=TextLabelFactory(entity=entity_name.OFFER_YEAR),
            reference=cls.education_group_child.id)

        cls.user = UserFactory()
        cls.user.user_permissions.add(
            Permission.objects.get(codename="can_access_education_group"))
        cls.url = reverse("education_group_general_informations",
                          args=[cls.education_group_child.id])
Example #25
0
 def test_ordered_by_name(self):
     EducationGroupTypeFactory(category=education_group_categories.TRAINING)
     expected_result = [
         self.complementary_module, self.options_list, self.subgroup
     ]
     self.assertEqual(expected_result,
                      list(find_authorized_types(category=self.category)))
Example #26
0
    def setUp(self):
        super().setUp()

        self.user = UserFactory()
        self.person = PersonFactory(user=self.user)

        # the user can access to the education group
        self.user.user_permissions.add(
            Permission.objects.get(codename='can_access_education_group'))

        academic_year = AcademicYearFactory()

        type_training = EducationGroupTypeFactory(
            category=education_group_categories.TRAINING)

        self.education_group_parent = EducationGroupYearFactory(
            acronym="Parent",
            academic_year=academic_year,
            education_group_type=type_training)

        self.education_group_year = EducationGroupYearFactory(
            acronym="Child_1",
            academic_year=academic_year,
            education_group_type=type_training)

        GroupElementYearFactory(parent=self.education_group_parent,
                                child_branch=self.education_group_year)

        self.text_label = TextLabelFactory(label='welcome_introduction',
                                           entity=entity_name.OFFER_YEAR)

        TranslatedTextLabelFactory(text_label=self.text_label,
                                   language="fr-be",
                                   label='Introduction')

        TranslatedTextLabelFactory(text_label=self.text_label,
                                   language="en",
                                   label='Introduction')
        # fr-be
        TranslatedTextRandomFactory(text_label=self.text_label,
                                    entity=self.text_label.entity,
                                    reference=str(
                                        self.education_group_year.id))

        # en
        EnglishTranslatedTextRandomFactory(text_label=self.text_label,
                                           entity=self.text_label.entity,
                                           reference=str(
                                               self.education_group_year.id))
        page = LoginPage(driver=self.selenium,
                         base_url=self.live_server_url + '/login/').open()

        page.login(username=self.user.username)

        self.url = reverse('education_group_general_informations',
                           args=[
                               self.education_group_parent.id,
                               self.education_group_year.id
                           ])
Example #27
0
 def setUp(self):
     self.academic_year = create_current_academic_year()
     self.education_group_type_group = EducationGroupTypeFactory(category=education_group_categories.GROUP)
     self.education_group_year_1 = EducationGroupYearFactory(academic_year=self.academic_year, acronym="PREMIER")
     self.education_group_year_1.management_entity_version = EntityVersionFactory()
     self.education_group_year_2 = EducationGroupYearFactory(academic_year=self.academic_year, acronym="DEUXIEME")
     self.education_group_year_2.management_entity_version = EntityVersionFactory()
     self.user = UserFactory()
Example #28
0
    def setUpTestData(cls):
        cls.education_group_type = EducationGroupTypeFactory(
            category=education_group_categories.MINI_TRAINING)
        cls.form_class = MiniTrainingYearModelForm
        AuthorizedRelationshipFactory(child_type=cls.education_group_type)

        super(TestMiniTrainingModelForm,
              cls).setUpTestData(education_group_type=cls.education_group_type)
Example #29
0
    def setUp(self):
        self.education_group_type = EducationGroupTypeFactory(
            category=education_group_categories.GROUP)
        self.form_class = GroupYearModelForm
        AuthorizedRelationshipFactory(child_type=self.education_group_type)

        super(TestGroupModelFormModelForm,
              self).setUp(education_group_type=self.education_group_type)
Example #30
0
    def setUp(self):
        self.education_group_type = EducationGroupTypeFactory(
            category=education_group_categories.MINI_TRAINING)
        self.form_class = MiniTrainingYearModelForm
        AuthorizedRelationshipFactory(child_type=self.education_group_type)

        super(TestMiniTrainingModelForm,
              self).setUp(education_group_type=self.education_group_type)