Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott committed Jul 27, 2017
1 parent 10edeb5 commit aa40d07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions storage/google/cloud/storage/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import requests
import six

from google.cloud import _helpers
from google.cloud import exceptions
from google.cloud.storage._http import Connection

Expand Down Expand Up @@ -284,9 +285,8 @@ def _generate_faux_mime_message(parser, response):
# We coerce to bytes to get consistent concat across
# Py2 and Py3. Percent formatting is insufficient since
# it includes the b in Py3.
content_type = response.headers.get('content-type', '')
if not isinstance(content_type, six.binary_type):
content_type = content_type.encode('utf-8')
content_type = _helpers._to_bytes(
response.headers.get('content-type', ''))

faux_message = b''.join([
b'Content-Type: ',
Expand Down
17 changes: 9 additions & 8 deletions storage/tests/unit/test_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ def test__make_request_GET_normal(self):

# Check the respone
self.assertEqual(response.status_code, 204)
self.assertIsInstance(response.content(), _FutureDict)
self.assertIs(target._properties, response.content())
self.assertIsInstance(response.json(), _FutureDict)
self.assertIsInstance(response.content, _FutureDict)
self.assertIs(target._properties, response.content)

# The real http request should not have been called yet.
http.request.assert_not_called()
Expand All @@ -170,8 +171,8 @@ def test__make_request_POST_normal(self):
'POST', url, data={'foo': 1}, target_object=target)

self.assertEqual(response.status_code, 204)
self.assertIsInstance(response.content(), _FutureDict)
self.assertIs(target._properties, response.content())
self.assertIsInstance(response.content, _FutureDict)
self.assertIs(target._properties, response.content)

# The real http request should not have been called yet.
http.request.assert_not_called()
Expand All @@ -196,8 +197,8 @@ def test__make_request_PATCH_normal(self):
'PATCH', url, data={'foo': 1}, target_object=target)

self.assertEqual(response.status_code, 204)
self.assertIsInstance(response.content(), _FutureDict)
self.assertIs(target._properties, response.content())
self.assertIsInstance(response.content, _FutureDict)
self.assertIs(target._properties, response.content)

# The real http request should not have been called yet.
http.request.assert_not_called()
Expand All @@ -221,8 +222,8 @@ def test__make_request_DELETE_normal(self):

# Check the respone
self.assertEqual(response.status_code, 204)
self.assertIsInstance(response.content(), _FutureDict)
self.assertIs(target._properties, response.content())
self.assertIsInstance(response.content, _FutureDict)
self.assertIs(target._properties, response.content)

# The real http request should not have been called yet.
http.request.assert_not_called()
Expand Down

0 comments on commit aa40d07

Please sign in to comment.