-
Notifications
You must be signed in to change notification settings - Fork 3
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
Functions for checkout service #6
Conversation
cloud_blobstore/s3.py
Outdated
""" | ||
Checks if bucket with specified name exists. | ||
:param bucket: the bucket to be checked. | ||
:return: true if specified bucket exists in the AZ. |
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.
AZ?
cloud_blobstore/s3.py
Outdated
""" | ||
exists = True | ||
try: | ||
self.s3.meta.client.head_bucket(Bucket=bucket) |
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.
why not just self.s3_client.head_bucket(Bucket=bucket)?
@@ -277,3 +278,30 @@ def find_next_missing_parts( | |||
if parts_resp['IsTruncated'] and search_start == parts_resp['NextPartNumberMarker']: | |||
# finished examining the results of this batch, move onto the next one | |||
break | |||
|
|||
def check_bucket_exists(self, bucket: str) -> bool: |
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.
I think this is a bit of a misnomer. This tests if the bucket is accessible, not if it exists.
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.
if bucket is not accessible I'm also checking the error code.
If it was a 404 error, then the bucket does not exist.
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.
Ah you are right. I misread the documentation!
Thanks!
cloud_blobstore/s3.py
Outdated
""" | ||
Get region associated with a specified bucket name. | ||
:param bucket: the bucket to be checked. | ||
:return: region, Note that underying AWS API returns None for default US-East-1, |
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.
s/underying/underlying/
Ensure that the ``check_bucket_exists`` method returns true for FIXTURE AND TEST buckets. | ||
""" | ||
handle = self.handle # type: BlobStore | ||
self.assertEqual(handle.check_bucket_exists(self.test_fixtures_bucket), True) |
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.
There needs to be a negative test as well.
tests/test_s3blobstore.py
Outdated
Ensure that the ``get_bucket_region`` method returns true for FIXTURE and TEST buckets. | ||
""" | ||
handle = self.handle # type: BlobStore | ||
self.assertEqual(handle.get_bucket_region(self.test_fixtures_bucket), 'us-east-1') |
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.
There needs to be a non-us-east-1 test as well.
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.
great idea, do you have any recommendations as far as buckets available in the context of the test?
cloud_blobstore/__init__.py
Outdated
""" | ||
Checks if bucket with specified name exists. | ||
:param bucket: the bucket to be checked. | ||
:return: true if specified bucket exists in the AZ. |
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.
AZ?
cloud_blobstore/__init__.py
Outdated
""" | ||
Get region associated with a specified bucket name. | ||
:param bucket: the bucket to be checked. | ||
:return: region, Note that underying AWS API returns None for default US-East-1, |
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.
This does not belong here.
…ckerberg/cloud-blobstore into rkisin-checkout-functions
New functions to support checkout service requirements:
Testing
Added 2 new unit tests for TEST and Fixture buckets
TODO:
Implement Google version of these functions Issue