Skip to content
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

fix s3 delete_many #38

Merged
merged 5 commits into from
Jul 14, 2017
Merged

fix s3 delete_many #38

merged 5 commits into from
Jul 14, 2017

Conversation

itajaja
Copy link
Member

@itajaja itajaja commented Jul 14, 2017

Couldn't find any documentation around this issue, but I empirically discovered that delete_objects with an empty array causes the request to fail. Also, this is a valid optimization anyway.

Couldn't find any documentation around this issue, but I empirically discovered that `delete_objects` with an empty array causes the request to fail. Also, this is a valid optimization anyway.
@taion
Copy link
Contributor

taion commented Jul 14, 2017

Add a quick test.

tests/test_s3.py Outdated
def assert_not_called(*args, **kwargs):
assert(False)

monkeypatch.setattr(annex._client, 'delete_objects', assert_not_called)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use a mock and actually assert it's not called, instead of this thing?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I didn't think it was worth adding a dependency

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what dependency? isn't mock in python3?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but tests run also on py2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding that dev dep is fine/better

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mkay

@@ -40,11 +40,15 @@ def delete(self, key):
self._client.delete_object(Bucket=self._bucket_name, Key=key)

def delete_many(self, keys):
objects = tuple({'Key': key} for key in keys)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably worth noting that you're doing this first because keys may be an iterable

Copy link
Contributor

@taion taion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one last nit, then :shipit:

tests/test_s3.py Outdated
@@ -12,6 +12,7 @@

try:
import boto3
from mock import Mock
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

install this unconditionally and take this out of the try/catch imo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@itajaja itajaja merged commit b8c6aec into master Jul 14, 2017
@itajaja itajaja deleted the fix-s3-delete_many branch July 14, 2017 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants