Skip to content

Commit

Permalink
Fixed some more pep8 errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Leyow authored and Kevin Leyow committed Sep 30, 2014
1 parent 76e360c commit cd0843f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
24 changes: 17 additions & 7 deletions gcloud/storage/test_bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,10 +254,13 @@ def test_upload_file_default_key(self):
BASENAME = 'file.ext'
FILENAME = '/path/to/%s' % BASENAME
_uploaded = []

class _Key(object):

def __init__(self, bucket, name):
self._bucket = bucket
self._name = name

def set_contents_from_filename(self, filename):
_uploaded.append((self._bucket, self._name, filename))
bucket = self._makeOne()
Expand Down Expand Up @@ -291,10 +294,13 @@ def test_upload_file_object_no_key(self):
FILENAME = 'file.txt'
FILEOBJECT = MockFile(FILENAME)
_uploaded = []

class _Key(object):

def __init__(self, bucket, name):
self._bucket = bucket
self._name = name

def set_contents_from_file(self, fh):
_uploaded.append((self._bucket, self._name, fh))
bucket = self._makeOne()
Expand All @@ -309,10 +315,13 @@ def test_upload_file_object_explicit_key(self):
FILEOBJECT = MockFile(FILENAME)
KEY = 'key'
_uploaded = []

class _Key(object):

def __init__(self, bucket, name):
self._bucket = bucket
self._name = name

def set_contents_from_file(self, fh):
_uploaded.append((self._bucket, self._name, fh))
bucket = self._makeOne()
Expand Down Expand Up @@ -682,8 +691,8 @@ def test_save_default_object_acl_existing_set_none_passed(self):
connection = _Connection({'foo': 'Foo', 'acl': []})
connection = _Connection({'foo': 'Foo', 'acl': []},
{'foo': 'Foo', 'acl': [],
'defaultObjectAcl': []},
)
'defaultObjectAcl': []},
)
metadata = {'defaultObjectAcl': []}
bucket = self._makeOne(connection, NAME, metadata)
bucket.reload_default_object_acl()
Expand All @@ -704,8 +713,8 @@ def test_save_default_object_acl_existing_set_new_passed(self):
new_acl = [{'entity': 'allUsers', 'role': ROLE}]
connection = _Connection({'foo': 'Foo', 'acl': new_acl},
{'foo': 'Foo', 'acl': new_acl,
'defaultObjectAcl': new_acl},
)
'defaultObjectAcl': new_acl},
)
metadata = {'defaultObjectAcl': []}
bucket = self._makeOne(connection, NAME, metadata)
bucket.reload_default_object_acl()
Expand All @@ -727,8 +736,8 @@ def test_clear_default_object_acl(self):
old_acl = [{'entity': 'allUsers', 'role': ROLE}]
connection = _Connection({'foo': 'Foo', 'acl': []},
{'foo': 'Foo', 'acl': [],
'defaultObjectAcl': []},
)
'defaultObjectAcl': []},
)
metadata = {'defaultObjectAcl': old_acl}
bucket = self._makeOne(connection, NAME, metadata)
bucket.reload_default_object_acl()
Expand Down Expand Up @@ -872,6 +881,7 @@ def delete_bucket(self, bucket, force=False):

class MockFile(io.StringIO):
name = None
def __init__(self, name, buffer_ = None):

def __init__(self, name, buffer_=None):
super(MockFile, self).__init__(buffer_)
self.name = name
12 changes: 5 additions & 7 deletions gcloud/storage/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test_build_api_url_w_extra_query_params(self):
'storage',
conn.API_VERSION,
'foo'
])
])
uri = conn.build_api_url('/foo', {'bar': 'baz'})
scheme, netloc, path, qs, frag = urlsplit(uri)
self.assertEqual('%s://%s' % (scheme, netloc), conn.API_BASE_URL)
Expand Down Expand Up @@ -217,19 +217,17 @@ def test_api_request_defaults(self):
URI = '/'.join([conn.API_BASE_URL,
'storage',
conn.API_VERSION,
'%s?project=%s' % (PATH, PROJECT)
])
]) + '%s?project=%s' % (PATH, PROJECT)
http = conn._http = Http({'status': '200',
'content-type': 'application/json',
},
'{}')
self.assertEqual(conn.api_request('GET', '/'), {})
}, '{}')
self.assertEqual(conn.api_request('GET', PATH), {})
self.assertEqual(http._called_with['method'], 'GET')
self.assertEqual(http._called_with['uri'], URI)
self.assertEqual(http._called_with['body'], None)
self.assertEqual(http._called_with['headers'],
{'Accept-Encoding': 'gzip',
'Content-Length': 0,
'Content-Length': 0,
})

def test_api_request_w_non_json_response(self):
Expand Down
2 changes: 1 addition & 1 deletion gcloud/storage/test_iterator.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def test__iter__(self):
response2['content-range'] = '10-14/15'
connection = _Connection((response1, '0123456789'),
(response2, '01234'),
)
)
key = _Key(connection)
iterator = self._makeOne(key)
chunks = list(iterator)
Expand Down
2 changes: 1 addition & 1 deletion gcloud/storage/test_key.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def test_set_contents_from_string(self):
connection = _Connection((loc_response, ''),
(chunk1_response, ''),
(chunk2_response, ''),
)
)
bucket = _Bucket(connection)
key = self._makeOne(bucket, KEY)
key.CHUNK_SIZE = 5
Expand Down

0 comments on commit cd0843f

Please sign in to comment.