Example #1
0
    def test_download_file_without_preparation(self):
        is_prepared = tasks_api.file_is_prepared(self.course.id)
        last_file_date = tasks_api.get_last_file_date(self.course.id)
        response = self.client.get(self.download_url)

        self.assertFalse(is_prepared)
        self.assertIsNone(last_file_date)
        self.assertEqual(404, response.status_code)
Example #2
0
    def test_download_file(self):
        self.login_with_backoffice_group()
        response_prepare = self.client.post(self.prepare_url, follow=True)
        instructor_task = tasks.InstructorTask.objects.get()
        is_prepared = tasks_api.file_is_prepared(self.course.id)
        file_path = tasks_api.get_file_path(self.course.id)
        response = self.client.get(self.download_url)

        self.assertEqual("SUCCESS", instructor_task.task_state)
        self.assertTrue(is_prepared)
        self.assertIsNotNone(file_path)
        self.assertTrue(os.path.exists(file_path))
        self.assertTrue(response_prepare.redirect_chain[0][0].endswith(self.status_url))
        self.assertEqual(200, response.status_code)
        self.assertEqual('application/x-gzip', response['Content-Type'])
        self.assertNotEqual('', response.content)