def setUpTestData(cls): cls.maxDiff = None cls.manager = AdviserManagerFactory() a_person_teacher = PersonFactory(first_name='Pierre', last_name='Dupont') cls.teacher = AdviserTeacherFactory(person=a_person_teacher) a_person_student = PersonFactory(last_name="Durant") another_person_student = PersonFactory(last_name="Paul") cls.student = StudentFactory.create(person=a_person_student) cls.student_with_1_dissertation = StudentFactory( person=another_person_student) cls.education_group1 = EducationGroupFactory() cls.academic_year1 = AcademicYearFactory() cls.education_group_year1 = EducationGroupYearFactory( acronym="test_offer1", education_group=cls.education_group1, academic_year=cls.academic_year1) cls.offer_proposition1 = OfferPropositionFactory( education_group=cls.education_group1) cls.proposition_dissertation = PropositionDissertationFactory( author=cls.teacher, creator=a_person_teacher, title='Proposition 1212121') cls.proposition_dissertation2 = PropositionDissertationFactory( author=cls.teacher, creator=a_person_teacher, title='Proposition 1212121')
def test_adviser_can_manage_dissertation(self): manager = AdviserManagerFactory() manager2 = AdviserManagerFactory() a_person_teacher = PersonFactory.create(first_name='Pierre', last_name='Dupont') a_person_teacher2 = PersonFactory.create(first_name='Marco', last_name='Millet') teacher = AdviserTeacherFactory(person=a_person_teacher) teacher2 = AdviserTeacherFactory(person=a_person_teacher2) a_person_student = PersonFactory.create(last_name="Durant", user=None) student = StudentFactory.create(person=a_person_student) offer_year_start = OfferYearFactory(academic_year=self.academic_year1, acronym="test_offer2") offer_year_start2 = OfferYearFactory(acronym="test_offer3", academic_year=offer_year_start.academic_year) offer = offer_year_start.offer offer2 = offer_year_start2.offer FacultyAdviserFactory(adviser=manager, offer=offer) create_faculty_adviser(manager, offer) create_faculty_adviser(manager2, offer2) proposition_dissertation = PropositionDissertationFactory(author=teacher, creator=a_person_teacher, title='Proposition1') dissertation = DissertationFactory(author=student, title='Dissertation 2017', offer_year_start=offer_year_start, proposition_dissertation=proposition_dissertation, status='DIR_SUBMIT', active=True, dissertation_role__adviser=teacher, dissertation_role__status='PROMOTEUR') self.assertEqual(adviser_can_manage(dissertation, manager), True) self.assertEqual(adviser_can_manage(dissertation, manager2), False) self.assertEqual(adviser_can_manage(dissertation, teacher), False)
def setUp(self): self.maxDiff = None self.manager = AdviserManagerFactory() a_person_teacher = PersonFactory.create( first_name='Pierre', last_name='Dupont', email='*****@*****.**') self.teacher = AdviserTeacherFactory(person=a_person_teacher) a_person_teacher2 = PersonFactory.create( first_name='Marco', last_name='Millet', email='*****@*****.**') self.teacher2 = AdviserTeacherFactory(person=a_person_teacher2) self.teacher3 = AdviserTeacherFactory() self.teacher4 = AdviserTeacherFactory() a_person_student = PersonFactory.create( last_name="Durant", user=None, email='*****@*****.**') self.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) self.offer_year_start2 = OfferYearFactory( acronym="test_offer2", offer=self.offer2, academic_year=self.academic_year1) self.offer_proposition1 = OfferPropositionFactory( offer=self.offer1, global_email_to_commission=True, evaluation_first_year=True) self.offer_proposition2 = OfferPropositionFactory( offer=self.offer2, global_email_to_commission=False) self.proposition_dissertation = PropositionDissertationFactory( author=self.teacher, creator=a_person_teacher, title='Proposition 1212121') FacultyAdviserFactory(adviser=self.manager, offer=self.offer1) self.dissertation1 = DissertationFactory( author=self.student, title='Dissertation_test_email', offer_year_start=self.offer_year_start1, proposition_dissertation=self.proposition_dissertation, status='DIR_SUBMIT', active=True, dissertation_role__adviser=self.teacher, dissertation_role__status='PROMOTEUR') DissertationRoleFactory(adviser=self.teacher2, status='CO_PROMOTEUR', dissertation=self.dissertation1) DissertationRoleFactory(adviser=self.teacher3, status='READER', dissertation=self.dissertation1)
def test_find_by_offers_year(self): student1 = StudentFactory.create() offer_year1 = OfferYearFactory() OfferEnrollmentFactory(student=student1, offer_year=offer_year1) result = list(offer_enrollment.find_by_offers_years([offer_year1])) self.assertEqual(result[0].student, student1) self.assertEqual(result[0].offer_year, offer_year1) self.assertEqual(len(result), 1)
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 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 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 = EducationGroupFactory() cls.education_group3 = EducationGroupFactory() cls.academic_year1 = create_current_academic_year() cls.academic_year2 = AcademicYearFactory(year=cls.academic_year1.year - 1) cls.education_group_year = EducationGroupYearFactory( academic_year=cls.academic_year1, education_group=cls.education_group, acronym="test_offer1") cls.faculty_manager = FacultyAdviserFactory( adviser=cls.manager, education_group=cls.education_group) cls.offer_proposition1 = OfferPropositionFactory( global_email_to_commission=True, evaluation_first_year=True, education_group=cls.education_group_year.education_group) cls.offer_proposition2 = OfferPropositionFactory( education_group=cls.education_group3, global_email_to_commission=False) cls.education_group_year2 = EducationGroupYearFactory( acronym="test_offer2", education_group=cls.offer_proposition2.education_group, academic_year=cls.academic_year1) cls.proposition_dissertation = PropositionDissertationFactory( author=cls.teacher, creator=a_person_teacher, title='Proposition 1212121') cls.dissertation_test_email = DissertationFactory( author=cls.student, title='Dissertation_test_email', proposition_dissertation=cls.proposition_dissertation, status='DRAFT', active=True, dissertation_role__adviser=cls.teacher, dissertation_role__status='PROMOTEUR', education_group_year=cls.education_group_year, ) FacultyAdviserFactory( adviser=cls.manager, education_group=cls.education_group_year.education_group) cls.manager2 = AdviserManagerFactory() FacultyAdviserFactory( adviser=cls.manager, education_group=cls.education_group_year2.education_group) FacultyAdviserFactory( adviser=cls.manager, education_group=cls.education_group_year.education_group) roles = [ 'PROMOTEUR', 'CO_PROMOTEUR', 'READER', 'PROMOTEUR', 'ACCOMPANIST', 'PRESIDENT' ] status = [ 'DRAFT', 'COM_SUBMIT', 'EVA_SUBMIT', 'TO_RECEIVE', 'DIR_SUBMIT', 'DIR_SUBMIT' ] cls.dissertations_list = list() for x in range(0, 6): proposition_dissertation = PropositionDissertationFactory( author=cls.teacher, creator=a_person_teacher, title='Proposition {}'.format(x)) PropositionOfferFactory( proposition_dissertation=proposition_dissertation, offer_proposition=cls.offer_proposition1) cls.dissertations_list.append( DissertationFactory( author=cls.student, title='Dissertation {}'.format(x), education_group_year=cls.education_group_year, proposition_dissertation=proposition_dissertation, status=status[x], active=True, dissertation_role__adviser=cls.teacher, dissertation_role__status=roles[x])) cls.dissertation_1 = DissertationFactory( author=cls.student, title='Dissertation 2017', education_group_year=cls.education_group_year, proposition_dissertation=cls.proposition_dissertation, status='COM_SUBMIT', active=True, dissertation_role__adviser=cls.teacher2, dissertation_role__status='PROMOTEUR') cls.url = reverse('manager_dissertations_search')
def setUpTestData(cls): a_person_student = PersonFactory(last_name="Durant") cls.student = StudentFactory.create(person=a_person_student) cls.url = reverse('adviser-autocomplete') cls.person = PersonFactory(first_name="pierre") cls.adviser = AdviserTeacherFactory(person=cls.person)
def test_find_by_with_person_last_name_case_insensitive(self): a_person = PersonFactory.create(last_name="Smith", user=None) a_student = StudentFactory.create(person=a_person) found = list(student.find_by(person_name="smith")) self.assertEqual(len(found), 1) self.assertEqual(found[0].id, a_student.id)
def test_find_by_with_person_first_name_case_insensitive(self): a_person = PersonWithoutUserFactory.create(first_name="John") a_student = StudentFactory.create(person=a_person) found = list(student.find_by(person_first_name="john")) self.assertEqual(len(found), 1) self.assertEqual(found[0].id, a_student.id)