示例#1
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}
示例#2
0
 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)
         )
示例#3
0
 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):
     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)})
示例#5
0
 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):
     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 test_admission_download_file(self):
     uploaded_file = SimpleUploadedFile(
         name='upload_test.pdf',
         content=str.encode('content'),
         content_type="application/pdf"
     )
     admission_file = AdmissionFileFactory(
         admission=self.admission,
         path=uploaded_file,
         uploaded_by=self.admission.person_information.person
     )
     url = reverse('download_file', kwargs={'admission_id': self.admission.pk, 'file_id': admission_file.pk})
     response = self.client.get(url)
     self.assertEqual(response.status_code, status.HTTP_200_OK)
示例#8
0
    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):
        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()
            })
    def setUp(self):
        ed = EducationGroupFactory()
        EducationGroupYearFactory(education_group=ed)
        self.manager = PersonFactory(last_name="AAA")
        self.manager.user.groups.add(GroupFactory(name=MANAGERS_GROUP))
        cet = ContinuingEducationTrainingFactory(education_group=ed)
        PersonTrainingFactory(person=self.manager, training=cet)
        PersonTrainingFactory(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,
        )
示例#11
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)
        group = GroupFactory(name='continuing_education_managers')
        cls.manager = PersonWithPermissionsFactory('view_admission',
                                                   'change_admission')
        cls.manager.user.groups.add(group)

        cls.admission = AdmissionFactory(formation=cls.formation,
                                         state=ACCEPTED)
        cls.admission_file = AdmissionFileFactory(admission=cls.admission)

        cls.url = reverse('send_invoice_notification_mail',
                          args=[cls.admission.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
        )

        cls.manager = ContinuingEducationManagerFactory()
        cls.admission = AdmissionFactory(
            formation=cls.formation,
            state=SUBMITTED
        )
        cls.admission_file = AdmissionFileFactory(
            admission=cls.admission
        )
 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='continuing_education_managers')
     cls.manager = PersonWithPermissionsFactory('view_admission', 'change_admission')
     cls.manager.user.groups.add(group)
     cls.admission = AdmissionFactory(
         formation=cls.formation,
         state=SUBMITTED
     )
     cls.admission_file = AdmissionFileFactory(
         admission=cls.admission
     )
    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.manager = ContinuingEducationManagerFactory()

        cls.admission = AdmissionFactory(
            formation=cls.formation,
            state=ACCEPTED
        )
        cls.admission_file = AdmissionFileFactory(
            admission=cls.admission
        )

        cls.url = reverse('send_invoice_notification_mail', args=[cls.admission.pk])