def setUpTestData(cls): cls.country_1 = CountryFactory(name="country_1", iso_code="C1") cls.country_2 = CountryFactory(name="country_2", iso_code="C2") cls.country_3 = CountryFactory(name="country_3", iso_code="C3") cls.academic_year_1 = AcademicYearFactory(year=2040) cls.academic_year_2 = AcademicYearFactory(current=True) cls.academic_year_3 = AcademicYearFactory(year=2041) cls.financing_1 = FinancingFactory( type__name="financing_1", academic_year=cls.academic_year_1, ) cls.financing_2 = FinancingFactory( type__name="financing_2", academic_year=cls.academic_year_1, ) cls.financing_3 = FinancingFactory( type__name="financing_3", academic_year=cls.academic_year_3, ) cls.financing_1.countries.set([cls.country_1, cls.country_2]) cls.financing_2.countries.set([cls.country_3]) cls.user = UserFactory() cls.user_adri = UserFactory() entity_version = EntityVersionFactory(acronym='ADRI') PartnershipEntityManagerFactory(entity=entity_version.entity, person__user=cls.user_adri) cls.url = reverse('partnerships:financings:export', kwargs={'year': cls.academic_year_1.year}) cls.url_empty = reverse('partnerships:financings:export')
def setUp(self): self.factory = RequestFactory() self.client = Client() self.settings = SettingsFactory() today = datetime.date.today() self.current_academic_year = AcademicYearFactory( start_date=today, end_date=today.replace(year=today.year + 1), year=today.year) self.phd_supervisor = PersonFactory() self.assistant = AcademicAssistantFactory( supervisor=self.phd_supervisor) self.assistant_mandate = AssistantMandateFactory( academic_year=self.current_academic_year, assistant=self.assistant) self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR self.assistant_mandate.save() self.review = ReviewFactory(reviewer=None, mandate=self.assistant_mandate, status=review_status.IN_PROGRESS) self.entity_version = EntityVersionFactory( entity_type=entity_type.INSTITUTE) self.mandate_entity = MandateEntityFactory( assistant_mandate=self.assistant_mandate, entity=self.entity_version.entity)
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, )
def setUp(self): today = datetime.date.today() self.faculty_user = factory_user.UserFactory() self.faculty_user.groups.add( Group.objects.get(name=FACULTY_MANAGER_GROUP)) self.faculty_person = factory_person.PersonFactory( user=self.faculty_user) self.faculty_user.user_permissions.add( Permission.objects.get(codename='can_propose_learningunit')) self.faculty_user.user_permissions.add( Permission.objects.get(codename='can_create_learningunit')) self.super_user = factory_user.SuperUserFactory() self.person = factory_person.PersonFactory(user=self.super_user) self.academic_years = GenerateAcademicYear(get_current_year(), get_current_year() + 7).academic_years self.academic_year = self.academic_years[0] self.language = LanguageFactory(code='FR') self.organization = organization_factory.OrganizationFactory( type=organization_type.MAIN) self.campus = campus_factory.CampusFactory( organization=self.organization, is_administration=True) self.entity = EntityFactory(organization=self.organization) self.entity_version = EntityVersionFactory( entity=self.entity, entity_type=entity_type.SCHOOL, start_date=today.replace(year=1900), end_date=None) PersonEntityFactory(person=self.faculty_person, entity=self.entity) PersonEntityFactory(person=self.person, entity=self.entity)
def setUp(self): self.user = UserFactory() self.user.user_permissions.add( Permission.objects.get(codename="can_access_learningunit")) self.user.user_permissions.add( Permission.objects.get(codename="can_edit_learningunit")) self.person = CentralManagerFactory(user=self.user) self.client.force_login(self.user) self.academic_year = create_current_academic_year() luy = LearningUnitYearFullFactory(academic_year=self.academic_year) self.external = ExternalLearningUnitYearFactory(learning_unit_year=luy) luy.learning_container_year.container_type = EXTERNAL luy.learning_container_year.save() EntityVersionFactory(entity=self.external.requesting_entity) PersonEntityFactory(person=self.person, entity=self.external.requesting_entity) self.data = get_valid_external_learning_unit_form_data( self.academic_year, self.person, self.external.learning_unit_year) self.url = reverse(update_learning_unit, args=[self.external.learning_unit_year.pk])
def setUpTestData(cls): cls.academic_year = create_current_academic_year() cls.education_group = EducationGroupFactory() EducationGroupYearFactory(education_group=cls.education_group, academic_year=cls.academic_year) cls.faculty_manager = PersonWithPermissionsFactory( 'view_admission', 'change_admission', groups=[TRAINING_MANAGERS_GROUP]) cls.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group) PersonTraining(person=cls.faculty_manager, training=cls.formation).save() cls.continuing_education_manager = PersonWithPermissionsFactory( 'view_admission', 'change_admission', 'validate_registration', groups=[MANAGERS_GROUP]) EntityVersionFactory(entity=cls.formation.management_entity) cls.registration_submitted = AdmissionFactory( formation=cls.formation, state=REGISTRATION_SUBMITTED, academic_year=cls.academic_year) cls.registration_validated = AdmissionFactory( formation=cls.formation, state=VALIDATED, academic_year=cls.academic_year) cls.student_worker = PersonWithPermissionsFactory( 'view_admission', 'change_received_file_state', 'validate_registration', groups=[STUDENT_WORKERS_GROUP])
def create_entity_version(an_acronym): start_date = date.today().replace(year=2010) entity_version = EntityVersionFactory(acronym=an_acronym, entity_type=FACULTY, end_date=None, start_date=start_date) return entity_version
def test_learning_units_summary_list(self, mock_render): request_factory = RequestFactory() now = datetime.datetime.now() EntityVersionFactory(entity=self.an_entity, start_date=now, end_date=datetime.datetime(now.year + 1, 9, 15), entity_type='INSTITUTE') request = request_factory.get( self.url, data={'academic_year_id': current_academic_year().id}) request.user = self.faculty_user lu = self._create_learning_unit_year_for_entity(self.an_entity) person_lu = PersonFactory() tutor_lu_1 = TutorFactory(person=person_lu) self.attribution_lu = AttributionFactory(learning_unit_year=lu, tutor=tutor_lu_1, summary_responsible=True) self._create_entity_calendar(self.an_entity) self.client.force_login(self.faculty_user) learning_units_summary_list(request) self.assertTrue(mock_render.called) request, template, context = mock_render.call_args[0] self.assertEqual(template, 'learning_units.html') self.assertEqual(context['search_type'], SUMMARY_LIST) self.assertEqual(len(context['learning_units_with_errors']), 1) self.assertTrue(context['is_faculty_manager'])
def test_create_entity_version_same_entity_same_dates(self): with self.assertRaisesMessage(AttributeError, 'EntityVersion invalid parameters'): EntityVersionFactory( entity=self.entities[0], start_date=self.start_date, end_date=self.end_date )
def setUpTestData(cls): today = datetime.date.today() FacultyManagerGroupFactory() cls.faculty_user = factory_user.UserFactory() cls.faculty_person = FacultyManagerFactory('can_propose_learningunit', 'can_create_learningunit', user=cls.faculty_user) cls.super_user = factory_user.SuperUserFactory() cls.person = factory_person.CentralManagerFactory(user=cls.super_user) start_year = AcademicYearFactory(year=get_current_year()) end_year = AcademicYearFactory(year=get_current_year() + 7) cls.academic_years = GenerateAcademicYear(start_year, end_year).academic_years cls.current_academic_year = cls.academic_years[0] cls.next_academic_year = cls.academic_years[1] generate_creation_or_end_date_proposal_calendars(cls.academic_years) cls.language = LanguageFactory(code='FR') cls.organization = organization_factory.OrganizationFactory( type=organization_type.MAIN) cls.campus = campus_factory.CampusFactory( organization=cls.organization, is_administration=True) cls.entity = EntityFactory(organization=cls.organization) cls.entity_version = EntityVersionFactory( entity=cls.entity, entity_type=entity_type.FACULTY, start_date=today.replace(year=1900), end_date=None) PersonEntityFactory(person=cls.faculty_person, entity=cls.entity) PersonEntityFactory(person=cls.person, entity=cls.entity)
def setUpTestData(cls): now = datetime.datetime.now() cls.academic_year = create_current_academic_year() cls.old_academic_year = AcademicYearFactory( year=cls.academic_year.year - 1) cls.next_academic_year = AcademicYearFactory( year=cls.academic_year.year + 1) cls.previous_academic_year = GenerateAcademicYear( cls.old_academic_year, cls.old_academic_year).academic_years[0] AcademicCalendarFactory( academic_year=cls.previous_academic_year, start_date=now - datetime.timedelta(days=5), end_date=now + datetime.timedelta(days=15), reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION) cls.requirement_entity_version = EntityVersionFactory( entity__organization__type=organization_type.MAIN, start_date=now, end_date=datetime.datetime(now.year + 1, 9, 15), entity_type=entity_type.INSTITUTE) cls.learning_unit_year = LearningUnitYearFactory( acronym="LBIR1100", academic_year=cls.academic_year, learning_container_year__academic_year=cls.academic_year, learning_container_year__acronym="LBIR1100", learning_container_year__requirement_entity=cls. requirement_entity_version.entity) cls.url = reverse('learning_units_summary') cls.faculty_person = FacultyManagerFactory( 'can_access_learningunit', 'can_edit_learningunit_pedagogy') PersonEntityFactory(person=cls.faculty_person, entity=cls.requirement_entity_version.entity)
def setUpTestData(cls): cls.settings = SettingsFactory() cls.previous_academic_year, cls.current_academic_year, _ = AcademicYearFactory.produce( ) cls.phd_supervisor = PersonFactory() cls.assistant = AcademicAssistantFactory(supervisor=cls.phd_supervisor) cls.assistant_mandate = AssistantMandateFactory( academic_year=cls.current_academic_year, assistant=cls.assistant, state=assistant_mandate_state.PHD_SUPERVISOR) cls.assistant2 = AcademicAssistantFactory(supervisor=None) cls.assistant_mandate2 = AssistantMandateFactory( academic_year=cls.current_academic_year, assistant=cls.assistant2, state=assistant_mandate_state.RESEARCH, ) cls.review = ReviewFactory(reviewer=None, mandate=cls.assistant_mandate, status=review_status.IN_PROGRESS) cls.entity_version = EntityVersionFactory( entity_type=entity_type.INSTITUTE, end_date=None) cls.mandate_entity = MandateEntityFactory( assistant_mandate=cls.assistant_mandate, entity=cls.entity_version.entity) cls.mandate_entity2 = MandateEntityFactory( assistant_mandate=cls.assistant_mandate2, entity=cls.entity_version.entity) cls.reviewer = ReviewerFactory(role=reviewer_role.RESEARCH, entity=cls.entity_version.entity, person=cls.phd_supervisor)
def test_check_postponement_conflict_on_all_sections(self): # LEARNING CONTAINER YEAR - Title modified another_learning_container_year = _build_copy( self.learning_container_year) another_learning_container_year.academic_year = self.next_academic_year another_learning_container_year.common_title = "Title Modified" another_learning_container_year.save() # LEARNING UNIT YEAR - Modify specific title another_learning_unit_year = _build_copy(self.learning_unit_year) another_learning_unit_year.academic_year = self.next_academic_year another_learning_unit_year.learning_container_year = another_learning_container_year another_learning_unit_year.specific_title = "Specific title modified" another_learning_unit_year.save() an_entity = EntityFactory() EntityVersionFactory(entity=an_entity, parent=None, end_date=None, acronym="AREC") another_learning_container_year.requirement_entity = an_entity another_learning_container_year.save() error_list = business_edition._check_postponement_conflict( self.learning_unit_year, another_learning_unit_year) self.assertIsInstance(error_list, list) self.assertEqual(len(error_list), 5)
def setUpTestData(cls): cls.user = UserFactory() cls.person = CentralManagerFactory( "can_access_learningunit", "can_edit_learningunit", user=cls.user ) person_entity = PersonEntityFactory( person=cls.person, entity=EntityVersionFactory().entity, ) cls.academic_year = create_current_academic_year() AcademicCalendarLearningUnitCentralEditionFactory( data_year=cls.academic_year, start_date=datetime.datetime(cls.academic_year.year - 6, 9, 15), end_date=datetime.datetime(cls.academic_year.year + 1, 9, 14) ) cls.luy = LearningUnitYearFullFactory( academic_year=cls.academic_year, internship_subtype=None, acronym="EFAC1000", learning_container_year__container_type=EXTERNAL, learning_container_year__requirement_entity=person_entity.entity, ) cls.data = get_valid_external_learning_unit_form_data(cls.academic_year, cls.person, cls.luy) cls.url = reverse(update_learning_unit, args=[cls.luy.pk])
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()
def setUpTestData(cls): cls.academic_year = create_current_academic_year() cls.next_academic_year = AcademicYearFactory( year=cls.academic_year.year + 1) cls.learning_container_year = LearningContainerYearFactory( academic_year=cls.academic_year, common_title='common title', ) cls.learning_unit_year = _create_learning_unit_year_with_components( cls.learning_container_year, create_lecturing_component=True, create_pratical_component=True) cls.entity_version = EntityVersionFactory(parent=None, end_date=None, acronym="DRT") cls.entity_version.refresh_from_db() cls.allocation_entity = _create_entity_container_with_components( cls.learning_unit_year, entity_container_year_link_type.ALLOCATION_ENTITY, cls.entity_version.entity) cls.requirement_entity = _create_entity_container_with_components( cls.learning_unit_year, entity_container_year_link_type.REQUIREMENT_ENTITY, cls.entity_version.entity, repartition_lecturing=Decimal(30), repartition_practical_exercises=Decimal(10)) cls.add_requirement_entity_1 = _create_entity_container_with_components( cls.learning_unit_year, entity_container_year_link_type.ADDITIONAL_REQUIREMENT_ENTITY_1, cls.entity_version.entity, repartition_lecturing=Decimal(10), repartition_practical_exercises=Decimal(5))
def setUpTestData(cls): cls.academic_year = AcademicYearFactory(year=2018) cls.education_group = EducationGroupFactory() EducationGroupYearFactory(education_group=cls.education_group, academic_year=cls.academic_year) cls.formation_1 = ContinuingEducationTrainingFactory( education_group=cls.education_group) cls.education_group = EducationGroupFactory() EducationGroupYearFactory(education_group=cls.education_group, academic_year=cls.academic_year) cls.formation_2 = ContinuingEducationTrainingFactory( education_group=cls.education_group) group = GroupFactory(name='continuing_education_managers') cls.manager = PersonWithPermissionsFactory('view_admission', 'change_admission') cls.manager.user.groups.add(group) EntityVersionFactory(entity=cls.formation_1.management_entity) cls.admission_archived = AdmissionFactory(formation=cls.formation_1, state=WAITING, archived=True) cls.admission_no_registration_required_archived = AdmissionFactory( formation=cls.formation_1, state=ACCEPTED_NO_REGISTRATION_REQUIRED, archived=True) cls.registration_1_unarchived = AdmissionFactory( formation=cls.formation_2, state=ACCEPTED, archived=False) cls.registration_2_archived = AdmissionFactory( formation=cls.formation_2, state=ACCEPTED, archived=True)
def setUp(self): self.user = UserFactory() self.user.user_permissions.add( Permission.objects.get(codename="can_access_learningunit")) self.user.user_permissions.add( Permission.objects.get(codename="can_edit_learningunit")) self.person = CentralManagerFactory(user=self.user) self.client.force_login(self.user) person_entity = PersonEntityFactory( person=self.person, entity=EntityVersionFactory().entity, ) self.academic_year = create_current_academic_year() luy = LearningUnitYearFullFactory( academic_year=self.academic_year, internship_subtype=None, acronym="EFAC0000", learning_container_year__container_type=EXTERNAL, learning_container_year__requirement_entity=person_entity.entity, ) self.external = ExternalLearningUnitYearFactory(learning_unit_year=luy) self.data = get_valid_external_learning_unit_form_data( self.academic_year, self.person, self.external.learning_unit_year) self.url = reverse(update_learning_unit, args=[self.external.learning_unit_year.pk])
def test_find_parent_of_type_itself(self): entity_v = EntityVersionFactory(entity_type=FACULTY) result = find_parent_of_type_into_entity_structure( entity_v, build_current_entity_version_structure_in_memory( timezone.now().date()), FACULTY) self.assertEqual(entity_v.entity, result)
def setUpTestData(cls): current_academic_year = create_current_academic_year() cls.proposal = ProposalLearningUnitFactory( state=proposal_state.ProposalState.ACCEPTED.name, learning_unit_year__subtype=learning_unit_year_subtypes.FULL, learning_unit_year__academic_year=current_academic_year, learning_unit_year__learning_container_year__academic_year= current_academic_year) cls.learning_unit_year = cls.proposal.learning_unit_year cls.person = PersonFactory() cls.person.user.user_permissions.add( Permission.objects.get(codename="can_access_learningunit")) cls.person.user.user_permissions.add( Permission.objects.get( codename="can_consolidate_learningunit_proposal")) person_entity = PersonEntityFactory( person=cls.person, entity=EntityContainerYearFactory( learning_container_year=cls.learning_unit_year. learning_container_year, type=entity_container_year_link_type.REQUIREMENT_ENTITY).entity ) EntityVersionFactory(entity=person_entity.entity) cls.url = reverse("learning_unit_consolidate_proposal") cls.post_data = {"learning_unit_year_id": cls.learning_unit_year.id}
def test_find_parent_of_type_without_parent(self): entity_v = EntityVersionFactory(parent=None, entity_type=SCHOOL) result = find_parent_of_type_into_entity_structure( entity_v, build_current_entity_version_structure_in_memory( timezone.now().date()), FACULTY) self.assertEqual(None, result)
def setUpTestData(cls): entities = create_entities_hierarchy() cls.faculty = entities['child_one_entity_version'] cls.child_entity = EntityFactory(country=entities['country'], organization=entities['organization']) cls.child_entity_version = EntityVersionFactory( acronym="CHILD_1_UNDER_FAC", parent=cls.faculty.entity, entity_type=SCHOOL, end_date=None, entity=cls.child_entity, start_date=entities['start_date']) cls.academic_year = create_current_academic_year() cls.education_group = EducationGroupFactory() EducationGroupYearFactory(education_group=cls.education_group, academic_year=cls.academic_year, management_entity=cls.child_entity) cls.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group, ) cls.admission = AdmissionFactory(formation=cls.formation, awareness_ucl_website=False, awareness_formation_website=False, awareness_press=False, awareness_facebook=True, awareness_linkedin=False, awareness_customized_mail=False, awareness_emailing=False, awareness_other='Other awareness', awareness_word_of_mouth=False, awareness_friends=False, awareness_former_students=False, awareness_moocs=False)
def setUpTestData(cls): current_academic_year = create_current_academic_year() cls.aca_calendar = AcademicCalendarFactory( academic_year=current_academic_year, reference=SUMMARY_COURSE_SUBMISSION) cls.entity_version = EntityVersionFactory()
def setUpTestData(cls): anac = AcademicYearFactory() requirement_entity = EntityFactory() EntityVersionFactory( start_date=AcademicYearFactory(year=anac.year - 1).start_date, end_date=AcademicYearFactory(year=anac.year + 1).end_date, entity=requirement_entity) luy = LearningUnitYearFactory( academic_year=anac, learning_container_year__requirement_entity=requirement_entity) ExternalLearningUnitYearFactory(learning_unit_year=luy) cls.luy = LearningUnitYear.objects.filter( pk=luy.pk).annotate_full_title().get() setattr(cls.luy, "entity_requirement", "OSIS") setattr(cls.luy, "entity_allocation", "OSIS") url_kwargs = { 'acronym': cls.luy.acronym, 'year': cls.luy.academic_year.year } url = reverse('learning_unit_api_v1:learningunits_read', kwargs=url_kwargs) cls.serializer = ExternalLearningUnitDetailedSerializer( cls.luy, context={ 'request': RequestFactory().get(url), 'language': settings.LANGUAGE_CODE_EN })
def _create_entity_and_version_related_to(organization, acronym, parent=None): entity = EntityFactory(organization=organization) EntityVersionFactory(acronym=acronym, entity=entity, parent=parent, end_date=None) return entity
def setUp(self): current_academic_year = create_current_academic_year() an_organization = OrganizationFactory(type=organization_type.MAIN) learning_container_year = LearningContainerYearFactory( academic_year=current_academic_year, container_type=learning_container_year_types.COURSE, ) self.learning_unit_year = LearningUnitYearFakerFactory( credits=5, subtype=learning_unit_year_subtypes.FULL, academic_year=current_academic_year, learning_container_year=learning_container_year, campus=CampusFactory(organization=an_organization, is_administration=True)) self.entity_container_year = EntityContainerYearFactory( learning_container_year=self.learning_unit_year. learning_container_year, type=entity_container_year_link_type.REQUIREMENT_ENTITY) today = datetime.date.today() an_entity = EntityFactory(organization=an_organization) self.entity_version = EntityVersionFactory( entity=an_entity, entity_type=entity_type.SCHOOL, start_date=today, end_date=today.replace(year=today.year + 1))
def setUpTestData(cls): cls.current_academic_year = create_current_academic_year() cls.academic_calendar = AcademicCalendarFactory( academic_year=cls.current_academic_year, reference=academic_calendar_type.SUMMARY_COURSE_SUBMISSION, start_date=datetime.date(timezone.now().year - 1, 9, 30), end_date=datetime.date(timezone.now().year + 1, 9, 30)) cls.academic_year_in_future = AcademicYearFactory( year=cls.current_academic_year.year + 1) cls.learning_unit_year = LearningUnitYearFactory( subtype=FULL, academic_year=cls.academic_year_in_future, learning_container_year__academic_year=cls.academic_year_in_future, summary_locked=False) a_valid_entity_version = EntityVersionFactory(entity_type=FACULTY) EntityContainerYearFactory( learning_container_year=cls.learning_unit_year. learning_container_year, entity=a_valid_entity_version.entity, type=entity_container_year_link_type.REQUIREMENT_ENTITY) cls.tutor = _get_tutor() # Add attribution to course [set summary responsible] AttributionFactory( tutor=cls.tutor, summary_responsible=True, learning_unit_year=cls.learning_unit_year, )
def test_learning_units_summary_list(self): now = datetime.datetime.now() EntityVersionFactory(entity=self.an_entity, start_date=now, end_date=datetime.datetime(now.year + 1, 9, 15), entity_type='INSTITUTE') lu = self._create_learning_unit_year_for_entity( self.an_entity, "LBIR1100") person_lu = PersonFactory() tutor_lu_1 = TutorFactory(person=person_lu) self.attribution_lu = AttributionFactory(learning_unit_year=lu, tutor=tutor_lu_1, summary_responsible=True) self._create_entity_calendar(self.an_entity) self.client.force_login(self.faculty_user) response = self.client.get( self.url, data={'academic_year_id': starting_academic_year().id}) self.assertTemplateUsed(response, 'learning_units.html') context = response.context self.assertEqual(context['search_type'], SUMMARY_LIST) self.assertEqual(context['learning_units_count'], 1) self.assertTrue(context['is_faculty_manager'])
def setUp(self): today = datetime.date.today() self.faculty_user = factory_user.UserFactory() self.faculty_user.groups.add( Group.objects.get(name=FACULTY_MANAGER_GROUP)) self.faculty_person = factory_person.PersonFactory( user=self.faculty_user) self.faculty_user.user_permissions.add( Permission.objects.get(codename='can_propose_learningunit')) self.faculty_user.user_permissions.add( Permission.objects.get(codename='can_create_learningunit')) self.super_user = factory_user.SuperUserFactory() self.person = factory_person.PersonFactory(user=self.super_user) self.academic_year = AcademicYearFactory.build( start_date=today.replace(year=today.year + 1), end_date=today.replace(year=today.year + 2), year=today.year + 1) super(AcademicYear, self.academic_year).save() self.language = LanguageFactory(code='FR') self.organization = organization_factory.OrganizationFactory( type=organization_type.MAIN) self.campus = campus_factory.CampusFactory( organization=self.organization, is_administration=True) self.entity = EntityFactory(organization=self.organization) self.entity_version = EntityVersionFactory( entity=self.entity, entity_type=entity_type.SCHOOL, start_date=today - datetime.timedelta(days=1), end_date=today.replace(year=today.year + 1)) PersonEntityFactory(person=self.faculty_person, entity=self.entity)
def test_learning_unit_with_faculty_manager_when_cannot_edit_end_date( self): learning_container_year = LearningContainerYearFactory( academic_year=self.current_academic_year, container_type=learning_container_year_types.COURSE, requirement_entity=EntityFactory(), ) learning_unit_year = LearningUnitYearFactory( academic_year=self.current_academic_year, learning_container_year=learning_container_year, subtype=learning_unit_year_subtypes.FULL) EntityVersionFactory(entity=learning_container_year.requirement_entity) learning_unit_year.learning_unit.end_year = None learning_unit_year.learning_unit.save() managers = [ FacultyManagerFactory('can_access_learningunit'), ] for manager in managers: PersonEntityFactory( entity=learning_container_year.requirement_entity, person=manager) url = reverse("learning_unit", args=[learning_unit_year.id]) self.client.force_login(manager.user) response = self.client.get(url) self.assertEqual(response.context["can_edit_date"], False)
def setUp(self): self.factory = RequestFactory() self.client = Client() self.settings = SettingsFactory() today = datetime.date.today() self.current_academic_year = AcademicYearFactory(start_date=today, end_date=today.replace(year=today.year + 1), year=today.year) self.phd_supervisor = PersonFactory() self.assistant = AcademicAssistantFactory(supervisor=self.phd_supervisor) self.assistant_mandate = AssistantMandateFactory(academic_year=self.current_academic_year, assistant=self.assistant) self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR self.assistant_mandate.save() self.review = ReviewFactory(reviewer=None, mandate=self.assistant_mandate, status=review_status.IN_PROGRESS) self.entity1 = EntityFactory() self.entity_version1 = EntityVersionFactory(entity=self.entity1, entity_type=entity_type.INSTITUTE) self.mandate_entity = MandateEntityFactory(assistant_mandate=self.assistant_mandate, entity=self.entity1)
class PhdSupervisorReviewViewTestCase(TestCase): def setUp(self): self.factory = RequestFactory() self.client = Client() self.settings = SettingsFactory() today = datetime.date.today() self.current_academic_year = AcademicYearFactory(start_date=today, end_date=today.replace(year=today.year + 1), year=today.year) self.phd_supervisor = PersonFactory() self.assistant = AcademicAssistantFactory(supervisor=self.phd_supervisor) self.assistant_mandate = AssistantMandateFactory(academic_year=self.current_academic_year, assistant=self.assistant) self.assistant_mandate.state = assistant_mandate_state.PHD_SUPERVISOR self.assistant_mandate.save() self.review = ReviewFactory(reviewer=None, mandate=self.assistant_mandate, status=review_status.IN_PROGRESS) self.entity1 = EntityFactory() self.entity_version1 = EntityVersionFactory(entity=self.entity1, entity_type=entity_type.INSTITUTE) self.mandate_entity = MandateEntityFactory(assistant_mandate=self.assistant_mandate, entity=self.entity1) def test_generate_phd_supervisor_menu_tabs(self): self.client.force_login(self.phd_supervisor) # Review has not been completed -> supervisor can edit self.assertEqual(generate_phd_supervisor_menu_tabs(self.assistant_mandate, None), [{'item': assistant_mandate_state.PHD_SUPERVISOR, 'class': '', 'action': 'edit'}]) self.assertEqual(generate_phd_supervisor_menu_tabs(self.assistant_mandate, assistant_mandate_state.PHD_SUPERVISOR), [{'item': assistant_mandate_state.PHD_SUPERVISOR, 'class': 'active', 'action': 'edit'}]) # Review has been completed -> supervisor can only view his review self.review.status = review_status.DONE self.review.save() self.assistant_mandate.state = assistant_mandate_state.RESEARCH self.assistant_mandate.save() self.assertEqual(generate_phd_supervisor_menu_tabs(self.assistant_mandate, None), [{'item': assistant_mandate_state.PHD_SUPERVISOR, 'class': '', 'action': 'view'}]) self.assertEqual(generate_phd_supervisor_menu_tabs(self.assistant_mandate, assistant_mandate_state.PHD_SUPERVISOR), [{'item': assistant_mandate_state.PHD_SUPERVISOR, 'class': 'active', 'action': 'view'}]) def test_pst_form_view(self): self.client.force_login(self.phd_supervisor.user) response = self.client.post('/assistants/phd_supervisor/pst_form/', {'mandate_id': self.assistant_mandate.id}) self.assertEqual(response.status_code, HTTP_OK) def test_review_view(self): self.client.force_login(self.phd_supervisor.user) response = self.client.post('/assistants/phd_supervisor/review/view/', {'mandate_id': self.assistant_mandate.id}) self.assertEqual(response.status_code, HTTP_OK) def test_review_edit(self): self.client.force_login(self.phd_supervisor.user) response = self.client.post('/assistants/phd_supervisor/review/edit/', {'mandate_id': self.assistant_mandate.id}) self.assertEqual(response.status_code, HTTP_OK) self.review.status = review_status.DONE self.review.save() response = self.client.post('/assistants/phd_supervisor/review/edit/',{'mandate_id': self.assistant_mandate.id}) self.assertEqual(response.status_code, HTTP_FOUND) def test_review_save(self): self.client.force_login(self.phd_supervisor.user) response = self.client.post('/assistants/phd_supervisor/review/save/', {'mandate_id': self.assistant_mandate.id, 'review_id': self.review.id }) self.assertEqual(response.status_code, HTTP_OK) def test_validate_review_and_update_mandate(self): validate_review_and_update_mandate(self.review, self.assistant_mandate) self.assertEqual(self.review.status, review_status.DONE) self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.RESEARCH) self.entity_version1.entity_type = entity_type.POLE self.entity_version1.save() validate_review_and_update_mandate(self.review, self.assistant_mandate) self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.RESEARCH) self.entity_version1.entity_type = entity_type.FACULTY self.entity_version1.save() validate_review_and_update_mandate(self.review, self.assistant_mandate) self.assertEqual(self.assistant_mandate.state, assistant_mandate_state.SUPERVISION)