def test_find_by_student(self): Group.objects.create(name='students') a_student = StudentFactory() an_offer_year = OfferYearFactory(offer=self.offer) OfferEnrollmentFactory(offer_year=an_offer_year, student=a_student, date_enrollment=datetime.datetime( an_offer_year.academic_year.year + 1, 2, 1)) self.assertListEqual(list(mdl_offer.find_by_student(a_student)), [self.offer])
def _create_internship_students(cls): internship_students = [ InternshipStudentInformationFactory(cohort=cls.cohort, person=PersonFactory()) for _ in range(0, N_STUDENTS) ] students = [ StudentFactory(person=student.person) for student in internship_students ] return students
class TestModelStudent(TestCase): def setUp(self): Group.objects.create(name='students') self.student = StudentFactory() def test_email(self): self.student.person.user.email = "*****@*****.**" self.student.person.user.save() self.assertEqual(self.student.email(), self.student.person.user.email) self.student.person.user = None self.student.person.save() self.assertEqual(self.student.email(), self.student.person.email) def test_find_by_registration_id(self): student = mdl_student.find_by_registration_id(self.student.registration_id) self.assertEqual(student, self.student) def test_search(self): self.assertEqual(mdl_student.search(), None) self.assertListEqual(list(mdl_student.search(registration_id=self.student.registration_id[:5])), [self.student]) self.assertListEqual(list(mdl_student.search(person_name=self.student.person.last_name)), [self.student]) self.assertListEqual(list(mdl_student.search(person_username=self.student.person.user.username)), [self.student]) self.assertListEqual(list(mdl_student.search(person_first_name=self.student.person.first_name)), [self.student]) self.assertListEqual(list(mdl_student.search(registration_id=self.student.registration_id, full_registration=True)), [self.student]) def test_is_student(self): a_person = PersonFactory() self.assertFalse(mdl_student.is_student(a_person.user)) self.assertTrue(mdl_student.is_student(self.student.person.user))
def setUpTestData(cls): cls.person_manager = PersonFactory() cls.person_manager2 = PersonFactory() cls.manager = AdviserManagerFactory(person=cls.person_manager) cls.manager2 = AdviserManagerFactory(person=cls.person_manager2) cls.a_person_teacher = PersonFactory(first_name='Pierre', last_name='Dupont') cls.teacher = AdviserTeacherFactory(person=cls.a_person_teacher) cls.a_person_teacher2 = PersonFactory(first_name='Marco', last_name='Millet') cls.teacher2 = AdviserTeacherFactory(person=cls.a_person_teacher2) cls.teacher3 = AdviserTeacherFactory() cls.teacher4 = AdviserTeacherFactory() a_person_student = PersonWithoutUserFactory(last_name="Durant") cls.student = StudentFactory(person=a_person_student) cls.offer1 = EducationGroupFactory() cls.offer2 = EducationGroupFactory() cls.academic_year1 = AcademicYearFactory() cls.academic_year2 = AcademicYearFactory(year=cls.academic_year1.year - 1) cls.education_group_year1 = EducationGroupYearFactory( acronym="test_offer1", education_group=cls.offer1, academic_year=cls.academic_year1) cls.offer_proposition1 = OfferPropositionFactory( education_group=cls.offer1, global_email_to_commission=True, evaluation_first_year=True) cls.offer_proposition2 = OfferPropositionFactory( education_group=cls.offer2, global_email_to_commission=False) cls.proposition_dissertation = PropositionDissertationFactory( author=cls.teacher, creator=cls.a_person_teacher, title='Proposition 1212121') cls.faculty_adviser1 = FacultyAdviserFactory( adviser=cls.manager, education_group=cls.offer1) cls.faculty_adviser2 = FacultyAdviserFactory( adviser=cls.manager, education_group=cls.offer2) cls.dissertation1 = DissertationFactory( author=cls.student, title='Dissertation_test_email', education_group_year=cls.education_group_year1, proposition_dissertation=cls.proposition_dissertation, status='DIR_SUBMIT', active=True, dissertation_role__adviser=cls.teacher, dissertation_role__status='PROMOTEUR') DissertationRoleFactory(adviser=cls.teacher2, status='CO_PROMOTEUR', dissertation=cls.dissertation1) DissertationRoleFactory(adviser=cls.teacher3, status='READER', dissertation=cls.dissertation1)
def setUpTestData(cls): cls.valid_grade = 'D' cls.not_valid_grade = 'A' cls.na_grade = 'E' cls.apd_index = 0 cls.exception_apd_index = 7 cls.exception_valid_grade = 'B' cls.cohort = CohortFactory() cls.good_student = StudentFactory() cls.score = ScoreFactory( student_affectation__period__cohort=cls.cohort, student_affectation__student=cls.good_student, APD_1='D') cls.bad_student = StudentFactory() cls.score = ScoreFactory( student_affectation__period__cohort=cls.cohort, student_affectation__student=cls.bad_student, APD_1='A')
def setUp(self): students_group = Group.objects.create(name="students") permission = Permission.objects.get(codename="is_student") students_group.permissions.add(permission) self.student = StudentFactory() self.student_performance = StudentPerformanceFactory( registration_id=self.student.registration_id) self.url = reverse('performance_student_result', args=[self.student_performance.pk]) self.client.force_login(self.student.person.user)
def setUp(self): self.person = PersonFactory() self.person.user.user_permissions.add( Permission.objects.get(codename="is_faculty_administrator")) Group.objects.create(name="students") self.student = StudentFactory() self.student_performance = StudentPerformanceFactory( registration_id=self.student.registration_id) self.url = reverse('performance_administration') self.client.force_login(self.person.user)
def setUp(self): self.academic_year = AcademicYearFactory() self.offer_year = OfferYearFactory(academic_year=self.academic_year) self.learning_unit_year = LearningUnitYearFactory(academic_year=self.academic_year, acronym="LBIR1100", decimal_scores=False) # Create tutor and score responsible _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Alibra', first_name='Paul')) _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Durant', first_name='Thomas'), is_score_responsible=True) _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Lobradi', first_name='Pierre')) self.session_exam = SessionExamFactory(number_session=1, learning_unit_year=self.learning_unit_year) # Create three students and enrol them to learning unit year self.student_1 = StudentFactory(person=PersonFactory(last_name='Dupont', first_name='Jacques')) self.student_2 = StudentFactory(person=PersonFactory(last_name='Dupont', first_name='Axel')) self.student_3 = StudentFactory(person=PersonFactory(last_name='Armand', first_name='Zoe')) self.deadline = datetime.datetime(2017, 3, 1) self._build_enrollment([self.student_1, self.student_2, self.student_3], enrollment_states.ENROLLED) self.student_not_enrolled = StudentFactory(person=PersonFactory(last_name='Armand', first_name='Zoe')) self._build_enrollment([self.student_not_enrolled], enrollment_states.NOT_ENROLLED)
def test_multiple_students_objects_for_one_user(self): StudentFactory(person=self.student.person) response = self.client.get(self.url) self.assertTemplateUsed(response, 'dashboard.html') messages = list(response.context['messages']) self.assertEqual(len(messages), 1) self.assertEqual(messages[0].tags, 'error') self.assertEqual(messages[0].message, _('error_multiple_registration_id'))
def test_find_by_offers_and_academic_year(self): tmp_student = StudentFactory() tmp_offer = OfferFactory() tmp_academic_year = AcademicYearFactory() tmp_offer_year = OfferYearFactory(offer=tmp_offer, academic_year=tmp_academic_year) OfferEnrollmentFactory.create(offer_year=tmp_offer_year, student=tmp_student) db_student = list( student.find_by_offers_and_academic_year([tmp_offer], tmp_academic_year))[0] self.assertIsNotNone(db_student) self.assertEqual(db_student, tmp_student)
def test_when_no_attestation_pdf(self, mock_fetch_student_attestation): StudentFactory(person=PersonFactory(global_id=STUDENT_GLOBAL_ID)) self.client.force_login(self.person.user) response = self.client.get(self.url, follow=True) self.assertTrue(mock_fetch_student_attestation.called) self.assertTemplateUsed(response, "attestation_home_admin.html") messages = list(response.context['messages']) self.assertEqual(len(messages), 1) self.assertEqual(messages[0].tags, 'error') self.assertEqual(messages[0].message, _('error_fetching_attestation'))
def test_when_attestation_pdf_fetched(self, mock_fetch_student_attestation): StudentFactory(person=self.person) self.client.force_login(self.person.user) response = self.client.get(self.url, follow=True) self.assertTrue(mock_fetch_student_attestation.called) self.assertEqual(response['Content-Type'], 'application/pdf') self.assertEqual( response['Content-Disposition'], 'attachment; filename="{}.pdf"'.format(self.attestation_type)) self.assertEqual(response.content.decode(), str(open_sample_pdf()))
def create_student(self, user=None): """ Create a student object with all related objects and permissions :return: The student """ if user: person = PersonFactory(user=user) else: person = PersonFactory() student = StudentFactory(person=person) students_group = self.create_students_group() students_group.user_set.add(person.user) return student
def setUp(self): academic_year = AcademicYearFactory(year=datetime.datetime.now().year) offer_year = OfferYearFactory(academic_year=academic_year) student_1 = StudentFactory( person=PersonFactory(last_name='Durant', first_name='Thomas')) student_2 = StudentFactory( person=PersonFactory(last_name='Dupont', first_name='Raph')) student_3 = StudentFactory( person=PersonFactory(last_name='Duclou', first_name='Paul')) offer_enrollement_1 = OfferEnrollmentFactory(offer_year=offer_year, student=student_1) offer_enrollement_2 = OfferEnrollmentFactory(offer_year=offer_year, student=student_2) offer_enrollement_3 = OfferEnrollmentFactory(offer_year=offer_year, student=student_3) self.l_unit_year = LearningUnitYearFactory(academic_year=academic_year) LearningUnitEnrollmentFactory(learning_unit_year=self.l_unit_year, offer_enrollment=offer_enrollement_1) LearningUnitEnrollmentFactory(learning_unit_year=self.l_unit_year, offer_enrollment=offer_enrollement_2) LearningUnitEnrollmentFactory(learning_unit_year=self.l_unit_year, offer_enrollment=offer_enrollement_3)
def setUp(self): self.request_factory = RequestFactory() academic_year = _get_academic_year(year=2017) academic_calendar = AcademicCalendarFactory( title="Submission of score encoding - 1", start_date=academic_year.start_date, end_date=academic_year.end_date, academic_year=academic_year, reference=academic_calendar_type.SCORES_EXAM_SUBMISSION) SessionExamCalendarFactory(academic_calendar=academic_calendar, number_session=number_session.ONE) self.learning_unit_year = LearningUnitYearFactory( academic_year=academic_year) self.offer_year = test_offer_year.create_offer_year( 'SINF1BA', 'Bachelor in informatica', academic_year) self.session_exam = test_session_exam.create_session_exam( number_session.ONE, self.learning_unit_year, self.offer_year) # Create enrollment related self.enrollments = [] for index in range(0, 2): offer_year = OfferYearFactory(academic_year=academic_year) OfferYearCalendarFactory(academic_calendar=academic_calendar, offer_year=offer_year) offer_enrollment = test_offer_enrollment.create_offer_enrollment( StudentFactory(), offer_year) learning_unit_enrollment = test_learning_unit_enrollment.create_learning_unit_enrollment( offer_enrollment=offer_enrollment, learning_unit_year=self.learning_unit_year) exam_enrollment = test_exam_enrollment.create_exam_enrollment( self.session_exam, learning_unit_enrollment) self.enrollments.append(exam_enrollment) self.tutor = TutorFactory() test_attribution.create_attribution( tutor=self.tutor, learning_unit_year=self.learning_unit_year) add_permission(self.tutor.person.user, "can_access_scoreencoding") offer_year = self.enrollments[ 0].learning_unit_enrollment.offer_enrollment.offer_year self.program_manager_1 = ProgramManagerFactory(offer_year=offer_year) add_permission(self.program_manager_1.person.user, "can_access_scoreencoding") offer_year = self.enrollments[ 1].learning_unit_enrollment.offer_enrollment.offer_year self.program_manager_2 = ProgramManagerFactory(offer_year=offer_year) add_permission(self.program_manager_2.person.user, "can_access_scoreencoding")
def generate_exam_enrollments(year, with_different_offer=False): number_enrollments = 2 academic_year = AcademicYearFactory(year=year) an_academic_calendar = AcademicCalendarFactory( academic_year=academic_year, start_date=(datetime.datetime.today() - datetime.timedelta(days=20)).date(), end_date=(datetime.datetime.today() + datetime.timedelta(days=20)).date(), reference=academic_calendar_type.SCORES_EXAM_SUBMISSION) session_exam_calendar = SessionExamCalendarFactory( number_session=number_session.ONE, academic_calendar=an_academic_calendar) learning_unit_year = LearningUnitYearFakerFactory( academic_year=academic_year, learning_container_year__academic_year=academic_year, acronym=LEARNING_UNIT_ACRONYM) attribution = AttributionFactory(learning_unit_year=learning_unit_year) if with_different_offer: session_exams = [ SessionExamFactory(number_session=number_session.ONE, learning_unit_year=learning_unit_year, offer_year__academic_year=academic_year) for _ in range(0, number_enrollments) ] else: session_exams = [ SessionExamFactory(number_session=number_session.ONE, learning_unit_year=learning_unit_year, offer_year__academic_year=academic_year) ] * number_enrollments offer_years = [session_exam.offer_year for session_exam in session_exams] exam_enrollments = list() for i in range(0, number_enrollments): student = StudentFactory() offer_enrollment = OfferEnrollmentFactory(offer_year=offer_years[i], student=student) learning_unit_enrollment = LearningUnitEnrollmentFactory( learning_unit_year=learning_unit_year, offer_enrollment=offer_enrollment) exam_enrollments.append( ExamEnrollmentFactory( session_exam=session_exams[i], learning_unit_enrollment=learning_unit_enrollment, enrollment_state=exam_enrollment_state.ENROLLED, date_enrollment=an_academic_calendar.start_date)) return locals()
def setUp(self): self.academic_year = AcademicYearFactory() self.offer_year = OfferYearFactory(academic_year=self.academic_year) self.learning_unit_year = LearningUnitYearFactory( academic_year=self.academic_year, acronym="LBIR1100", decimal_scores=False) # Create tutor and score responsible _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Alibra', first_name='Paul')) _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Durant', first_name='Thomas'), is_score_responsible=True) _create_attribution(self.learning_unit_year, person=PersonFactory(last_name='Lobradi', first_name='Pierre')) self.session_exam = SessionExamFactory( number_session=1, learning_unit_year=self.learning_unit_year) # Create three students and enrol them to learning unit year self.student_1 = StudentFactory( person=PersonFactory(last_name='Dupont', first_name='Jacques')) self.student_2 = StudentFactory( person=PersonFactory(last_name='Dupont', first_name='Axel')) self.student_3 = StudentFactory( person=PersonFactory(last_name='Armand', first_name='Zoe')) for student in (self.student_1, self.student_2, self.student_3): offer_enrollment = OfferEnrollmentFactory( offer_year=self.offer_year, student=student) lu_enrolmment = LearningUnitEnrollmentFactory( offer_enrollment=offer_enrollment, learning_unit_year=self.learning_unit_year) ExamEnrollmentFactory(learning_unit_enrollment=lu_enrolmment, session_exam=self.session_exam)
def setUpTestData(cls): cls.person_manager = PersonFactory() cls.person_no_manager = PersonFactory() cls.person_manager2 = PersonFactory() cls.manager = AdviserManagerFactory(person=cls.person_manager) cls.manager2 = AdviserManagerFactory(person=cls.person_manager2) cls.a_person_teacher = PersonFactory() cls.teacher = AdviserTeacherFactory(person=cls.a_person_teacher) cls.teacher2 = AdviserTeacherFactory() cls.teacher3 = AdviserTeacherFactory() cls.a_person_student = PersonWithoutUserFactory() cls.student = StudentFactory(person=cls.a_person_student) cls.education_group = EducationGroupFactory() cls.education_group2 = EducationGroupFactory() cls.academic_year1 = AcademicYearFactory() cls.education_group_year = EducationGroupYearFactory( acronym="test_offer1", title="test_offer1", education_group=cls.education_group, academic_year=cls.academic_year1 ) cls.faculty_adviser1 = FacultyAdviserFactory( adviser=cls.manager, education_group=cls.education_group ) cls.faculty_adviser2 = FacultyAdviserFactory( adviser=cls.manager2, education_group=cls.education_group2 ) cls.proposition_dissertation = PropositionDissertationFactory(author=cls.teacher, creator=cls.teacher3.person) cls.offer_propo = OfferPropositionFactory(education_group=cls.education_group) cls.proposition_offer = PropositionOfferFactory( proposition_dissertation=cls.proposition_dissertation, offer_proposition=cls.offer_propo ) cls.dissertation1 = DissertationFactory( author=cls.student, education_group_year=cls.education_group_year, proposition_dissertation=cls.proposition_dissertation, status='DIR_SUBMIT', active=True, dissertation_role__adviser=cls.teacher, dissertation_role__status=dissertation_role_status.PROMOTEUR ) cls.dissertation_role = DissertationRoleFactory( adviser=cls.teacher3, status=dissertation_role_status.READER, dissertation=cls.dissertation1 )
def setUp(self): self.maxDiff = None self.manager = AdviserManagerFactory() a_person_teacher = PersonFactory.create(first_name='Pierre', last_name='Dupont') self.teacher = AdviserTeacherFactory(person=a_person_teacher) a_person_teacher2 = PersonFactory.create(first_name='Marco', last_name='Millet') self.teacher2 = AdviserTeacherFactory(person=a_person_teacher2) a_person_student = PersonFactory.create(last_name="Durant", user=None) student = StudentFactory.create(person=a_person_student) self.offer1 = OfferFactory(title="test_offer1") self.offer2 = OfferFactory(title="test_offer2") self.academic_year1 = AcademicYearFactory() self.academic_year2 = AcademicYearFactory(year=self.academic_year1.year-1) self.offer_year_start1 = OfferYearFactory(acronym="test_offer1", offer=self.offer1, academic_year=self.academic_year1) offer_year_start2 = OfferYearFactory(academic_year=self.academic_year2, acronym="test_offer2", offer=self.offer1) self.offer_proposition1 = OfferPropositionFactory(offer=self.offer1) self.offer_proposition2 = OfferPropositionFactory(offer=self.offer2) FacultyAdviserFactory(adviser=self.manager, offer=self.offer1) self.manager2 = AdviserManagerFactory() FacultyAdviserFactory(adviser=self.manager, offer=self.offer2) roles = ['PROMOTEUR', 'CO_PROMOTEUR', 'READER', 'PROMOTEUR', 'ACCOMPANIST', 'PRESIDENT'] status = ['DRAFT', 'COM_SUBMIT', 'EVA_SUBMIT', 'TO_RECEIVE', 'DIR_SUBMIT', 'DIR_SUBMIT'] self.dissertations_list = list() for x in range(0, 6): proposition_dissertation = PropositionDissertationFactory(author=self.teacher, creator=a_person_teacher, title='Proposition {}'.format(x) ) PropositionOfferFactory(proposition_dissertation=proposition_dissertation, offer_proposition=self.offer_proposition1) self.dissertations_list.append(DissertationFactory(author=student, title='Dissertation {}'.format(x), offer_year_start=self.offer_year_start1, proposition_dissertation=proposition_dissertation, status=status[x], active=True, dissertation_role__adviser=self.teacher, dissertation_role__status=roles[x] )) self.dissertation_1 = DissertationFactory\ (author=student, title='Dissertation 2017', offer_year_start=self.offer_year_start1, proposition_dissertation=proposition_dissertation, status='COM_SUBMIT', active=True, dissertation_role__adviser=self.teacher2, dissertation_role__status='PROMOTEUR')
def test_multiple_students_objects_for_one_user(self): StudentFactory(person=self.student.person) msg = _( "A problem was detected with your registration : 2 registration id's are linked to your user. Please " "contact the registration departement (SIC). Thank you.") response = self.client.get(self.url) self.assertTemplateUsed(response, 'dashboard.html') messages = list(response.context['messages']) self.assertEqual(len(messages), 1) self.assertEqual(messages[0].tags, 'error') self.assertEqual(messages[0].message, msg)
def _create_context_exam_enrollments(cls, learning_unit_year, offer_year, nb_enrollment=10, nb_filled=10): counter_filled = nb_filled session_exam = SessionExamFactory(number_session=number_session.ONE, learning_unit_year=learning_unit_year) OfferYearCalendarFactory(academic_calendar=cls.academic_calendar, offer_year=offer_year) for index in range(0, nb_enrollment): offer_enrollment = test_offer_enrollment.create_offer_enrollment(StudentFactory(), offer_year) learning_unit_enrollment = test_learning_unit_enrollment.create_learning_unit_enrollment( offer_enrollment=offer_enrollment, learning_unit_year=learning_unit_year) exam_enrollment = test_exam_enrollment.create_exam_enrollment(session_exam, learning_unit_enrollment) if counter_filled: exam_enrollment.score_final = randint(0, 20) exam_enrollment.save() counter_filled -= 1
def test_student_picture(self, mock_request_get): student = StudentFactory(person=PersonFactory( last_name='Durant', first_name='Thomas', gender='M')) request = RequestFactory().get( reverse('student_picture', args=[student.id])) request.user = self.program_manager_1.person.user from base.views.student import student_picture from django.contrib.staticfiles.storage import staticfiles_storage response = student_picture(request, student.id) self.assertTrue(mock_request_get.called) self.assertEqual(response.url, staticfiles_storage.url('img/men_unknown.png'))
def test_ajax_delete_evolution_score(self): computed_score = 0 student_info = InternshipStudentInformationFactory(cohort=self.cohort, evolution_score=20) student = StudentFactory(person=student_info.person) url = reverse('delete_evolution_score', kwargs={'cohort_id': self.cohort.pk}) response = self.client.post(url, data={ 'computed': computed_score, 'scores': '{"P1": 0, "P2": 0}', 'student': student.registration_id }) student_info.refresh_from_db() self.assertTemplateUsed(response, 'fragment/evolution_score_cell.html') self.assertIsNone(student_info.evolution_score)
def test_ajax_save_evaluation_status(self): affectation = StudentAffectationStatFactory( student=StudentFactory(), period=PeriodFactory(cohort=self.cohort)) self.assertFalse(affectation.internship_evaluated) url = reverse('save_evaluation_status', kwargs={'cohort_id': self.cohort.pk}) response = self.client.post(url, data={ 'student': affectation.student.registration_id, 'period': affectation.period.name, 'status': 'true' }) affectation.refresh_from_db() self.assertEqual(response.status_code, 204) self.assertTrue(affectation.internship_evaluated)
def setUpTestData(cls): cls.user = UserFactory() cls.student = StudentFactory(person__user=cls.user) add_permission(cls.student.person.user, "can_access_internship") cls.cohort = CohortFactory() cls.student_information = test_internship_student_information.create_student_information( cls.user, cls.cohort, cls.student.person ) cls.selective_internship = InternshipFactory( name='Selective internship', cohort=cls.cohort, speciality=None ) cls.specialty = test_internship_speciality.create_speciality(name="specialty", cohort=cls.cohort)
def test_post_upload_eval_error(self, mock_import): student = StudentFactory() mock_import.return_value = [{ 'registration_id': student.registration_id, 'period': self.period.name }] url = reverse('internship_upload_eval', kwargs={ 'cohort_id': self.cohort.pk, }) redirect_url = reverse('internship_scores_encoding', kwargs={'cohort_id': self.cohort.pk}) response = self.client.post(url, data={'file_upload': self.xlsxfile}) messages_list = [msg for msg in response.wsgi_request._messages] self.assertRedirects(response, redirect_url) self.assertEqual(messages_list[0].level_tag, 'error') self.assertIn(student.registration_id, str(messages_list[0]))
def test_when_not_receive_attestation_statuses( self, mock_fetch_json_attestation_statuses): a_student = StudentFactory(person=self.person) self.client.force_login(self.person.user) response = self.client.get(self.url, follow=True) self.assertTrue(mock_fetch_json_attestation_statuses.called) self.assertEqual(response.status_code, OK) self.assertTemplateUsed(response, 'attestation_home_student.html') self.assertEqual(response.context['student'], a_student) self.assertFalse(response.context['attestation_statuses']) self.assertFalse(response.context['academic_year']) self.assertFalse(response.context['formated_academic_year']) self.assertFalse(response.context['available'])
def create_phd(self, user=None): """ Create a phd person object with all related objects and permissions :param user: related user object , if none it will be created :return: The phd person """ if user: person = PersonFactory(user=user) else: person = PersonFactory() TutorFactory(person=person) StudentFactory(person=person) tutors_group = self.create_tutors_group() tutors_group.user_set.add(person.user) student_group = self.create_students_group() student_group.user_set.add(person.user) return person
def setUpTestData(cls): cls.maxDiff = None cls.manager = AdviserManagerFactory() a_person_teacher = PersonFactory.create(first_name='Pierre', last_name='Dupont', email='*****@*****.**') cls.teacher = AdviserTeacherFactory(person=a_person_teacher) a_person_teacher2 = PersonFactory.create(first_name='Marco', last_name='Millet', email='*****@*****.**') cls.teacher2 = AdviserTeacherFactory(person=a_person_teacher2) a_person_student = PersonWithoutUserFactory.create( last_name="Durant", email='*****@*****.**') cls.student = StudentFactory.create(person=a_person_student) cls.education_group_1 = EducationGroupFactory() cls.academic_year1 = AcademicYearFactory() cls.education_group_year_1 = EducationGroupYearFactory( acronym="test_offer1", education_group=cls.education_group_1, academic_year=cls.academic_year1, title="test_offer1") cls.offer_proposition1 = OfferPropositionFactory( education_group=cls.education_group_1, global_email_to_commission=True) cls.proposition_dissertation = PropositionDissertationFactory( author=cls.teacher, creator=a_person_teacher, title='Proposition 1212121') FacultyAdviserFactory(adviser=cls.manager, education_group=cls.education_group_1) cls.dissertation_1 = DissertationFactory( author=cls.student, title='Dissertation_test_email', education_group_year=cls.education_group_year_1, proposition_dissertation=cls.proposition_dissertation, status='DRAFT', active=True, dissertation_role__adviser=cls.teacher, dissertation_role__status='PROMOTEUR') FacultyAdviserFactory(adviser=cls.manager, education_group=cls.education_group_1) cls.dissert_role = DissertationRoleFactory( dissertation=cls.dissertation_1, adviser=cls.teacher2, status='READER')
def test_ajax_save_evolution_score(self): computed_score = 0 new_score = 20 student_info = InternshipStudentInformationFactory(cohort=self.cohort) student = StudentFactory(person=student_info.person) self.assertIsNone(student_info.evolution_score) url = reverse('save_evolution_score', kwargs={'cohort_id': self.cohort.pk}) response = self.client.post(url, data={ 'computed': computed_score, 'edited': new_score, 'student': student.registration_id, 'scores': '{}', }) student_info.refresh_from_db() self.assertTemplateUsed(response, 'fragment/evolution_score_cell.html') self.assertEqual(student_info.evolution_score, new_score)