def test_prepare_file_twice(self): # Prepare 1st file self.client.post(self.prepare_url) file_path1 = tasks_api.get_file_path(self.course.id) last_file_date1 = tasks_api.get_last_file_date(self.course.id) self.assertTrue(os.path.exists(file_path1)) # Prepare 2nd file self.client.post(self.prepare_url) file_path2 = tasks_api.get_file_path(self.course.id) last_file_date2 = tasks_api.get_last_file_date(self.course.id) self.assertFalse(os.path.exists(file_path1)) self.assertTrue(os.path.exists(file_path2)) self.assertLess(last_file_date1, last_file_date2)
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)