Last active
March 23, 2018 19:58
-
-
Save jamesls/9e1f0eb8e6b632f62ea5cb38131de2ae to your computer and use it in GitHub Desktop.
One off integ test to verify head object behavior
This file contains 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
# -*- coding: utf-8 -*- | |
import botocore.session | |
from botocore.exceptions import ClientError | |
import logging | |
import pytest | |
LOG = logging.getLogger('botocore.tests.integration') | |
session = botocore.session.get_session() | |
session.set_debug_logger('') | |
regions = session.get_available_regions('s3') | |
REGION_TO_BUCKETS = { | |
'ap-northeast-1': 'YOURPREFIX-ap-northeast-1', | |
'ap-northeast-2': 'YOURPREFIX-ap-northeast-2', | |
'ap-south-1': 'YOURPREFIX-ap-south-1', | |
'ap-southeast-1': 'YOURPREFIX-ap-southeast-1', | |
'ap-southeast-2': 'YOURPREFIX-ap-southeast-2', | |
'ca-central-1': 'YOURPREFIX-ca-central-1', | |
'eu-central-1': 'YOURPREFIX-eu-central-1', | |
'eu-west-1': 'YOURPREFIX-eu-west-1', | |
'eu-west-2': 'YOURPREFIX-eu-west-2', | |
'eu-west-3': 'YOURPREFIX-eu-west-3', | |
'sa-east-1': 'YOURPREFIX-sa-east-1', | |
'us-east-1': 'YOURPREFIX-us-east-1', | |
'us-east-2': 'YOURPREFIX-us-east-2', | |
'us-west-1': 'YOURPREFIX-us-west-1', | |
'us-west-2': 'YOURPREFIX-us-west-2', | |
} | |
# For every combination of a client configured region and | |
# a bucket in a specific region, verify we can make a head_object | |
# request. | |
@pytest.mark.parametrize("configured_region", regions) | |
@pytest.mark.parametrize("bucket_region", regions) | |
def test_can_head_objects(configured_region, bucket_region): | |
client = session.create_client('s3', region_name=configured_region) | |
bucket_name = REGION_TO_BUCKETS[bucket_region] | |
# This assumes that the 'foo' key already exists in the bucket. | |
key_name = 'foo' | |
client.head_object(Bucket=bucket_name, Key=key_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: