Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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.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
                )
            )
Ejemplo n.º 4
0
    def test_create_valid_admission_with_new_person_and_person_info(self):
        self.assertEqual(3, Admission.admission_objects.all().count())
        self.assertEqual(1, ContinuingEducationPerson.objects.all().count())
        self.assertEqual(1, Person.objects.all().count())

        p = PersonFactory(email='*****@*****.**')
        ContinuingEducationPersonFactory(person=p)
        data = {
            'person_information': {
                'birth_date': datetime.date.today(),
                'birth_country':  'NL',
                'birth_location': 'Turlututu',
                'person': {
                    'first_name': 'Benjamin',
                    'last_name': 'Dau',
                    'gender': 'M',
                    'email': '*****@*****.**'
                },
            },
            'email': '*****@*****.**',
            'formation': self.formation.uuid
        }

        response = self.client.post(self.url, data=data, format='json')
        self.assertEqual(response.status_code, status.HTTP_201_CREATED)
        self.assertEqual(4, Admission.admission_objects.all().count())
        self.assertEqual(2, ContinuingEducationPerson.objects.all().count())
        self.assertEqual(2, Person.objects.all().count())
Ejemplo n.º 5
0
 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
        )
Ejemplo n.º 7
0
    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 setUpTestData(cls):
     cls.user = UserFactory()
     person_information = ContinuingEducationPersonFactory()
     cls.admission = AdmissionFactory(person_information=person_information)
     cls.url = reverse('continuing_education_api_v1:file-list-create',
                       kwargs={'uuid': cls.admission.uuid})
     for x in range(4):
         AdmissionFileFactory(admission=cls.admission,
                              uploaded_by=person_information.person)
    def setUpTestData(cls):
        cls.birth_country = CountryFactory()

        cls.continuing_education_person = ContinuingEducationPersonFactory(
            birth_country=cls.birth_country)
        url = reverse('continuing_education_api_v1:person-list-create')
        cls.serializer = ContinuingEducationPersonPostSerializer(
            cls.continuing_education_person,
            context={'request': RequestFactory().get(url)})
    def setUpTestData(cls):
        cls.birth_country = CountryFactory()
        fr = CountryFactory(iso_code='FR')

        cls.user = UserFactory()
        p = PersonFactory(user=cls.user)
        cls.person = ContinuingEducationPersonFactory(
            person=p, birth_country=cls.birth_country)
        cls.url = reverse('continuing_education_api_v1:person-detail')
    def test_search(self):
        an_admission = AdmissionFactory(formation=self.formation)
        persisted_admission = admission.search(
            person=an_admission.person_information)
        self.assertTrue(persisted_admission.exists())

        nonexistent_admission = admission.search(
            person=ContinuingEducationPersonFactory())
        self.assertFalse(nonexistent_admission.exists())
    def setUpTestData(cls):
        cls.user = UserFactory()
        cls.url = reverse('continuing_education_api_v1:person-list-create')

        cls.birth_country = CountryFactory()
        cls.country = CountryFactory(iso_code='FR')
        cls.person = PersonFactory()
        for x in range(3):
            ContinuingEducationPersonFactory(birth_country=cls.birth_country)
 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)})
Ejemplo n.º 14
0
 def setUpTestData(cls):
     ed = EducationGroupFactory()
     EducationGroupYearFactory(education_group=ed)
     cls.person_information = ContinuingEducationPersonFactory()
     cls.admission = AdmissionFactory(
         person_information=cls.person_information,
         formation=ContinuingEducationTrainingFactory(education_group=ed))
     url = reverse('continuing_education_api_v1:registration-list',
                   kwargs={'uuid': cls.person_information.uuid})
     cls.serializer = RegistrationListSerializer(
         cls.admission, context={'request': RequestFactory().get(url)})
Ejemplo n.º 15
0
 def setUpTestData(cls):
     participant = PersonFactory()
     person_information = ContinuingEducationPersonFactory(
         person=participant)
     cls.admission = AdmissionFactory(person_information=person_information)
     cls.participant_file = AdmissionFileFactory(uploaded_by=participant)
     cls.manager = PersonFactory()
     cls.manager_file = AdmissionFileFactory(uploaded_by=cls.manager)
     other_manager = PersonFactory()
     cls.other_manager_file = AdmissionFileFactory(
         uploaded_by=other_manager)
     cls.context = {'user': cls.manager.user, 'admission': cls.admission}
Ejemplo n.º 16
0
 def setUpTestData(cls):
     ed = EducationGroupFactory()
     EducationGroupYearFactory(education_group=ed)
     cls.person_information = ContinuingEducationPersonFactory()
     cls.academic_year = AcademicYearFactory(year=2018)
     AcademicYearFactory(year=cls.academic_year.year + 1)
     cls.admission = AdmissionFactory(
         person_information=cls.person_information,
         formation=ContinuingEducationTrainingFactory(education_group=ed))
     url = reverse('continuing_education_api_v1:registration-detail-update',
                   kwargs={'uuid': cls.admission.uuid})
     cls.serializer = RegistrationDetailSerializer(
         cls.admission, context={'request': RequestFactory().get(url)})
Ejemplo n.º 17
0
 def setUpTestData(cls):
     cls.person_information = ContinuingEducationPersonFactory()
     cls.citizenship = CountryFactory()
     ed = EducationGroupFactory()
     EducationGroupYearFactory(education_group=ed)
     cls.formation = ContinuingEducationTrainingFactory(education_group=ed)
     cls.admission = AdmissionFactory(
         citizenship=cls.citizenship,
         person_information=cls.person_information,
         formation=cls.formation)
     url = reverse('continuing_education_api_v1:admission-detail-update',
                   kwargs={'uuid': cls.admission.uuid})
     cls.serializer = AdmissionPostSerializer(
         cls.admission, context={'request': RequestFactory().get(url)})
    def setUpTestData(cls):
        person_information = ContinuingEducationPersonFactory()
        cls.admission_file = AdmissionFileFactory(
            uploaded_by=person_information.person)
        cls.user = UserFactory()
        cls.url = reverse('continuing_education_api_v1:file-detail-delete',
                          kwargs={
                              'file_uuid': cls.admission_file.uuid,
                              'uuid': cls.admission_file.admission.uuid
                          })

        cls.invalid_url = reverse(
            'continuing_education_api_v1:file-detail-delete',
            kwargs={
                'uuid': uuid.uuid4(),
                'file_uuid': uuid.uuid4()
            })
Ejemplo n.º 19
0
 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))
Ejemplo n.º 20
0
 def setUpTestData(cls):
     cls.person_information = ContinuingEducationPersonFactory()
     ed = EducationGroupFactory()
     EducationGroupYearFactory(
         education_group=ed,
         academic_year=create_current_academic_year()
     )
     cls.formation = ContinuingEducationTrainingFactory(education_group=ed)
     cls.registration = AdmissionFactory(
         person_information=cls.person_information,
         formation=cls.formation
     )
     url = reverse(
         'continuing_education_api_v1:registration-detail-update',
         kwargs={'uuid': cls.registration.uuid}
     )
     cls.serializer = RegistrationPostSerializer(cls.registration, context={'request': RequestFactory().get(url)})
Ejemplo n.º 21
0
 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, registration_required=False)
     cls.manager = PersonWithPermissionsFactory('view_admission',
                                                'change_admission',
                                                groups=[MANAGERS_GROUP])
     cls.student_worker = PersonWithPermissionsFactory(
         'view_admission', groups=[STUDENT_WORKERS_GROUP])
     EntityVersionFactory(entity=cls.formation.management_entity)
     a_person_information = ContinuingEducationPersonFactory(
         person__gender='M')
     cls.admission = AdmissionFactory(
         formation=cls.formation,
         state=SUBMITTED,
         person_information=a_person_information,
     )
    def setUpTestData(cls):
        GroupFactory(name='continuing_education_managers')
        cls.academic_year = create_current_academic_year()
        cls.education_group = EducationGroupFactory()
        cls.user = UserFactory()
        EducationGroupYearFactory(education_group=cls.education_group,
                                  academic_year=cls.academic_year)
        cls.admission = AdmissionFactory(
            person_information=ContinuingEducationPersonFactory(
                person=PersonFactory(user=cls.user)),
            formation=ContinuingEducationTrainingFactory(
                education_group=cls.education_group),
            state=random.choice([ACCEPTED, REGISTRATION_SUBMITTED, VALIDATED]))

        cls.url = reverse(
            'continuing_education_api_v1:registration-detail-update',
            kwargs={'uuid': cls.admission.uuid})
        cls.invalid_url = reverse(
            'continuing_education_api_v1:registration-detail-update',
            kwargs={'uuid': uuid.uuid4()})
 def test_admission_ordering(self):
     ed = EducationGroupFactory()
     EducationGroupYearFactory(education_group=ed,
                               academic_year=self.academic_year,
                               acronym='M')
     cet = ContinuingEducationTrainingFactory(education_group=ed)
     ed_next = EducationGroupFactory()
     EducationGroupYearFactory(education_group=ed_next,
                               academic_year=self.academic_year,
                               acronym='O')
     cet_next = ContinuingEducationTrainingFactory(education_group=ed_next)
     persons_data = [('A', 'I', cet), ('D', 'J', cet), ('C', 'J', cet),
                     ('B', 'I', cet), ('E', 'K', cet_next),
                     ('H', 'L', cet_next), ('G', 'L', cet_next),
                     ('F', 'K', cet_next)]
     for first_name, name, formation in persons_data:
         a_person = ContinuingEducationPersonFactory(
             person=PersonFactory(first_name=first_name, last_name=name))
         AdmissionFactory(person_information=a_person, formation=formation)
     expected_order = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
     result = Admission.objects.all().values_list(
         'person_information__person__first_name', flat=True)
     self.assertEqual(list(result), expected_order)