def test_get_managers_mail_mail_missing(self): ed = EducationGroupFactory() EducationGroupYearFactory(education_group=ed, academic_year=create_current_academic_year()) manager = PersonFactory(last_name="AAA", email="") manager_2 = PersonFactory(last_name="BBB", email="") cet = ContinuingEducationTrainingFactory(education_group=ed) ContinuingEducationTrainingManagerFactory(person=manager, training=cet) ContinuingEducationTrainingManagerFactory(person=manager_2, training=cet) admission = AdmissionFactory(formation=cet) expected_mails = "{}".format(manager_2.email) self.assertEqual(_get_managers_mails(admission.formation), expected_mails)
def test_archive_procedure_authorized(self): training_manager = ContinuingEducationTrainingManagerFactory(training=self.formation) self.client.force_login(training_manager.person.user) response = self.client.post( reverse('archive_procedure', kwargs={'admission_id': self.admission.pk}) ) self.assertEqual(response.status_code, HttpResponseRedirect.status_code)
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.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group ) cls.training_manager = ContinuingEducationTrainingManagerFactory(training=cls.formation) valid_state = [REGISTRATION_SUBMITTED, VALIDATED, ACCEPTED] cls.registrations = [] for valid_state in valid_state: cls.registrations.append(AdmissionFactory( formation=cls.formation, state=valid_state )) for invalid_state in admission_state_choices.STATE_CHOICES: if invalid_state[0] not in [REGISTRATION_SUBMITTED, VALIDATED, ACCEPTED]: AdmissionFactory( formation=cls.formation, state=invalid_state[0] )
def test_admission_detail_access_denied(self): other_training_manager = ContinuingEducationTrainingManagerFactory() self.client.force_login(other_training_manager.person.user) url = reverse('admission_detail', args=[self.admission.id]) response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) self.assertTemplateUsed(response, 'access_denied.html')
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.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group) cls.training_manager = ContinuingEducationTrainingManagerFactory() cls.registration_to_validate = AdmissionFactory( formation=cls.formation, state=REGISTRATION_SUBMITTED, ) cls.admission_diploma_to_produce = AdmissionFactory( formation=cls.formation, state=VALIDATED, ) cls.admission_to_validate = AdmissionFactory( formation=cls.formation, state=admission_state_choices.SUBMITTED, ) cls.admissions_to_accept = [ AdmissionFactory(state=random.choice([ admission_state_choices.SUBMITTED, admission_state_choices.WAITING ]), formation=cls.formation) for _ in range(2) ] cls.admission_not_to_accept = AdmissionFactory( state=admission_state_choices.DRAFT, formation=cls.formation) cls.reason = "because that's the way it is"
def test_list_with_archive(self): self.admission.archived = True self.admission.save() training_manager = ContinuingEducationTrainingManagerFactory(training=self.formation) self.client.force_login(training_manager.person.user) response = self.client.post(reverse('archive')) self.assertEqual(response.status_code, HttpResponse.status_code) self.assertCountEqual(response.context['archives'].object_list, [self.admission])
def test_list_with_no_registrations_visible(self): training_manager = ContinuingEducationTrainingManagerFactory() self.client.force_login(training_manager.person.user) url = reverse('registration') response = self.client.get(url) self.assertEqual(response.status_code, HttpResponse.status_code) self.assertCountEqual(response.context['admissions'], []) self.assertTemplateUsed(response, 'registrations.html')
def test_list_admissions_filtered_by_training_manager_with_admission(self): training_manager = ContinuingEducationTrainingManagerFactory(training=self.formation) self.client.force_login(training_manager.person.user) url = reverse('admission') response = self.client.get(url) self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(len(response.context['admissions'].object_list), 1) self.assertTemplateUsed(response, 'admissions.html')
def setUp(self): ed = EducationGroupFactory() EducationGroupYearFactory(education_group=ed, academic_year=create_current_academic_year()) cet = ContinuingEducationTrainingFactory(education_group=ed) self.manager = ContinuingEducationTrainingManagerFactory(training=cet) self.other_manager = ContinuingEducationTrainingManagerFactory( person=PersonFactory(last_name="BBB"), training=cet) self.admission = AdmissionFactory(formation=cet) uploaded_file = SimpleUploadedFile(name='upload_test.pdf', content=str.encode('content'), content_type="application/pdf") self.admission_file = AdmissionFileFactory( admission=self.admission, path=uploaded_file, )
def setUpTestData(cls): ed = EducationGroupFactory() EducationGroupYearFactory(education_group=ed, academic_year=create_current_academic_year()) cls.cet = ContinuingEducationTrainingFactory(education_group=ed) cls.manager = ContinuingEducationTrainingManagerFactory( training=cls.cet) cls.admission = AdmissionFactory(formation=cls.cet)
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.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group, additional_information_label='additional_information', registration_required=True ) cls.education_group_no_registration_required = EducationGroupFactory() EducationGroupYearFactory( education_group=cls.education_group_no_registration_required, academic_year=cls.academic_year ) cls.formation_no_registration_required = ContinuingEducationTrainingFactory( education_group=cls.education_group_no_registration_required, registration_required=False ) cls.manager = ContinuingEducationManagerFactory() cls.training_manager = ContinuingEducationTrainingManagerFactory(training=cls.formation) EntityVersionFactory( entity=cls.formation.management_entity ) cls.admission = AdmissionFactory( formation=cls.formation, state=SUBMITTED, person_information__person__gender='H', academic_year=cls.academic_year, ) a_person_information = ContinuingEducationPersonFactory(person__gender='H') cls.admission_no_admission_required = AdmissionFactory( formation=cls.formation_no_registration_required, state=ACCEPTED_NO_REGISTRATION_REQUIRED, person_information=a_person_information, academic_year=cls.academic_year, ) cls.file = SimpleUploadedFile( name='upload_test.pdf', content=str.encode(FILE_CONTENT), content_type="application/pdf" ) cls.country = CountryFactory() cls.person_data = { 'last_name': cls.admission.person_information.person.last_name, 'first_name': cls.admission.person_information.person.first_name, 'gender': cls.admission.person_information.person.gender, 'email': cls.admission.person_information.person.email, } cls.continuing_education_person_data = { 'birth_date': cls.admission.person_information.birth_date.strftime('%Y-%m-%d'), 'birth_location': cls.admission.person_information.birth_location, 'birth_country': cls.admission.person_information.birth_country.id, }
def test_training_manager_can_edit_training(self): training_manager = ContinuingEducationTrainingManagerFactory( training=self.continuing_education_training) self.client.force_login(training_manager.person.user) url = reverse('formation_edit', args=[self.continuing_education_training.id]) response = self.client.get(url) self.assertEqual(response.status_code, HttpResponseBase.status_code) self.assertTemplateUsed(response, 'formation_form.html')
def test_context_trainer_manager_contents(self): training_manager = ContinuingEducationTrainingManagerFactory( training=self.continuing_education_training) self.client.force_login(training_manager.person.user) response = self.client.get(reverse('formation')) self.assertEqual(response.status_code, 200) self.assertTrue( response.context['continuing_education_training_manager']) self.assertCountEqual(response.context['trainings_managing'], [training_manager.training.id])
def setUpTestData(cls): cls.current_academic_year = create_current_academic_year() cls.education_group = EducationGroupFactory() EducationGroupYearFactory(education_group=cls.education_group, academic_year=cls.current_academic_year) cls.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group) cls.training_manager = ContinuingEducationTrainingManagerFactory( training=cls.formation) cls.manager = ContinuingEducationManagerFactory()
def test_formation_administrators(self): academic_year = create_current_academic_year() EducationGroupYearFactory( education_group=self.education_group, academic_year=academic_year, ) a_training = ContinuingEducationTraining( education_group=self.education_group) a_training.save() person_1 = PersonFactory(first_name="Louis", last_name="Lesquoy") person_2 = PersonFactory(first_name="Arnaud", last_name="Jadoulle") ContinuingEducationTrainingManagerFactory(person=person_1, training=a_training) ContinuingEducationTrainingManagerFactory(person=person_2, training=a_training) self.assertEqual( a_training.formation_administrators, "{}, {} - {}, {}".format(person_2.last_name.upper(), person_2.first_name, person_1.last_name.upper(), person_1.first_name))
def setUpTestData(cls): cls.academic_year = create_current_academic_year() cls.education_group = EducationGroupFactory() cls.start_date = date.today().replace(year=2010) cls.faculty = EntityVersionFactory( acronym="DRT_NEW", entity_type=FACULTY, start_date=cls.start_date, end_date=None, ) EducationGroupYearFactory( education_group=cls.education_group, academic_year=cls.academic_year, management_entity=cls.faculty.entity, ) cls.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group) cls.training_managers = [ ContinuingEducationTrainingManagerFactory(), ContinuingEducationTrainingManagerFactory(training=cls.formation) ] cls.continuing_education_manager = ContinuingEducationManagerFactory()
def setUpTestData(cls): cls.user = UserFactory() cls.url = reverse( 'continuing_education_api_v1:continuing-education-training-list-create' ) cls.academic_year = create_current_academic_year() cls.education_group = EducationGroupFactory() EducationGroupYearFactory(education_group=cls.education_group, academic_year=cls.academic_year) cls.continuing_education_training = ContinuingEducationTrainingFactory( education_group=cls.education_group) cls.training_manager = ContinuingEducationTrainingManagerFactory( training=cls.continuing_education_training)
def setUpTestData(cls): cls.student = ContinuingEducationStudentWorkerFactory() cls.training_manager = ContinuingEducationTrainingManagerFactory() cls.admission = AdmissionFactory() cls.academic_year = AcademicYearFactory(year=2018) cls.education_group = EducationGroupFactory() EducationGroupYearFactory( education_group=cls.education_group, academic_year=cls.academic_year, ) cls.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group, active=True)
def setUpTestData(cls): cls.manager = ContinuingEducationManagerFactory() cls.manager.person.employee = True cls.academic_year = create_current_academic_year() cls.education_group = EducationGroupFactory() EducationGroupYearFactory( education_group=cls.education_group, academic_year=cls.academic_year, ) cls.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group, active=True) cls.training_manager = ContinuingEducationTrainingManagerFactory( training=cls.formation)
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.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group ) cls.training_manager = ContinuingEducationTrainingManagerFactory() cls.admission = AdmissionFactory( formation=cls.formation, state=SUBMITTED, )
def test_get_prospects_by_user(self): academic_year = create_current_academic_year() education_group = EducationGroupFactory() EducationGroupYearFactory(education_group=education_group, academic_year=academic_year) training_1 = ContinuingEducationTrainingFactory( education_group=education_group) manager = ContinuingEducationTrainingManagerFactory( training=training_1) prospect_1 = ProspectFactory(formation=training_1) prospect_2 = ProspectFactory(formation=training_1) ProspectFactory() ProspectFactory() self.assertCountEqual(get_prospects_by_user(manager.person.user), [prospect_1, prospect_2])
def setUpTestData(cls): academic_year = create_current_academic_year() academic_year_next = AcademicYearFactory(year=academic_year.year + 1) cls.ed = EducationGroupFactory() cls.education_group_year = EducationGroupYearFactory( education_group=cls.ed, academic_year=academic_year) cls.education_group_year_next_year = EducationGroupYearFactory( education_group=cls.ed, academic_year=academic_year_next) cls.active_formation = ContinuingEducationTrainingFactory( education_group=cls.ed, active=True) cls.training_manager = ContinuingEducationTrainingManagerFactory( training=cls.active_formation) ed2 = EducationGroupFactory() EducationGroupYearFactory(education_group=ed2) cls.formation_not_managed = ContinuingEducationTrainingFactory( education_group=ed2)
def test_send_email_email_missing(self, mock_send_mail): self.manager_without_email = ContinuingEducationTrainingManagerFactory( person=PersonFactory(last_name="AAA", email=""), training=self.cet) self.cet.send_notification_emails = True self.cet.save() admission.send_submission_email_to_admission_managers( self.admission, None) receivers = mock_send_mail.call_args[1].get('receivers') self.assertCountEqual(receivers, [ { 'receiver_person_id': self.manager.person.id, 'receiver_email': self.manager.person.email, 'receiver_lang': self.manager.person.language }, ])
def setUpTestData(cls): cls.manager = ContinuingEducationManagerFactory() cls.training_manager = ContinuingEducationTrainingManagerFactory() cls.academic_year = create_current_academic_year() cls.education_group = EducationGroupFactory() EducationGroupYearFactory(education_group=cls.education_group, academic_year=cls.academic_year) cls.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group) cls.registrations_to_validate = [ AdmissionFactory( state=admission_state_choices.REGISTRATION_SUBMITTED, formation=cls.formation) for _ in range(2) ] cls.registration_not_to_validate = AdmissionFactory( state=admission_state_choices.DRAFT, diploma_produced=True, formation=cls.formation) cls.diplomas_to_produce = [ AdmissionFactory( state=admission_state_choices.VALIDATED, diploma_produced=False, formation=cls.formation, ucl_registration_complete=True, payment_complete=True, assessment_succeeded=True, ) for _ in range(2) ] cls.no_diploma_to_produce_because_waiting = AdmissionFactory( state=admission_state_choices.WAITING, diploma_produced=True, formation=cls.formation) cls.admissions_to_accept = [ AdmissionFactory(state=random.choice([ admission_state_choices.SUBMITTED, admission_state_choices.WAITING ]), formation=cls.formation) for _ in range(2) ] cls.admission_not_to_accept = AdmissionFactory( state=admission_state_choices.DRAFT, formation=cls.formation)
def test_prospect_list_ordered_by_formation(self): self.academic_year = create_current_academic_year() self.education_groups = [EducationGroupFactory() for _ in range(1, 3)] acronyms = ['AAA', 'BBA', 'CAA'] prospects = [] for index, education_group in enumerate(self.education_groups): EducationGroupYearFactory( acronym=acronyms[index], education_group=education_group, academic_year=self.academic_year ) training = ContinuingEducationTrainingFactory(education_group=education_group) ContinuingEducationTrainingManagerFactory(training=training, person=self.manager.person) prospects.append(ProspectFactory(formation=training)) response = self.client.get(reverse('prospects')) self.assertEqual(response.status_code, 200) self.assertTemplateUsed(response, 'prospects.html') for index, object in enumerate(response.context['prospects'].object_list): self.assertEqual(response.context['prospects'].object_list[index], prospects[index]) self.assertEqual(response.context['prospects_count'], len(prospects))
def setUpTestData(cls): continuing_education_group_type = EducationGroupTypeFactory( name=education_group_types.TrainingType.AGGREGATION.name, ) current_acad_year = create_current_academic_year() cls.next_acad_year = AcademicYearFactory(year=current_acad_year.year + 1) cls.previous_acad_year = AcademicYearFactory( year=current_acad_year.year - 1) cls.formation_AAAA = EducationGroupYearFactory( acronym="AAAA", partial_acronym="AAAA", academic_year=current_acad_year, education_group_type=continuing_education_group_type) cls.formation_BBBB = EducationGroupYearFactory( acronym="BBBB", partial_acronym="BBBB", academic_year=cls.next_acad_year, education_group_type=continuing_education_group_type) cls.formation_ABBB = EducationGroupYearFactory( acronym="ABBB", partial_acronym="ABBB", academic_year=cls.next_acad_year, education_group_type=continuing_education_group_type) cls.current_academic_formation = EducationGroupYearFactory( acronym="DDDD", partial_acronym="DDDD", academic_year=current_acad_year, education_group_type=continuing_education_group_type) cls.manager = ContinuingEducationManagerFactory() cls.training_manager = ContinuingEducationTrainingManagerFactory() cls.entity_version = EntityVersionFactory( entity=cls.formation_AAAA.management_entity, ) cls.continuing_education_training = ContinuingEducationTrainingFactory( education_group=cls.formation_AAAA.education_group)
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.formation = ContinuingEducationTrainingFactory(education_group=cls.education_group) cls.faculty_manager = ContinuingEducationTrainingManagerFactory(training=cls.formation) cls.continuing_education_manager = ContinuingEducationManagerFactory() 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 = ContinuingEducationStudentWorkerFactory()
def setUpTestData(cls): cls.training_manager = ContinuingEducationTrainingManagerFactory() cls.manager = ContinuingEducationManagerFactory() cls.student_worker = ContinuingEducationStudentWorkerFactory()
def test_inject_admission_to_epc_refused_to_training_manager(self): continuing_education_training_manager = ContinuingEducationTrainingManagerFactory() self.client.force_login(continuing_education_training_manager.person.user) response = self.client.get(self.url) self.assertRedirects(response, "/login/?next={}".format(self.url))
def setUpTestData(cls): cls.manager = ContinuingEducationTrainingManagerFactory()