コード例 #1
0
    def test_get_administrator_entities_acronym_list(self):

        structure_root_1 = StructureFactory(acronym='A')

        structure_child_1 = StructureFactory(acronym='AA',
                                             part_of=structure_root_1)
        structure_child_2 = StructureFactory(acronym='BB',
                                             part_of=structure_root_1)

        structure_root_2 = StructureFactory(acronym='B')

        data = [{
            'root':
            structure_root_1,
            'structures':
            [structure_root_1, structure_child_1, structure_child_2]
        }, {
            'root': structure_root_2,
            'structures': []
        }]

        EntityManagerFactory(person=self.person, structure=structure_root_1)

        data = pgm_manager_administration._get_administrator_entities_acronym_list(
            data)

        self.assertEqual(data, "A, B")
コード例 #2
0
 def test_find_program_manager_by_entity_administration_fac(self):
     a_management_entity = StructureFactory()
     offer_yr = OfferYearFactory(academic_year=self.academic_year,
                                 entity_management=a_management_entity)
     ProgramManagerFactory(offer_year=offer_yr, person=PersonFactory())
     self.assertEquals(
         len(
             program_manager.find_by_management_entity(
                 [a_management_entity], self.academic_year)), 1)
コード例 #3
0
    def test_get_administrator_entities_ensure_order(self):
        structure_root_1 = StructureFactory(acronym='SST')
        StructureFactory(acronym='EPL', part_of=structure_root_1)
        StructureFactory(acronym='AGRO', part_of=structure_root_1)
        structure_root_2 = StructureFactory(acronym='SIMM')

        EntityManagerFactory(person=self.entity_manager.person,
                             structure=structure_root_1)
        EntityManagerFactory(person=self.entity_manager.person,
                             structure=structure_root_2)

        data = pgm_manager_administration.get_administrator_entities(
            self.entity_manager.person.user)
        self.assertEqual(data[0]['root'], structure_root_2)  # SIMM
        self.assertEqual(len(data[0]['structures']), 1)
        self.assertEqual(data[1]['root'], self.structure_parent1)  # SSH
        self.assertEqual(len(data[1]['structures']), 6)
        self.assertEqual(data[2]['root'], structure_root_1)  # SST
        self.assertEqual(len(data[2]['structures']), 3)
コード例 #4
0
    def test_get_administrator_entities(self):
        a_person = PersonFactory(user=self.user)
        root_acronyms = ['A', 'B']
        child_acronyms = ['AA', 'BB']

        structure_root_1 = StructureFactory(acronym=root_acronyms[0])

        StructureFactory(acronym=child_acronyms[0], part_of=structure_root_1)
        StructureFactory(acronym=child_acronyms[1], part_of=structure_root_1)

        structure_root_2 = StructureFactory(acronym=root_acronyms[1])

        EntityManagerFactory(person=a_person, structure=structure_root_1)
        EntityManagerFactory(person=a_person, structure=structure_root_2)

        data = pgm_manager_administration.get_administrator_entities(self.user)
        self.assertEqual(data[0]['root'], structure_root_1)
        self.assertEqual(len(data[0]['structures']), 3)
        self.assertEqual(data[1]['root'], structure_root_2)
        self.assertEqual(len(data[1]['structures']), 1)
コード例 #5
0
    def setUpTestData(cls):
        ProgramManagerGroupFactory()
        group = EntityManagerGroupFactory()
        group.permissions.add(
            Permission.objects.get(codename='view_programmanager'))
        group.permissions.add(
            Permission.objects.get(codename='change_programmanager'))

        # FIXME: Old structure model [To remove]
        cls.structure_parent1 = StructureFactory(acronym='SSH')
        cls.structure_child1 = StructureFactory(acronym='TECO',
                                                part_of=cls.structure_parent1)
        cls.structure_child11 = StructureFactory(acronym='TEBI',
                                                 part_of=cls.structure_child1)
        cls.structure_child2 = StructureFactory(acronym='ESPO',
                                                part_of=cls.structure_parent1)
        cls.structure_child21 = StructureFactory(acronym='ECON',
                                                 part_of=cls.structure_child2)
        cls.structure_child22 = StructureFactory(acronym='COMU',
                                                 part_of=cls.structure_child2)

        cls.entity_manager = EntityManagerFactory(
            structure=cls.structure_parent1)
        cls.academic_year_previous, cls.academic_year_current = AcademicYearFactory.produce_in_past(
            quantity=2)
        cls.person = PersonFactory()
コード例 #6
0
    def test_pgm_manager_queried_by_academic_year(self):
        a_management_entity = StructureFactory()
        offer_year_previous_year = OfferYearFactory(academic_year=self.academic_year_previous,
                                                    entity_management=a_management_entity)
        offer_year_current_year = OfferYearFactory(academic_year=self.academic_year_current,
                                                   entity_management=a_management_entity)
        person_previous_year = PersonFactory()
        person_current_year = PersonFactory()

        ProgramManagerFactory(person=person_previous_year, offer_year=offer_year_previous_year)
        ProgramManagerFactory(person=person_current_year, offer_year=offer_year_current_year)

        self.assertEqual(len(pgm_manager_administration._get_entity_program_managers([{'root': a_management_entity}],
                                                                                     self.academic_year_current)), 1)
コード例 #7
0
    def test_offer_year_queried_by_academic_year(self):
        an_entity_management = StructureFactory()
        OfferYearFactory(academic_year=self.academic_year_previous, entity_management=an_entity_management)
        OfferYearFactory(academic_year=self.academic_year_current, entity_management=an_entity_management)
        OfferYearFactory(academic_year=self.academic_year_current, entity_management=an_entity_management)

        self.assertEqual(len(pgm_manager_administration._get_programs(self.academic_year_current,
                                                                      [an_entity_management],
                                                                      None,
                                                                      None)), 2)
        self.assertEqual(len(pgm_manager_administration._get_programs(self.academic_year_previous,
                                                                      [an_entity_management],
                                                                      None,
                                                                      None)), 1)
コード例 #8
0
    def test_get_entity_list_for_entity_hierarchy(self):
        entity_parent1 = StructureFactory(acronym='P1')

        entity_child1 = StructureFactory(acronym='C1', part_of=entity_parent1)
        StructureFactory(acronym='C11', part_of=entity_child1)

        entity_child2 = StructureFactory(acronym='P2', part_of=entity_parent1)
        StructureFactory(acronym='P21', part_of=entity_child2)
        StructureFactory(acronym='P22', part_of=entity_child2)

        self.assertEqual(len(pgm_manager_administration.get_entity_list(None, entity_parent1)), 6)
コード例 #9
0
    def test_get_entity_list_for_one_entity(self):
        entity_parent1 = StructureFactory(acronym='P1')

        entity_child1 = StructureFactory(acronym='C1', part_of=entity_parent1)
        StructureFactory(acronym='C11', part_of=entity_child1)

        entity_child2 = StructureFactory(acronym='C2', part_of=entity_parent1)
        StructureFactory(acronym='C21', part_of=entity_child2)
        StructureFactory(acronym='C22', part_of=entity_child2)

        self.assertEqual(len(pgm_manager_administration.get_entity_list(entity_child1.id, None)), 1)
コード例 #10
0
    def setUpTestData(cls):
        ProgramManagerGroupFactory()

        cls.user = SuperUserFactory()
        cls.person = PersonFactory()

        cls.structure_parent1 = StructureFactory(acronym='SSH')

        cls.structure_child1 = StructureFactory(acronym='TECO', part_of=cls.structure_parent1)
        cls.structure_child11 = StructureFactory(acronym='TEBI', part_of=cls.structure_child1)

        cls.structure_child2 = StructureFactory(acronym='ESPO', part_of=cls.structure_parent1)
        cls.structure_child21 = StructureFactory(acronym='ECON', part_of=cls.structure_child2)
        cls.structure_child22 = StructureFactory(acronym='COMU', part_of=cls.structure_child2)
        EntityManagerFactory(person__user=cls.user, structure=cls.structure_parent1)

        cls.academic_year_previous, cls.academic_year_current = AcademicYearFactory.produce_in_past(quantity=2)
コード例 #11
0
    def test_search_find_programs_by_entity_grade_type(self):
        an_offer_type = OfferTypeFactory()
        offer_year1 = OfferYearFactory(
            academic_year=self.academic_year_current,
            entity_management=self.structure_parent1,
            offer_type=an_offer_type)
        OfferYearFactory(academic_year=self.academic_year_current,
                         entity_management=StructureFactory(),
                         offer_type=an_offer_type)
        self.assertEqual(
            len(
                pgm_manager_administration._filter_by_entity_offer_type(
                    offer_year1.academic_year, [self.structure_parent1],
                    an_offer_type)), 1)

        self.assertEqual(
            len(
                pgm_manager_administration._filter_by_entity_offer_type(
                    offer_year1.academic_year, [self.structure_parent1],
                    None)), 1)
        self.assertEqual(
            len(
                pgm_manager_administration._filter_by_entity_offer_type(
                    offer_year1.academic_year, None, None)), 2)
コード例 #12
0
    def setUpTestData(cls):
        ProgramManagerGroupFactory()

        cls.user = User.objects.create_user('tmp', '*****@*****.**', 'tmp')
        cls.person = PersonFactory()

        cls.structure_parent1 = StructureFactory(acronym='SSH')

        cls.structure_child1 = StructureFactory(acronym='TECO',
                                                part_of=cls.structure_parent1)
        cls.structure_child11 = StructureFactory(acronym='TEBI',
                                                 part_of=cls.structure_child1)

        cls.structure_child2 = StructureFactory(acronym='ESPO',
                                                part_of=cls.structure_parent1)
        cls.structure_child21 = StructureFactory(acronym='ECON',
                                                 part_of=cls.structure_child2)
        cls.structure_child22 = StructureFactory(acronym='COMU',
                                                 part_of=cls.structure_child2)

        cls.academic_year_previous, cls.academic_year_current = AcademicYearFactory.produce_in_past(
            quantity=2)
コード例 #13
0
    def setUp(self):
        self.user = User.objects.create_user('tmp', '*****@*****.**', 'tmp')
        self.person = PersonFactory()

        self.structure_parent1 = StructureFactory(acronym='SSH')

        self.structure_child1 = StructureFactory(
            acronym='TECO', part_of=self.structure_parent1)
        self.structure_child11 = StructureFactory(
            acronym='TEBI', part_of=self.structure_child1)

        self.structure_child2 = StructureFactory(
            acronym='ESPO', part_of=self.structure_parent1)
        self.structure_child21 = StructureFactory(
            acronym='ECON', part_of=self.structure_child2)
        self.structure_child22 = StructureFactory(
            acronym='COMU', part_of=self.structure_child2)

        a_year = datetime.now().year
        self.academic_year_previous = AcademicYearFactory(year=a_year - 1)
        self.academic_year_current = AcademicYearFactory(year=a_year)

        self.Client = Client()
コード例 #14
0
 def test_get_entity_root(self):
     a_structure = StructureFactory()
     self.assertEqual(
         pgm_manager_administration.get_entity_root(a_structure.id),
         a_structure)
コード例 #15
0
    def _prepare_context_education_groups_search(self):
        # Create a structure [Entity / Entity version]
        country = CountryFactory()
        structure = StructureFactory()
        ssh_entity = EntityFactory(country=country)
        ssh_entity_v = EntityVersionFactory(acronym="SSH",
                                            end_date=None,
                                            entity=ssh_entity)

        agro_entity = EntityFactory(country=country)
        envi_entity = EntityFactory(country=country)
        ages_entity = EntityFactory(country=country)
        agro_entity_v = EntityVersionFactory(entity=agro_entity,
                                             parent=ssh_entity_v.entity,
                                             acronym="AGRO",
                                             end_date=None)
        envi_entity_v = EntityVersionFactory(entity=envi_entity,
                                             parent=agro_entity_v.entity,
                                             acronym="ENVI",
                                             end_date=None)
        ages_entity_v = EntityVersionFactory(entity=ages_entity,
                                             parent=agro_entity_v.entity,
                                             acronym="AGES",
                                             end_date=None)

        # Create EG and put entity charge [AGRO]
        agro_education_group = EducationGroupFactory()
        agro_education_group_type = EducationGroupTypeFactory(
            category=TRAINING)

        agro_education_group_year = EducationGroupYearFactory(
            acronym='EDPH2',
            academic_year=self.academic_year,
            education_group=agro_education_group,
            education_group_type=agro_education_group_type)

        agro_offer = OfferFactory()
        agro_offer_year = OfferYearFactory(offer=agro_offer,
                                           entity_management=structure,
                                           entity_administration_fac=structure)

        OfferYearEntityFactory(offer_year=agro_offer_year,
                               entity=agro_entity,
                               education_group_year=agro_education_group_year,
                               type=offer_year_entity_type.ENTITY_MANAGEMENT)

        # Create EG and put entity charge [ENVI]
        envi_education_group = EducationGroupFactory()
        envi_education_group_type = EducationGroupTypeFactory(
            category=TRAINING)

        envi_education_group_year = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group=envi_education_group,
            education_group_type=envi_education_group_type)

        envi_offer = OfferFactory()
        envi_offer_year = OfferYearFactory(offer=envi_offer,
                                           entity_management=structure,
                                           entity_administration_fac=structure)

        OfferYearEntityFactory(offer_year=envi_offer_year,
                               entity=envi_entity,
                               education_group_year=envi_education_group_year,
                               type=offer_year_entity_type.ENTITY_MANAGEMENT)

        # Create EG and put entity charge [AGES]
        ages_education_group = EducationGroupFactory()
        ages_education_group_type = EducationGroupTypeFactory(
            category=TRAINING)

        ages_education_group_year = EducationGroupYearFactory(
            academic_year=self.academic_year,
            education_group=ages_education_group,
            education_group_type=ages_education_group_type)

        ages_offer = OfferFactory()
        ages_offer_year = OfferYearFactory(offer=ages_offer,
                                           entity_management=structure,
                                           entity_administration_fac=structure)

        OfferYearEntityFactory(offer_year=ages_offer_year,
                               entity=ages_entity,
                               education_group_year=ages_education_group_year,
                               type=offer_year_entity_type.ENTITY_MANAGEMENT)