Skip to content

Commit aa40d07

Browse files
author
Jon Wayne Parrott
committed
Address review comments
1 parent 10edeb5 commit aa40d07

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

storage/google/cloud/storage/batch.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import requests
2727
import six
2828

29+
from google.cloud import _helpers
2930
from google.cloud import exceptions
3031
from google.cloud.storage._http import Connection
3132

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

291291
faux_message = b''.join([
292292
b'Content-Type: ',

storage/tests/unit/test_batch.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ def test__make_request_GET_normal(self):
142142

143143
# Check the respone
144144
self.assertEqual(response.status_code, 204)
145-
self.assertIsInstance(response.content(), _FutureDict)
146-
self.assertIs(target._properties, response.content())
145+
self.assertIsInstance(response.json(), _FutureDict)
146+
self.assertIsInstance(response.content, _FutureDict)
147+
self.assertIs(target._properties, response.content)
147148

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

172173
self.assertEqual(response.status_code, 204)
173-
self.assertIsInstance(response.content(), _FutureDict)
174-
self.assertIs(target._properties, response.content())
174+
self.assertIsInstance(response.content, _FutureDict)
175+
self.assertIs(target._properties, response.content)
175176

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

198199
self.assertEqual(response.status_code, 204)
199-
self.assertIsInstance(response.content(), _FutureDict)
200-
self.assertIs(target._properties, response.content())
200+
self.assertIsInstance(response.content, _FutureDict)
201+
self.assertIs(target._properties, response.content)
201202

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

222223
# Check the respone
223224
self.assertEqual(response.status_code, 204)
224-
self.assertIsInstance(response.content(), _FutureDict)
225-
self.assertIs(target._properties, response.content())
225+
self.assertIsInstance(response.content, _FutureDict)
226+
self.assertIs(target._properties, response.content)
226227

227228
# The real http request should not have been called yet.
228229
http.request.assert_not_called()

0 commit comments

Comments
 (0)