Ejemplo n.º 1
0
    def post(self, request, *args, **kwargs):
        """ POST handler """
        if 'file' not in request.data:
            raise ParseError('No file content uploaded')

        csv_file = request.data['file']
        if csv_file.size > UPLOAD_FILE_MAX_SIZE:
            raise FileTooLarge()

        if is_enrollment_write_blocked(self.program.key):  # pylint: disable=no-member
            return Response('Job already in progress for program', HTTP_409_CONFLICT)

        enrollments = load_records_from_uploaded_csv(csv_file, self.field_names)
        return self.invoke_upload_job(self.task_fn, json.dumps(enrollments), *args, **kwargs)
Ejemplo n.º 2
0
 def test_read_job_does_not_block(self):
     task_name = build_enrollment_job_status_name(self.program.key, 'read', self.TASK_NAME)
     self.create_dummy_job_status(UserTaskStatus.IN_PROGRESS, self.user, task_name)
     self.assertFalse(is_enrollment_write_blocked(self.program.key))
Ejemplo n.º 3
0
 def test_processing_job_blocks(self, state, expected):
     task_name = build_enrollment_job_status_name(self.program.key, 'write', self.TASK_NAME)
     self.create_dummy_job_status(state, self.user, task_name)
     job_in_progress = is_enrollment_write_blocked(self.program.key)
     self.assertEqual(expected, job_in_progress)