Exemple #1
0
    def setUpTestData(cls):
        group = EntityManagerGroupFactory()
        group.permissions.add(
            Permission.objects.get(codename='view_scoresresponsible'))
        group.permissions.add(
            Permission.objects.get(codename='change_scoresresponsible'))

        cls.person = PersonFactory()
        cls.academic_year = AcademicYearFactory(
            year=datetime.date.today().year, start_date=datetime.date.today())

        # FIXME: Old structure model [To remove]
        cls.structure = structure.StructureFactory()

        entities_hierarchy = create_entities_hierarchy()
        cls.root_entity = entities_hierarchy.get('root_entity')

        cls.entity_manager = EntityManagerFactory(
            person=cls.person,
            structure=cls.structure,
            entity=cls.root_entity,
        )
        cls.entity_manager.person.user.groups.add(group)
        cls.learning_unit_year = LearningUnitYearFactory(
            academic_year=cls.academic_year,
            acronym="LBIR1210",
            structure=cls.structure,
            learning_container_year__academic_year=cls.academic_year,
            learning_container_year__acronym="LBIR1210",
            learning_container_year__requirement_entity=cls.root_entity,
        )
    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()
Exemple #3
0
    def setUpTestData(cls):
        group = EntityManagerGroupFactory()
        group.permissions.add(
            Permission.objects.get(codename='view_scoresresponsible'))
        group.permissions.add(
            Permission.objects.get(codename='change_scoresresponsible'))

        cls.tutor = TutorFactory()
        cls.user = cls.tutor.person.user
        cls.academic_year = AcademicYearFactory(current=True)

        # FIXME: Old structure model [To remove]
        cls.structure = structure.StructureFactory()
        cls.structure_children = structure.StructureFactory(
            part_of=cls.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        cls.root_entity = entities_hierarchy.get('root_entity')
        cls.child_one_entity = entities_hierarchy.get('child_one_entity')
        cls.child_two_entity = entities_hierarchy.get('child_two_entity')
        cls.learning_unit_yr_req_entity_acronym = entities_hierarchy.get(
            'child_one_entity_version').acronym
        cls.root_entity_acronym = entities_hierarchy.get(
            'root_entity_version').acronym

        cls.entity_manager = EntityManagerFactory(
            person=cls.tutor.person,
            structure=cls.structure,
            entity=cls.root_entity,
        )

        cls.learning_unit_year = LearningUnitYearFactory(
            academic_year=cls.academic_year,
            acronym="LBIR1210",
            structure=cls.structure,
            learning_container_year__academic_year=cls.academic_year,
            learning_container_year__acronym="LBIR1210",
            learning_container_year__requirement_entity=cls.child_one_entity,
        )

        cls.learning_unit_year_children = LearningUnitYearFactory(
            academic_year=cls.academic_year,
            acronym="LBIR1211",
            structure=cls.structure_children,
            learning_container_year__academic_year=cls.academic_year,
            learning_container_year__acronym="LBIR1211",
            learning_container_year__requirement_entity=cls.child_two_entity,
        )

        cls.attribution = AttributionFactory(
            tutor=cls.tutor,
            learning_unit_year=cls.learning_unit_year,
            score_responsible=True)
        cls.attribution_children = AttributionFactory(
            tutor=cls.tutor,
            learning_unit_year=cls.learning_unit_year_children,
            score_responsible=True)
        cls.url = reverse('scores_responsible_list')
        cls.user.groups.add(group)
Exemple #4
0
 def test_delete_manager_no_person_to_be_removed(self):
     self.client.force_login(self.user)
     a_person = PersonFactory(user=self.user)
     EntityManagerFactory(person=a_person)
     url = reverse('delete_manager')
     response = self.client.get(url + "?person=&pgms=")
     self.assertEqual(response.status_code, 204)
Exemple #5
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")
Exemple #6
0
 def setUpTestData(cls):
     cls.entity_manager = EntityManagerFactory()
     cls.educ_group = EducationGroupFactory()
     cls.education_group = OfferPropositionFactory()
     cls.adviser = AdviserTeacherFactory()
     cls.faculty_adviser = FacultyAdviserFactory(
         adviser=cls.adviser, education_group=cls.educ_group)
Exemple #7
0
    def setUp(self):
        group, created = Group.objects.get_or_create(name='entity_managers')
        content_type = ContentType.objects.get_for_model(EntityManager)
        perm, created = Permission.objects.get_or_create(
            codename='is_entity_manager', content_type=content_type)
        group.permissions.add(perm)
        self.user = user.UserFactory()
        self.user.save()
        self.person = create_person_with_user(self.user)
        self.tutor = TutorFactory(person=self.person)
        self.academic_year = AcademicYearFactory(
            year=datetime.date.today().year, start_date=datetime.date.today())
        # Old structure model [To remove]
        self.structure = structure.StructureFactory()
        self.structure_children = structure.StructureFactory(
            part_of=self.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        self.root_entity = entities_hierarchy.get('root_entity')
        self.child_one_entity = entities_hierarchy.get('child_one_entity')
        self.child_two_entity = entities_hierarchy.get('child_two_entity')

        self.entity_manager = EntityManagerFactory(person=self.person,
                                                   structure=self.structure,
                                                   entity=self.root_entity)

        # Create two learning_unit_year with context (Container + EntityContainerYear)
        self.learning_unit_year = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure,
            entity=self.child_one_entity,
            acronym="LBIR1210")
        self.learning_unit_year_children = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure_children,
            entity=self.child_two_entity,
            acronym="LBIR1211")

        self.attribution = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            score_responsible=True)
        self.attribution_children = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year_children,
            score_responsible=True)
Exemple #8
0
    def setUp(self):
        self.faculty_administrator = EntityManagerFactory()

        self.user = User.objects.create_user("username",
                                             "*****@*****.**",
                                             "passtest",
                                             first_name='first_name',
                                             last_name='last_name')
        self.user.save()
    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)
Exemple #10
0
    def setUp(self):
        self.user = user.UserFactory()
        self.user.save()
        self.person = create_person_with_user(self.user)
        self.tutor = TutorFactory(person=self.person)
        self.academic_year = AcademicYearFactory(
            year=datetime.date.today().year, start_date=datetime.date.today())
        # Old structure model [To remove]
        self.structure = structure.StructureFactory()
        self.structure_children = structure.StructureFactory(
            part_of=self.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        self.root_entity = entities_hierarchy.get('root_entity')
        self.child_one_entity = entities_hierarchy.get('child_one_entity')
        self.child_two_entity = entities_hierarchy.get('child_two_entity')

        self.entity_manager = EntityManagerFactory(person=self.person,
                                                   structure=self.structure,
                                                   entity=self.root_entity)

        # Create two learning_unit_year with context (Container + EntityContainerYear)
        self.learning_unit_year = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure,
            entity=self.child_one_entity,
            acronym="LBIR1210")
        self.learning_unit_year_children = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure_children,
            entity=self.child_two_entity,
            acronym="LBIR1211")

        self.attribution = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            score_responsible=True)
        self.attribution_children = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year_children,
            score_responsible=True)
Exemple #11
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)
Exemple #12
0
 def test_delete_manager(self):
     offer_year1 = OfferYearFactory(
         academic_year=self.academic_year_current,
         entity_management=self.structure_parent1)
     ProgramManagerFactory(person=self.person, offer_year=offer_year1)
     self.client.force_login(self.user)
     a_person = PersonFactory(user=self.user)
     EntityManagerFactory(person=a_person)
     url = reverse('delete_manager')
     response = self.client.get(url + "?person=%s&pgms=%s" %
                                (self.person.id, offer_year1.id))
     self.assertEqual(response.status_code, 204)
    def setUp(self):
        group, created = Group.objects.get_or_create(name='entity_managers')
        content_type = ContentType.objects.get_for_model(EntityManager)
        perm, created = Permission.objects.get_or_create(codename='is_entity_manager', content_type=content_type)
        group.permissions.add(perm)
        self.user = user.UserFactory()
        self.user.save()
        self.person = create_person_with_user(self.user)
        self.tutor = TutorFactory(person=self.person)
        self.academic_year = AcademicYearFactory(year=datetime.date.today().year,
                                                 start_date=datetime.date.today())
        # Old structure model [To remove]
        self.structure = structure.StructureFactory()
        self.structure_children = structure.StructureFactory(part_of=self.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        self.root_entity = entities_hierarchy.get('root_entity')
        self.child_one_entity = entities_hierarchy.get('child_one_entity')
        self.child_two_entity = entities_hierarchy.get('child_two_entity')

        self.entity_manager = EntityManagerFactory(
            person=self.person,
            structure=self.structure,
            entity=self.root_entity)

        # Create two learning_unit_year with context (Container + EntityContainerYear)
        self.learning_unit_year = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure,
            entity=self.child_one_entity,
            acronym="LBIR1210")
        self.learning_unit_year_children = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure_children,
            entity=self.child_two_entity,
            acronym="LBIR1211")

        self.attribution = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            score_responsible=True)
        self.attribution_children = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year_children,
            score_responsible=True)
    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)
    def setUp(self):
        self.user = user.UserFactory()
        self.user.save()
        self.person = create_person_with_user(self.user)
        self.tutor = TutorFactory(person=self.person)
        self.academic_year = AcademicYearFactory(
            year=datetime.date.today().year, start_date=datetime.date.today())
        # Old structure model [To remove]
        self.structure = structure.StructureFactory()
        self.structure_children = structure.StructureFactory(
            part_of=self.structure)

        # New structure model
        self.create_new_entity()
        self.entity_manager = EntityManagerFactory(person=self.person,
                                                   structure=self.structure,
                                                   entity=self.root_entity)
        self.create_learning_units()
Exemple #16
0
    def setUpTestData(cls):
        # Create entity version and entity manager
        cls.entity_version = EntityVersionFactory(
            entity_type=entity_type.SECTOR)
        cls.entity_manager_person = PersonFactory()
        EntityManagerFactory(entity=cls.entity_version.entity,
                             person=cls.entity_manager_person)

        cls.current_academic_year = create_current_academic_year()
        # Create multiple attribution
        for nb in range(0, 10):
            AttributionFactory(
                learning_unit_year__acronym='LBIR120{}'.format(nb),
                learning_unit_year__academic_year=cls.current_academic_year,
                learning_unit_year__learning_container_year__academic_year=cls.
                current_academic_year,
                learning_unit_year__learning_container_year__requirement_entity
                =cls.entity_version.entity,
            )
Exemple #17
0
    def setUpTestData(cls):
        # Create entity version and entity manager
        cls.entity_version = EntityVersionFactory(
            entity_type=entity_type.SECTOR)
        cls.entity_manager_person = PersonFactory()
        EntityManagerFactory(entity=cls.entity_version.entity,
                             person=cls.entity_manager_person)

        cls.current_academic_year = create_current_academic_year()
        # Create multiple attribution
        for nb in range(0, 10):
            attribution = AttributionFactory(
                learning_unit_year__acronym='LBIR120{}'.format(nb),
                learning_unit_year__academic_year=cls.current_academic_year,
                learning_unit_year__learning_container_year__academic_year=cls.
                current_academic_year,
            )
            # Link course to entity
            EntityContainerYearFactory(
                learning_container_year=attribution.learning_unit_year.
                learning_container_year,
                entity=cls.entity_version.entity,
                type=entity_container_year_link_type.REQUIREMENT_ENTITY,
            )
Exemple #18
0
class ScoresResponsibleViewTestCase(TestCase):
    def setUp(self):
        self.user = user.UserFactory()
        self.user.save()
        self.person = create_person_with_user(self.user)
        self.tutor = TutorFactory(person=self.person)
        self.academic_year = AcademicYearFactory(
            year=datetime.date.today().year, start_date=datetime.date.today())
        # Old structure model [To remove]
        self.structure = structure.StructureFactory()
        self.structure_children = structure.StructureFactory(
            part_of=self.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        self.root_entity = entities_hierarchy.get('root_entity')
        self.child_one_entity = entities_hierarchy.get('child_one_entity')
        self.child_two_entity = entities_hierarchy.get('child_two_entity')

        self.entity_manager = EntityManagerFactory(person=self.person,
                                                   structure=self.structure,
                                                   entity=self.root_entity)

        # Create two learning_unit_year with context (Container + EntityContainerYear)
        self.learning_unit_year = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure,
            entity=self.child_one_entity,
            acronym="LBIR1210")
        self.learning_unit_year_children = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure_children,
            entity=self.child_two_entity,
            acronym="LBIR1211")

        self.attribution = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            score_responsible=True)
        self.attribution_children = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year_children,
            score_responsible=True)

    def test_is_faculty_admin(self):
        entities_manager = mdl_base.entity_manager.is_entity_manager(self.user)
        self.assertTrue(entities_manager)

    def test_scores_responsible(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible')
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

    def test_scores_responsible_search_with_many_elements(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_search')
        data = {
            'course_code': 'LBIR121',
            'learning_unit_title': '',
            'tutor': self.tutor.person.last_name,
            'scores_responsible': ''
        }
        response = self.client.get(url, data=data)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context[-1]['dict_attribution']), 2)

    def test_scores_responsible_search_without_elements(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_search')
        data = {
            'course_code': '',
            'learning_unit_title': '',
            'tutor': '',
            'scores_responsible': ''
        }
        response = self.client.get(url, data=data)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context[-1]['dict_attribution']), 2)

    def test_create_attributions_list(self):
        entities_manager = mdl_base.entity_manager.find_by_user(self.user)
        entities = [
            entity_manager.entity for entity_manager in entities_manager
        ]
        entities_with_descendants = Entity.objects.filter(pk__in=[
            row['entity_id']
            for row in EntityVersion.objects.get_tree(entities)
        ])
        attributions_searched = attribution.search_scores_responsible(
            learning_unit_title=None,
            course_code=None,
            entities=entities_with_descendants,
            tutor=None,
            responsible=None)
        dictionary = get_attributions_list(attributions_searched,
                                           "-score_responsible")
        self.assertIsNotNone(dictionary)

    def test_scores_responsible_management(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_management')
        data = {
            'learning_unit_year':
            "learning_unit_year_%d" % self.learning_unit_year.id
        }
        response = self.client.get(url, data=data)
        self.assertEqual(response.status_code, 200)

    def test_scores_responsible_management_with_wrong_learning_unit_year(self):
        self.client.force_login(self.user)
        self.entity_manager.entity = EntityVersionFactory(parent=None,
                                                          end_date=None).entity
        self.entity_manager.save()
        url = reverse('scores_responsible_management')
        data = {
            'learning_unit_year':
            "learning_unit_year_{}".format(self.learning_unit_year.id)
        }
        response = self.client.get(url, data=data)
        self.assertEqual(response.status_code, 403)

    def test_scores_responsible_add(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_add',
                      args=[self.learning_unit_year.id])
        attribution_id = 'attribution_' + str(self.attribution.id)
        response = self.client.post(url, {
            "action": "add",
            "attribution_id": attribution_id
        })
        self.assertEqual(response.status_code, 302)

    def test_scores_responsible_cancel(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_add',
                      args=[self.learning_unit_year.id])
        attribution_id = 'attribution_' + str(self.attribution.id)
        response = self.client.post(url, {
            "action": "cancel",
            "attribution_id": attribution_id
        })
        self.assertEqual(response.status_code, 302)
 def setUpTestData(cls):
     cls.entity_manager = EntityManagerFactory()
     cls.education_group = OfferPropositionFactory()
     cls.adviser = AdviserTeacherFactory()
 def setUpTestData(cls):
     AcademicYearFactory(current=True)
     cls.entity_manager = EntityManagerFactory()
     cls.education_group = OfferPropositionFactory()
class ScoresResponsibleViewTestCase(TestCase):
    def setUp(self):
        group, created = Group.objects.get_or_create(name='entity_managers')
        content_type = ContentType.objects.get_for_model(EntityManager)
        perm, created = Permission.objects.get_or_create(codename='is_entity_manager', content_type=content_type)
        group.permissions.add(perm)
        self.user = user.UserFactory()
        self.user.save()
        self.person = create_person_with_user(self.user)
        self.tutor = TutorFactory(person=self.person)
        self.academic_year = AcademicYearFactory(year=datetime.date.today().year,
                                                 start_date=datetime.date.today())
        # Old structure model [To remove]
        self.structure = structure.StructureFactory()
        self.structure_children = structure.StructureFactory(part_of=self.structure)

        # New structure model
        entities_hierarchy = create_entities_hierarchy()
        self.root_entity = entities_hierarchy.get('root_entity')
        self.child_one_entity = entities_hierarchy.get('child_one_entity')
        self.child_two_entity = entities_hierarchy.get('child_two_entity')

        self.entity_manager = EntityManagerFactory(
            person=self.person,
            structure=self.structure,
            entity=self.root_entity)

        # Create two learning_unit_year with context (Container + EntityContainerYear)
        self.learning_unit_year = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure,
            entity=self.child_one_entity,
            acronym="LBIR1210")
        self.learning_unit_year_children = create_learning_unit_with_context(
            academic_year=self.academic_year,
            structure=self.structure_children,
            entity=self.child_two_entity,
            acronym="LBIR1211")

        self.attribution = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year,
            score_responsible=True)
        self.attribution_children = test_attribution.create_attribution(
            tutor=self.tutor,
            learning_unit_year=self.learning_unit_year_children,
            score_responsible=True)

    def test_is_faculty_admin(self):
        entities_manager = mdl_base.entity_manager.is_entity_manager(self.user)
        self.assertTrue(entities_manager)

    def test_scores_responsible(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible')
        response = self.client.get(url)
        self.assertEqual(response.status_code, 200)

    def test_scores_responsible_search_with_many_elements(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_search')
        data = {
            'course_code': 'LBIR121',
            'learning_unit_title': '',
            'tutor': self.tutor.person.last_name,
            'scores_responsible': ''
        }
        response = self.client.get(url, data=data)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context[-1]['dict_attribution']), 2)

    def test_scores_responsible_search_without_elements(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_search')
        data = {
            'course_code': '',
            'learning_unit_title': '',
            'tutor': '',
            'scores_responsible': ''
        }
        response = self.client.get(url, data=data)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(len(response.context[-1]['dict_attribution']), 2)

    def test_create_attributions_list(self):
        entities_manager = mdl_base.entity_manager.find_by_user(self.user)
        entities = [entity_manager.entity for entity_manager in entities_manager]
        entities_with_descendants = Entity.objects.filter(
            pk__in=[row['entity_id'] for row in EntityVersion.objects.get_tree(entities)])
        attributions_searched = attribution.search_scores_responsible(
            learning_unit_title=None,
            course_code=None,
            entities=entities_with_descendants,
            tutor=None,
            responsible=None
        )
        dictionary = get_attributions_list(attributions_searched, "-score_responsible")
        self.assertIsNotNone(dictionary)

    def test_scores_responsible_management(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_management')
        data = {
            'learning_unit_year': "learning_unit_year_%d" % self.learning_unit_year.id
        }
        response = self.client.get(url, data=data)
        self.assertEqual(response.status_code, 200)

    def test_scores_responsible_management_with_wrong_learning_unit_year(self):
        self.client.force_login(self.user)
        self.entity_manager.entity = EntityVersionFactory(parent=None, end_date=None).entity
        self.entity_manager.save()
        url = reverse('scores_responsible_management')
        data = {
            'learning_unit_year': "learning_unit_year_{}".format(self.learning_unit_year.id)
        }
        response = self.client.get(url, data=data)
        self.assertEqual(response.status_code, 403)

    def test_scores_responsible_add(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_add', args=[self.learning_unit_year.id])
        attribution_id = 'attribution_' + str(self.attribution.id)
        response = self.client.post(url, {"action": "add",
                                          "attribution_id": attribution_id})
        self.assertEqual(response.status_code, 302)

    def test_scores_responsible_cancel(self):
        self.client.force_login(self.user)
        url = reverse('scores_responsible_add', args=[self.learning_unit_year.id])
        attribution_id = 'attribution_' + str(self.attribution.id)
        response = self.client.post(url, {"action": "cancel",
                                          "attribution_id": attribution_id})
        self.assertEqual(response.status_code, 302)
Exemple #22
0
 def test_entity_manager_for_the_user(self):
     a_person = PersonFactory(user=self.user)
     EntityManagerFactory(person=a_person)
     self.assertTrue(entity_manager.is_entity_manager(self.user))