Skip to content

Commit

Permalink
Merge branch 'integ-windows' into develop
Browse files Browse the repository at this point in the history
* integ-windows:
  Fix pep8 formatting
  Fix s3 integration tests on windows
  • Loading branch information
jamesls committed Dec 9, 2014
2 parents 33f608e + b8c5366 commit 459da7f
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions tests/integration/test_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ def create_multipart_upload(self, key_name):
bucket=self.bucket_name,
key=key_name)
upload_id = parsed['UploadId']
self.addCleanup(self.service.get_operation('AbortMultipartUpload').call,
self.endpoint, upload_id=upload_id,
bucket=self.bucket_name, key=key_name)
self.addCleanup(
self.service.get_operation('AbortMultipartUpload').call,
self.endpoint, upload_id=upload_id,
bucket=self.bucket_name, key=key_name)

def create_object_catch_exceptions(self, key_name):
try:
Expand Down Expand Up @@ -108,8 +109,10 @@ def setUp(self):
self.bucket_location = 'us-west-2'

operation = self.service.get_operation('CreateBucket')
response = operation.call(self.endpoint, bucket=self.bucket_name,
create_bucket_configuration={'LocationConstraint': self.bucket_location})
location = {'LocationConstraint': self.bucket_location}
response = operation.call(
self.endpoint, bucket=self.bucket_name,
create_bucket_configuration=location)
self.assertEqual(response[0].status_code, 200)

def tearDown(self):
Expand Down Expand Up @@ -159,7 +162,8 @@ def test_can_delete_urlencoded_object(self):
self.assertEqual(bucket_contents[0]['Key'], 'a+b/foo')

subdir_contents = self.service.get_operation('ListObjects').call(
self.endpoint, bucket=self.bucket_name, prefix='a+b')[1]['Contents']
self.endpoint,
bucket=self.bucket_name, prefix='a+b')[1]['Contents']
self.assertEqual(len(subdir_contents), 1)
self.assertEqual(subdir_contents[0]['Key'], 'a+b/foo')

Expand Down Expand Up @@ -312,7 +316,8 @@ def test_unicode_key_put_list(self):
self.assertEqual(len(parsed['Contents']), 1)
self.assertEqual(parsed['Contents'][0]['Key'], key_name)
operation = self.service.get_operation('GetObject')
parsed = operation.call(self.endpoint, bucket=self.bucket_name, key=key_name)[1]
parsed = operation.call(self.endpoint, bucket=self.bucket_name,
key=key_name)[1]
self.assertEqual(parsed['Body'].read().decode('utf-8'), 'foo')

def test_thread_safe_auth(self):
Expand All @@ -335,7 +340,8 @@ def test_thread_safe_auth(self):
"Unexpectedly caught exceptions: %s" % self.caught_exceptions)
self.assertEqual(
len(set(self.auth_paths)), 10,
"Expected 10 unique auth paths, instead received: %s" % (self.auth_paths))
"Expected 10 unique auth paths, instead received: %s" %
(self.auth_paths))

def test_non_normalized_key_paths(self):
# The create_object method has assertEqual checks for 200 status.
Expand Down Expand Up @@ -493,8 +499,10 @@ def setUp(self):
self.bucket_location = 'us-west-2'

operation = self.service.get_operation('CreateBucket')
response = operation.call(self.endpoint, bucket=self.bucket_name,
create_bucket_configuration={'LocationConstraint': self.bucket_location})
location = {'LocationConstraint': self.bucket_location}
response = operation.call(
self.endpoint, bucket=self.bucket_name,
create_bucket_configuration=location)
self.assertEqual(response[0].status_code, 200)
self.keys = []

Expand All @@ -514,10 +522,10 @@ def test_bucket_in_other_region(self):
f.write('foobarbaz' * 1024 * 1024)
f.flush()
op = self.service.get_operation('PutObject')
response = op.call(self.endpoint,
bucket=self.bucket_name,
key='foo.txt',
body=open(f.name, 'rb'))
with open(f.name, 'rb') as body_file:
response = op.call(
self.endpoint, bucket=self.bucket_name,
key='foo.txt', body=body_file)
self.assertEqual(response[0].status_code, 200)
self.keys.append('foo.txt')

Expand All @@ -528,10 +536,10 @@ def test_bucket_in_other_region_using_http(self):
f.write('foobarbaz' * 1024 * 1024)
f.flush()
op = self.service.get_operation('PutObject')
response = op.call(http_endpoint,
bucket=self.bucket_name,
key='foo.txt',
body=open(f.name, 'rb'))
with open(f.name, 'rb') as body_file:
response = op.call(
http_endpoint, bucket=self.bucket_name,
key='foo.txt', body=body_file)
self.assertEqual(response[0].status_code, 200)
self.keys.append('foo.txt')

Expand All @@ -545,8 +553,10 @@ def setUp(self):
self.bucket_location = 'eu-central-1'

operation = self.service.get_operation('CreateBucket')
response = operation.call(self.endpoint, bucket=self.bucket_name,
create_bucket_configuration={'LocationConstraint': self.bucket_location})
location = {'LocationConstraint': self.bucket_location}
response = operation.call(
self.endpoint, bucket=self.bucket_name,
create_bucket_configuration=location)
self.assertEqual(response[0].status_code, 200)
self.keys = []

Expand All @@ -564,12 +574,14 @@ def test_request_retried_for_sigv4(self):
original_send = adapters.HTTPAdapter.send
state = mock.Mock()
state.error_raised = False

def mock_http_adapter_send(self, *args, **kwargs):
if not state.error_raised:
state.error_raised = True
raise ConnectionError("Simulated ConnectionError raised.")
else:
return original_send(self, *args, **kwargs)

with mock.patch('botocore.vendored.requests.adapters.HTTPAdapter.send',
mock_http_adapter_send):
response = operation.call(self.endpoint,
Expand Down

0 comments on commit 459da7f

Please sign in to comment.