def test_li_edit_date_person_test_is_eligible_to_modify_end_date_based_on_container_type( self): lu = LearningUnitFactory(existing_proposal_in_epc=False) learning_unit_year_without_proposal = LearningUnitYearFactory( academic_year=self.academic_year, subtype=learning_unit_year_subtypes.FULL, learning_unit=lu, learning_container_year=self.lcy) person_faculty_manager = FacultyManagerFactory() PersonEntityFactory(person=person_faculty_manager, entity=self.entity_container_yr.entity) self.context['user'] = person_faculty_manager.user self.context[ 'learning_unit_year'] = learning_unit_year_without_proposal result = li_edit_date_lu(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected(ID_LINK_EDIT_DATE_LU, MSG_NO_ELIGIBLE_TO_MODIFY_END_DATE)) # allowed if _is_person_central_manager or # _is_learning_unit_year_a_partim or # negation(_is_container_type_course_dissertation_or_internship), # test 1st condition true self.context['user'] = self.central_manager_person.user result = li_edit_date_lu(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected(ID_LINK_EDIT_DATE_LU, url=self.url_edit)) # test 2nd condition true self.context['user'] = person_faculty_manager.user learning_unit_year_without_proposal.subtype = learning_unit_year_subtypes.PARTIM learning_unit_year_without_proposal.save() self.context[ 'learning_unit_year'] = learning_unit_year_without_proposal self.assertEqual( li_edit_date_lu(self.context, self.url_edit, ""), self._get_result_data_expected(ID_LINK_EDIT_DATE_LU, url=self.url_edit)) # test 3rd condition true learning_unit_year_without_proposal.learning_container_year.container_type = learning_container_year_types.OTHER_COLLECTIVE learning_unit_year_without_proposal.learning_container_year.save() learning_unit_year_without_proposal.subtype = learning_unit_year_subtypes.FULL learning_unit_year_without_proposal.save() self.context[ 'learning_unit_year'] = learning_unit_year_without_proposal self.assertEqual( li_edit_date_lu(self.context, self.url_edit, ""), self._get_result_data_expected(ID_LINK_EDIT_DATE_LU, url=self.url_edit))
def test_li_edit_lu_everything_ok(self): result = li_edit_lu(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected(ID_LINK_EDIT_LU, url=self.url_edit)) result = li_edit_date_lu(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected(ID_LINK_EDIT_DATE_LU, url=self.url_edit))
def test_li_edit_lu_year_is_editable_but_existing_proposal_in_epc(self): self.learning_unit.existing_proposal_in_epc = True self.learning_unit.save() self.context["learning_unit_year"] = self.learning_unit_year result = li_edit_lu(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected(ID_LINK_EDIT_LU, MSG_EXISTING_PROPOSAL_IN_EPC)) result = li_edit_date_lu(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected(ID_LINK_EDIT_DATE_LU, MSG_EXISTING_PROPOSAL_IN_EPC)) result = li_delete_all_lu(self.context, self.url_edit, '', "#modalDeleteLuy") expected = self._get_result_data_expected_delete( "link_delete_lus", MSG_EXISTING_PROPOSAL_IN_EPC) self.assertEqual(result, expected) self.proposal.learning_unit_year = self.learning_unit_year self.proposal.save() self.context["proposal"] = self.proposal result = li_suppression_proposal(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected_for_proposal_suppression( "link_proposal_suppression", MSG_EXISTING_PROPOSAL_IN_EPC, DISABLED)) result = li_modification_proposal(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected( "link_proposal_modification", MSG_EXISTING_PROPOSAL_IN_EPC, ))
def test_li_edit_date_person_test_is_eligible_to_modify_end_date_based_on_container_type( self): lu = LearningUnitFactory(existing_proposal_in_epc=False) learning_unit_year_without_proposal = LearningUnitYearFactory( academic_year=self.current_academic_year, learning_unit=lu, ) person_faculty_managers = [ create_person_with_permission_and_group(FACULTY_MANAGER_GROUP, 'can_edit_learningunit'), create_person_with_permission_and_group(UE_FACULTY_MANAGER_GROUP, 'can_edit_learningunit') ] for manager in person_faculty_managers: manager.user.user_permissions.add( Permission.objects.get(codename='can_edit_learningunit_date')) learning_unit_year_without_proposal.subtype = learning_unit_year_subtypes.FULL learning_unit_year_without_proposal.learning_container_year = self.lcy learning_unit_year_without_proposal.learning_container_year.container_type = learning_container_year_types.COURSE learning_unit_year_without_proposal.learning_container_year.save() learning_unit_year_without_proposal.save() PersonEntityFactory( person=manager, entity=self.requirement_entity, ) self.context['user'] = manager.user self.context[ 'learning_unit_year'] = learning_unit_year_without_proposal result = li_edit_date_lu(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected( ID_LINK_EDIT_DATE_LU, MSG_NO_ELIGIBLE_TO_MODIFY_END_DATE)) # allowed if _is_person_central_manager or # _is_learning_unit_year_a_partim or # negation(_is_container_type_course_dissertation_or_internship), # test 1st condition true self.context['user'] = self.central_manager_person.user result = li_edit_date_lu(self.context, self.url_edit, "") self.assertEqual( result, self._get_result_data_expected(ID_LINK_EDIT_DATE_LU, url=self.url_edit)) # test 2nd condition true self.context['user'] = manager.user learning_unit_year_without_proposal.subtype = learning_unit_year_subtypes.PARTIM learning_unit_year_without_proposal.save() self.context[ 'learning_unit_year'] = learning_unit_year_without_proposal self.assertEqual( li_edit_date_lu(self.context, self.url_edit, ""), self._get_result_data_expected(ID_LINK_EDIT_DATE_LU, url=self.url_edit)) # test 3rd condition true learning_unit_year_without_proposal.learning_container_year.container_type = learning_container_year_types.OTHER_COLLECTIVE learning_unit_year_without_proposal.learning_container_year.save() learning_unit_year_without_proposal.subtype = learning_unit_year_subtypes.FULL learning_unit_year_without_proposal.save() self.context[ 'learning_unit_year'] = learning_unit_year_without_proposal self.assertEqual( li_edit_date_lu(self.context, self.url_edit, ""), self._get_result_data_expected(ID_LINK_EDIT_DATE_LU, url=self.url_edit))