fix: removing s3boto storage backend. (#31876)

* fix: removing s3boto storage backend
This commit is contained in:
Awais Qureshi
2023-03-13 13:32:19 +05:00
committed by GitHub
parent a4ee38dc39
commit 2ae2fbd4f5
5 changed files with 15 additions and 30 deletions

View File

@@ -27,7 +27,6 @@ from edx_django_utils.monitoring import set_custom_attribute, set_custom_attribu
from opaque_keys.edx.keys import CourseKey
from opaque_keys.edx.locator import LibraryLocator
from path import Path as path
from storages.backends.s3boto import S3BotoStorage
from storages.backends.s3boto3 import S3Boto3Storage
from user_tasks.conf import settings as user_tasks_settings
from user_tasks.models import UserTaskArtifact, UserTaskStatus
@@ -381,14 +380,6 @@ def export_status_handler(request, course_key_string):
artifact = UserTaskArtifact.objects.get(status=task_status, name='Output')
if isinstance(artifact.file.storage, FileSystemStorage):
output_url = reverse_course_url('export_output_handler', course_key)
elif isinstance(artifact.file.storage, S3BotoStorage):
filename = os.path.basename(artifact.file.name)
disposition = f'attachment; filename="{filename}"'
output_url = artifact.file.storage.url(artifact.file.name, response_headers={
'response-content-disposition': disposition,
'response-content-encoding': 'application/octet-stream',
'response-content-type': 'application/x-tgz'
})
elif isinstance(artifact.file.storage, S3Boto3Storage):
filename = os.path.basename(artifact.file.name)
disposition = f'attachment; filename="{filename}"'

View File

@@ -25,7 +25,6 @@ from django.test.utils import override_settings
from milestones.tests.utils import MilestonesTestCaseMixin
from opaque_keys.edx.locator import LibraryLocator
from path import Path as path
from storages.backends.s3boto import S3BotoStorage
from storages.backends.s3boto3 import S3Boto3Storage
from user_tasks.models import UserTaskStatus
@@ -958,7 +957,7 @@ class ExportTestCase(CourseTestCase):
"""
Verify that the export status handler generates the correct export path
for storage providers other than ``FileSystemStorage`` and
``S3BotoStorage``
``S3Boto3Storage``
"""
mock_latest_task_status.return_value = Mock(state=UserTaskStatus.SUCCEEDED)
mock_get_user_task_artifact.return_value = self._mock_artifact(
@@ -968,7 +967,7 @@ class ExportTestCase(CourseTestCase):
result = json.loads(resp.content.decode('utf-8'))
self.assertEqual(result['ExportOutput'], '/path/to/testfile.tar.gz')
@ddt.data(S3BotoStorage, S3Boto3Storage)
@ddt.data(S3Boto3Storage)
@patch('cms.djangoapps.contentstore.views.import_export._latest_task_status')
@patch('user_tasks.models.UserTaskArtifact.objects.get')
def test_export_status_handler_s3(
@@ -979,7 +978,7 @@ class ExportTestCase(CourseTestCase):
):
"""
Verify that the export status handler generates the correct export path
for the ``S3BotoStorage`` storage provider
for the ``S3Boto3Storage`` storage provider
"""
mock_latest_task_status.return_value = Mock(state=UserTaskStatus.SUCCEEDED)
mock_get_user_task_artifact.return_value = self._mock_artifact(