Exemple #1
0
 def test_learning_unit_proposal_form_get_as_central_manager_with_instance(
         self):
     self.person.user.groups.add(
         Group.objects.get(name=CENTRAL_MANAGER_GROUP))
     proposal = ProposalLearningUnitFactory(
         learning_unit_year=self.learning_unit_year,
         state=ProposalState.FACULTY.name,
         entity=self.entity_version.entity)
     form = ProposalBaseForm(self.form_data,
                             self.person,
                             self.learning_unit_year,
                             proposal=proposal)
     self.assertFalse(form.fields['state'].disabled)
     self.assertEqual(form.fields['state'].initial,
                      ProposalState.FACULTY.name)
Exemple #2
0
 def test_creation_proposal_learning_unit_with_not_linked_entity(self):
     self.person_entity.entity = self.an_entity_school
     self.person_entity.save()
     form = ProposalBaseForm(self.form_data, self.person,
                             self.learning_unit_year)
     self.assertTrue('entity' in form.errors[1])
Exemple #3
0
 def test_creation_proposal_learning_unit_with_school_entity(self):
     self.entity_version.entity_type = SCHOOL
     self.entity_version.save()
     form = ProposalBaseForm(self.form_data, self.person,
                             self.learning_unit_year)
     self.assertTrue('entity' in form.errors[0])
Exemple #4
0
 def test_learning_unit_proposal_form_get_as_central_manager(self):
     self.person.user.groups.add(
         Group.objects.get(name=CENTRAL_MANAGER_GROUP))
     form = ProposalBaseForm(self.form_data, self.person,
                             self.learning_unit_year)
     self.assertFalse(form.fields['state'].disabled)
Exemple #5
0
 def test_learning_unit_proposal_form_get_as_faculty_manager(self):
     self.person.user.groups.add(
         Group.objects.get(name=FACULTY_MANAGER_GROUP))
     form = ProposalBaseForm(self.form_data, self.person,
                             self.learning_unit_year)
     self.assertTrue(form.fields['state'].disabled)
    def test_creation_proposal_learning_unit(self):
        initial_data_expected = {
            "learning_container_year": {
                "id":
                self.learning_unit_year.learning_container_year.id,
                "acronym":
                self.learning_unit_year.acronym,
                "common_title":
                self.learning_unit_year.learning_container_year.common_title,
                "container_type":
                self.learning_unit_year.learning_container_year.container_type,
                "in_charge":
                self.learning_unit_year.learning_container_year.in_charge,
                "team":
                self.learning_unit_year.learning_container_year.team,
                "common_title_english":
                self.learning_unit_year.learning_container_year.
                common_title_english,
                "is_vacant":
                self.learning_unit_year.learning_container_year.is_vacant,
                "type_declaration_vacant":
                self.learning_unit_year.learning_container_year.
                type_declaration_vacant,
            },
            "learning_unit_year": {
                "id":
                self.learning_unit_year.id,
                "acronym":
                self.learning_unit_year.acronym,
                "specific_title":
                self.learning_unit_year.specific_title,
                "internship_subtype":
                self.learning_unit_year.internship_subtype,
                "language":
                self.learning_unit_year.language.pk,
                "credits":
                self.learning_unit_year.credits,
                "campus":
                self.learning_unit_year.campus.id,
                "periodicity":
                self.learning_unit_year.periodicity,
                "status":
                self.learning_unit_year.status,
                "session":
                self.learning_unit_year.session,
                "quadrimester":
                self.learning_unit_year.quadrimester,
                "specific_title_english":
                self.learning_unit_year.specific_title_english,
                "professional_integration":
                self.learning_unit_year.professional_integration,
                "attribution_procedure":
                self.learning_unit_year.attribution_procedure,
            },
            "learning_unit": {
                "id":
                self.learning_unit_year.learning_unit.id,
                'end_year':
                self.learning_unit_year.learning_unit.end_year,
                "other_remark":
                self.learning_unit_year.learning_unit.other_remark,
                "faculty_remark":
                self.learning_unit_year.learning_unit.faculty_remark,
            },
            "entities": {
                entity_container_year_link_type.REQUIREMENT_ENTITY:
                self.entity_container_year.entity.id,
                entity_container_year_link_type.ALLOCATION_ENTITY:
                None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1:
                None,
                entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_2:
                None
            },
            "learning_component_years": []
        }

        form = ProposalBaseForm(self.form_data, self.person,
                                self.learning_unit_year)
        self.assertTrue(form.is_valid(), form.errors)
        form.save()

        a_proposal_learning_unt = proposal_learning_unit.find_by_learning_unit_year(
            self.learning_unit_year)

        self.assertEqual(a_proposal_learning_unt.type, PROPOSAL_TYPE)
        self.assertEqual(a_proposal_learning_unt.state, PROPOSAL_STATE)
        self.assertEqual(a_proposal_learning_unt.author, self.person)
        self.assertDictEqual(a_proposal_learning_unt.initial_data,
                             initial_data_expected)