-
Notifications
You must be signed in to change notification settings - Fork 32
Add support for Python 3.12 & Django 5.2 #577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
|
|
||
| """ | ||
| Unit tests for django-storages | ||
| """ | ||
|
|
||
| from unittest import TestCase | ||
|
|
||
| from django.conf import settings | ||
| from django.test.utils import override_settings | ||
|
|
||
| from edxval.utils import get_video_image_storage, get_video_transcript_storage | ||
| from storages.backends.s3boto3 import S3Boto3Storage # pylint: disable=wrong-import-order | ||
|
|
||
|
|
||
| class S3Boto3TestCase(TestCase): | ||
| """Unit tests for verifying the S3Boto3 storage backend selection logic""" | ||
|
|
||
| def setUp(self): | ||
| self.storage = S3Boto3Storage() | ||
|
|
||
| def test_video_image_backend(self): | ||
| # settings file contains the `VIDEO_IMAGE_SETTINGS` but dont'have STORAGE_CLASS | ||
| # so it returns the default storage. | ||
|
|
||
| storage = get_video_image_storage() | ||
| storage_class = storage.__class__ | ||
|
|
||
| self.assertEqual( | ||
| 'django.core.files.storage.filesystem.FileSystemStorage', | ||
| f"{storage_class.__module__}.{storage_class.__name__}", | ||
| ) | ||
|
|
||
| @override_settings(VIDEO_IMAGE_SETTINGS={ | ||
| 'STORAGE_CLASS': 'storages.backends.s3boto3.S3Boto3Storage', | ||
| 'STORAGE_KWARGS': { | ||
| 'bucket_name': 'test', | ||
| 'default_acl': 'public', | ||
| 'location': 'abc/def' | ||
| } | ||
| }) | ||
| def test_video_image_backend_with_params(self): | ||
| storage = get_video_image_storage() | ||
| self.assertIsInstance(storage, S3Boto3Storage) | ||
| self.assertEqual(storage.bucket_name, "test") | ||
| self.assertEqual(storage.default_acl, 'public') | ||
| self.assertEqual(storage.location, "abc/def") | ||
|
|
||
| def test_video_image_without_storages_settings(self): | ||
| # Remove VIDEO_IMAGE_SETTINGS from settings safely | ||
| if hasattr(settings, 'VIDEO_IMAGE_SETTINGS'): | ||
| del settings.VIDEO_IMAGE_SETTINGS | ||
|
|
||
| storage = get_video_image_storage() | ||
| storage_class = storage.__class__ | ||
|
|
||
| self.assertEqual( | ||
| 'django.core.files.storage.filesystem.FileSystemStorage', | ||
| f"{storage_class.__module__}.{storage_class.__name__}", | ||
| ) | ||
|
|
||
| def test_video_transcript_backend(self): | ||
| # settings file contains the `VIDEO_TRANSCRIPTS_SETTINGS` but dont'have STORAGE_CLASS | ||
| # so it returns the default storage. | ||
|
|
||
| storage = get_video_transcript_storage() | ||
| storage_class = storage.__class__ | ||
|
|
||
| self.assertEqual( | ||
| 'django.core.files.storage.filesystem.FileSystemStorage', | ||
| f"{storage_class.__module__}.{storage_class.__name__}", | ||
| ) | ||
|
|
||
| @override_settings(VIDEO_TRANSCRIPTS_SETTINGS={ | ||
| 'STORAGE_CLASS': 'storages.backends.s3boto3.S3Boto3Storage', | ||
| 'STORAGE_KWARGS': { | ||
| 'bucket_name': 'test', | ||
| 'default_acl': 'private', | ||
| 'location': 'abc/' | ||
| } | ||
| }) | ||
| def test_transcript_storage_backend_with_params(self): | ||
| storage = get_video_transcript_storage() | ||
| self.assertIsInstance(storage, S3Boto3Storage) | ||
| self.assertEqual(storage.bucket_name, "test") | ||
| self.assertEqual(storage.default_acl, 'private') | ||
| self.assertEqual(storage.location, 'abc/') | ||
|
|
||
| def test_video_transcript_without_storages_settings(self): | ||
| # Remove VIDEO_TRANSCRIPTS_SETTINGS from settings. | ||
| if hasattr(settings, 'VIDEO_TRANSCRIPTS_SETTINGS'): | ||
| del settings.VIDEO_TRANSCRIPTS_SETTINGS | ||
|
|
||
| storage = get_video_transcript_storage() | ||
| storage_class = storage.__class__ | ||
|
|
||
| self.assertEqual( | ||
| 'django.core.files.storage.filesystem.FileSystemStorage', | ||
| f"{storage_class.__module__}.{storage_class.__name__}", | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.