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 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 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 = ContinuingEducationTrainingFactory( education_group=cls.education_group ) group = GroupFactory(name=TRAINING_MANAGERS_GROUP) cls.training_manager = PersonWithPermissionsFactory('view_admission', 'change_admission') cls.training_manager.user.groups.add(group) 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, )
def setUpTestData(cls): cls.user = UserFactory() CountryFactory(iso_code='NL') cls.person = ContinuingEducationPersonFactory() cls.address = AddressFactory() 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 ) cls.admission = AdmissionFactory( person_information=cls.person, address=cls.address, state=DRAFT, formation=cls.formation ) cls.url = reverse('continuing_education_api_v1:registration-list', kwargs={'uuid': cls.person.uuid}) for state in [VALIDATED, ACCEPTED, REGISTRATION_SUBMITTED]: cls.education_group = EducationGroupFactory() EducationGroupYearFactory(education_group=cls.education_group) AdmissionFactory( person_information=cls.person, state=state, formation=ContinuingEducationTrainingFactory( education_group=cls.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.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 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 setUp(self): self.client.force_login(self.training_manager.person.user) self.admission = AdmissionFactory( formation=self.formation, academic_year=self.current_academic_year) self.data = self.admission.__dict__ self.data['formation'] = self.admission.formation.pk self.data['academic_year'] = self.admission.academic_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.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) group = GroupFactory(name=MANAGERS_GROUP) cls.manager = PersonWithPermissionsFactory('view_admission', 'change_admission') cls.manager.user.groups.add(group) group = GroupFactory(name=TRAINING_MANAGERS_GROUP) cls.training_manager = PersonWithPermissionsFactory( 'view_admission', 'change_admission') cls.training_manager.user.groups.add(group) EntityVersionFactory(entity=cls.formation.management_entity) cls.admission = AdmissionFactory( formation=cls.formation, state=SUBMITTED, person_information__person__gender='M', academic_year=cls.academic_year, ) a_person_information = ContinuingEducationPersonFactory( person__gender='M') 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 setUp(self): self.admission = AdmissionFactory() self.basic_response = { 'message': 'IUFC_NO_ERROR', 'success': True, 'student_case_uuid': str(self.admission.uuid), 'registration_id': '123456789', 'registration_status': 'INSCRIT' }
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.rejected_admission_other = AdmissionFactory( state=REJECTED, state_reason=ANY_REASON, formation=cls.formation) cls.rejected_admission_not_other = AdmissionFactory( state=REJECTED, state_reason=NOT_ENOUGH_EXPERIENCE, formation=cls.formation)
def setUpTestData(cls): cls.person_without_change_perm = PersonWithPermissionsFactory('view_admission') cls.registrations_to_validate = [ AdmissionFactory(state=admission_state_choices.REGISTRATION_SUBMITTED) for _ in range(2) ] cls.diplomas_to_produce = [ AdmissionFactory(state=admission_state_choices.VALIDATED, diploma_produced=False) for _ in range(2) ] cls.admissions_to_validate = [ AdmissionFactory(state=admission_state_choices.SUBMITTED) for _ in range(2) ]
def test_get_admissions_by_faculty_criteria_get_child_too(self): an_admission_submitted_1 = AdmissionFactory( formation=ContinuingEducationTrainingFactory( education_group=self.education_group_on_faculty), state=SUBMITTED) an_admission_submitted_2 = AdmissionFactory( formation=ContinuingEducationTrainingFactory( education_group=self.education_group_on_faculty_child), state=SUBMITTED) form = AdmissionFilterForm( {"faculty": self.fac_3_version_with_child.id}) self.assertTrue(form.is_valid()) results = form.get_admissions() self.assertCountEqual( results, [an_admission_submitted_1, an_admission_submitted_2])
def setUp(self): GroupFactory(name='continuing_education_managers') self.citizenship = CountryFactory() self.user = UserFactory() self.academic_year = AcademicYearFactory(year=2018) education_group = EducationGroupFactory() EducationGroupYearFactory( education_group=education_group, academic_year=self.academic_year ) self.admission = AdmissionFactory( citizenship=self.citizenship, person_information=ContinuingEducationPersonFactory(person=PersonFactory(user=self.user)), formation=ContinuingEducationTrainingFactory(education_group=education_group), state=DRAFT ) self.url = reverse('continuing_education_api_v1:admission-detail-update', kwargs={'uuid': self.admission.uuid}) self.invalid_url = reverse( 'continuing_education_api_v1:admission-detail-update', kwargs={'uuid': uuid.uuid4()} ) self.client.force_authenticate(user=self.user)
def setUpTestData(cls): cls.user = UserFactory() cls.citizenship = CountryFactory(iso_code='FR') new_country = CountryFactory(iso_code='NL') cls.person = ContinuingEducationPersonFactory( birth_country=cls.citizenship ) cls.address = AddressFactory() cls.academic_year = AcademicYearFactory(year=2018) cls.url = reverse('continuing_education_api_v1:admission-list', kwargs={'uuid': cls.person.uuid}) for state in [SUBMITTED, ACCEPTED, REJECTED, DRAFT]: education_group = EducationGroupFactory() EducationGroupYearFactory( education_group=education_group, academic_year=cls.academic_year ) cls.formation = ContinuingEducationTrainingFactory(education_group=education_group) cls.admission = AdmissionFactory( citizenship=cls.citizenship, person_information=cls.person, address=cls.address, state=state, formation=cls.formation )
def setUpTestData(cls): cls.permission = HasAdmissionAccess() cls.user = UserFactory() person_information = ContinuingEducationPersonFactory( person=PersonFactory(user=cls.user) ) cls.admission = AdmissionFactory(person_information=person_information)
def setUpTestData(cls): cls.education_group = EducationGroupFactory() EducationGroupYearFactory( education_group=cls.education_group, academic_year=create_current_academic_year() ) cls.formation = ContinuingEducationTrainingFactory( education_group=cls.education_group ) algeria = CountryFactory(name=COUNTRY_NAME) cls.address = AddressFactory(city=CITY_NAME, country=algeria, location='Street', postal_code='5500') cls.registration = AdmissionFactory( formation=cls.formation, state=ACCEPTED, ucl_registration_complete=True, payment_complete=False, citizenship=algeria, person_information=ContinuingEducationPersonFactory(birth_location=CITY_NAME, birth_country=algeria, birth_date=datetime.datetime(1977, 4, 22)), address=cls.address, billing_address=cls.address, residence_address=cls.address )
def test_cansendfiles_return_true_if_safe_methods(self): admission = AdmissionFactory() file = AdmissionFileFactory(admission=admission) self.request.method = 'GET' self.assertTrue( self.permission.has_object_permission(self.request, None, file) )
def setUpTestData(cls): cls.manager = PersonWithPermissionsFactory('view_admission', 'change_admission', groups=[MANAGERS_GROUP]) 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) cls.admission_accepted = AdmissionFactory( state=admission_state_choices.ACCEPTED, formation=cls.formation) cls.admission_rejected = AdmissionFactory( state=admission_state_choices.REJECTED, formation=cls.formation) cls.admission_validated = AdmissionFactory( state=admission_state_choices.VALIDATED, formation=cls.formation)
def setUp(self): self.admission = AdmissionFactory() self.file = SimpleUploadedFile( name='upload_test.pdf', content=str.encode("test_content"), content_type="application/pdf", )
def test_cansendfiles_return_false_with_wrong_state(self): states = [REJECTED, WAITING, SUBMITTED, REGISTRATION_SUBMITTED, VALIDATED] self.request.method = 'DELETE' for state in states: admission = AdmissionFactory(state=state) file = AdmissionFileFactory(admission=admission) self.assertFalse( self.permission.has_object_permission(self.request, None, file) ) self.request.method = 'POST' for state in states: admission = AdmissionFactory(state=state) file = AdmissionFileFactory(admission=admission) self.assertFalse( self.permission.has_object_permission(self.request, None, file) )
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 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): cls.continuing_education_manager = ContinuingEducationManagerFactory() cls.admission = AdmissionFactory(state=VALIDATED) EducationGroupYearFactory( education_group=cls.admission.formation.education_group, academic_year=create_current_academic_year() ) cls.url = reverse('injection_to_epc', args=[cls.admission.pk])
def test_get_admission_by_no_registration_required(self): admission = AdmissionFactory( formation=self.formation_no_registration_required, state=ACCEPTED_NO_REGISTRATION_REQUIRED) form = AdmissionFilterForm({"registration_required": False}) self.assertTrue(form.is_valid()) results = form.get_admissions() self.assertCountEqual(results, [admission])
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 _create_admissions_for_free_text_search(self): self.admissions_free_text = [] for person in self.persons: self.admissions_free_text.append( AdmissionFactory( formation=self.formation_no_registration_required, person_information=ContinuingEducationPersonFactory( person=person), address=AddressFactory( country=self.country_without_accent), state=SUBMITTED, )) for ed in self.eds: self.admissions_free_text.append( AdmissionFactory(formation=ContinuingEducationTrainingFactory( education_group=ed), state=SUBMITTED))
def setUpTestData(cls): cls.user = UserFactory() current_acad_year = create_current_academic_year() cls.next_acad_year = AcademicYearFactory(year=current_acad_year.year + 1) cls.admission = AdmissionFactory() 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.entity_version = EntityVersionFactory( entity=cls.formation.management_entity, acronym=FACULTY_ACRONYM, entity_type=entity_type.FACULTY) cls.admission = AdmissionFactory(formation=cls.formation, state=SUBMITTED)
def _build_admission_with_accent(self, a_state, archived): address_with_accent = AddressFactory(country=self.country_accent, city=CITY_NAME_WITH_ACCENT) admission_accent = AdmissionFactory(address=address_with_accent, state=a_state, archived=archived) EducationGroupYearFactory( education_group=admission_accent.formation.education_group) return admission_accent
def test_cansendfiles_return_true_if_admission_state_is_draft(self): admission = AdmissionFactory(state=DRAFT) file = AdmissionFileFactory(admission=admission) methods = ['POST', 'DELETE'] for method in methods: self.request.method = method self.assertTrue( self.permission.has_object_permission(self.request, None, file) )
def setUpTestData(cls): person_information = ContinuingEducationPersonFactory() cls.admission = AdmissionFactory(person_information=person_information) cls.admission_file = AdmissionFileFactory( uploaded_by=person_information.person) url = reverse('continuing_education_api_v1:file-list-create', kwargs={'uuid': cls.admission.uuid}) cls.serializer = AdmissionFileSerializer( cls.admission_file, context={'request': RequestFactory().get(url)})