-
Notifications
You must be signed in to change notification settings - Fork 35
Add optional folder argument for file uploads to S3 Buckets #208
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
Changes from 2 commits
cc4d7ea
ae64538
d36f4b7
06eb6c9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -79,3 +79,46 @@ def test_upload_file_multiple_failures(minio_instance: MinIO): | |||||||||||||||
with patch("acquire.uploaders.plugin.log") as mocked_logger: | ||||||||||||||||
upload_files_using_uploader(minio_instance, [Path("hello")]) | ||||||||||||||||
mocked_logger.error.assert_called_with("Upload %s FAILED after too many attempts. Stopping.", Path("hello")) | ||||||||||||||||
|
||||||||||||||||
def test_minio_folder_initialization(minio_plugin): | ||||||||||||||||
arguments = { | ||||||||||||||||
"endpoint": "test", | ||||||||||||||||
"access_id": "test", | ||||||||||||||||
"access_key": "test", | ||||||||||||||||
"bucket": "test", | ||||||||||||||||
"folder": "Uploads/" | ||||||||||||||||
} | ||||||||||||||||
minio = minio_plugin(upload=arguments) | ||||||||||||||||
assert minio.folder == "Uploads" | ||||||||||||||||
|
||||||||||||||||
minio.folder = "Uploads/test_folder" | ||||||||||||||||
assert minio.folder == "Uploads/test_folder" | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part only tests the assignment of the
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're totally right, this is what I meant to do ;) |
||||||||||||||||
|
||||||||||||||||
arguments.pop("folder") | ||||||||||||||||
minio_no_folder = minio_plugin(upload=arguments) | ||||||||||||||||
assert minio_no_folder.folder == "" | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
def test_upload_file_with_folder(minio_instance: MinIO): | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||
mock_client = Mock() | ||||||||||||||||
test_path = Path("example.txt") | ||||||||||||||||
minio_instance.folder = 'test_folder' | ||||||||||||||||
minio_instance.upload_file(mock_client, test_path) | ||||||||||||||||
|
||||||||||||||||
mock_client.fput_object.assert_called_once_with( | ||||||||||||||||
"test", "test_folder/example.txt", test_path | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
|
||||||||||||||||
def test_upload_file_without_folder(minio_instance: MinIO): | ||||||||||||||||
mock_client = Mock() | ||||||||||||||||
minio_instance.folder = "" | ||||||||||||||||
mock_client = Mock() | ||||||||||||||||
test_path = Path("example.txt") | ||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
for consistency with the other test :) |
||||||||||||||||
minio_instance.upload_file(mock_client, test_path) | ||||||||||||||||
|
||||||||||||||||
mock_client.fput_object.assert_called_once_with( | ||||||||||||||||
"test", "example.txt", test_path | ||||||||||||||||
) | ||||||||||||||||
|
||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Callable
should probably be imported at the top first.