Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit abceb1b

Browse files
authored
Merge branch 'master' into fileio
2 parents 3160173 + 4868be3 commit abceb1b

File tree

4 files changed

+56
-8
lines changed

4 files changed

+56
-8
lines changed

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@
44

55
[1]: https://pypi.org/project/google-cloud-storage/#history
66

7+
### [1.36.2](https://www.github.com/googleapis/python-storage/compare/v1.36.1...v1.36.2) (2021-03-09)
8+
9+
10+
### Bug Fixes
11+
12+
* update batch connection to request api endpoint info from client ([#392](https://www.github.com/googleapis/python-storage/issues/392)) ([91fc6d9](https://www.github.com/googleapis/python-storage/commit/91fc6d9870a36308b15a827ed6a691e5b4669b62))
13+
14+
### [1.36.1](https://www.github.com/googleapis/python-storage/compare/v1.36.0...v1.36.1) (2021-02-19)
15+
16+
17+
### Bug Fixes
18+
19+
* allow metadata keys to be cleared ([#383](https://www.github.com/googleapis/python-storage/issues/383)) ([79d27da](https://www.github.com/googleapis/python-storage/commit/79d27da9fe842e44a9091076ea0ef52c5ef5ff72)), closes [#381](https://www.github.com/googleapis/python-storage/issues/381)
20+
* allow signed url version v4 without signed credentials ([#356](https://www.github.com/googleapis/python-storage/issues/356)) ([3e69bf9](https://www.github.com/googleapis/python-storage/commit/3e69bf92496616c5de28094dd42260b35c3bf982))
21+
* correctly encode bytes for V2 signature ([#382](https://www.github.com/googleapis/python-storage/issues/382)) ([f44212b](https://www.github.com/googleapis/python-storage/commit/f44212b7b91a67ca661898400fe632f9fb3ec8f6))
22+
723
## [1.36.0](https://www.github.com/googleapis/python-storage/compare/v1.35.1...v1.36.0) (2021-02-10)
824

925

google/cloud/storage/batch.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ class Batch(Connection):
147147
_MAX_BATCH_SIZE = 1000
148148

149149
def __init__(self, client):
150-
super(Batch, self).__init__(client)
150+
api_endpoint = client._connection.API_BASE_URL
151+
client_info = client._connection._client_info
152+
super(Batch, self).__init__(
153+
client, client_info=client_info, api_endpoint=api_endpoint
154+
)
151155
self._requests = []
152156
self._target_objects = []
153157

google/cloud/storage/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
__version__ = "1.36.0"
15+
__version__ = "1.36.2"

tests/unit/test_batch.py

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def test__make_request_GET_normal(self):
136136
url = "http://example.com/api"
137137
http = _make_requests_session([])
138138
connection = _Connection(http=http)
139-
batch = self._make_one(connection)
139+
client = _Client(connection)
140+
batch = self._make_one(client)
140141
target = _MockObject()
141142

142143
response = batch._make_request("GET", url, target_object=target)
@@ -164,7 +165,8 @@ def test__make_request_POST_normal(self):
164165
url = "http://example.com/api"
165166
http = _make_requests_session([])
166167
connection = _Connection(http=http)
167-
batch = self._make_one(connection)
168+
client = _Client(connection)
169+
batch = self._make_one(client)
168170
data = {"foo": 1}
169171
target = _MockObject()
170172

@@ -191,7 +193,8 @@ def test__make_request_PATCH_normal(self):
191193
url = "http://example.com/api"
192194
http = _make_requests_session([])
193195
connection = _Connection(http=http)
194-
batch = self._make_one(connection)
196+
client = _Client(connection)
197+
batch = self._make_one(client)
195198
data = {"foo": 1}
196199
target = _MockObject()
197200

@@ -218,7 +221,8 @@ def test__make_request_DELETE_normal(self):
218221
url = "http://example.com/api"
219222
http = _make_requests_session([])
220223
connection = _Connection(http=http)
221-
batch = self._make_one(connection)
224+
client = _Client(connection)
225+
batch = self._make_one(client)
222226
target = _MockObject()
223227

224228
response = batch._make_request("DELETE", url, target_object=target)
@@ -243,7 +247,8 @@ def test__make_request_POST_too_many_requests(self):
243247
url = "http://example.com/api"
244248
http = _make_requests_session([])
245249
connection = _Connection(http=http)
246-
batch = self._make_one(connection)
250+
client = _Client(connection)
251+
batch = self._make_one(client)
247252

248253
batch._MAX_BATCH_SIZE = 1
249254
batch._requests.append(("POST", url, {}, {"bar": 2}))
@@ -254,7 +259,8 @@ def test__make_request_POST_too_many_requests(self):
254259
def test_finish_empty(self):
255260
http = _make_requests_session([])
256261
connection = _Connection(http=http)
257-
batch = self._make_one(connection)
262+
client = _Client(connection)
263+
batch = self._make_one(client)
258264

259265
with self.assertRaises(ValueError):
260266
batch.finish()
@@ -518,6 +524,25 @@ def test_as_context_mgr_w_error(self):
518524
self.assertIsInstance(target2._properties, _FutureDict)
519525
self.assertIsInstance(target3._properties, _FutureDict)
520526

527+
def test_respect_client_existing_connection(self):
528+
client_endpoint = "http://localhost:9023"
529+
http = _make_requests_session([])
530+
connection = _Connection(http=http, api_endpoint=client_endpoint)
531+
client = _Client(connection)
532+
batch = self._make_one(client)
533+
self.assertEqual(batch.API_BASE_URL, client_endpoint)
534+
self.assertEqual(batch._client._connection.API_BASE_URL, client_endpoint)
535+
536+
def test_use_default_api_without_existing_connection(self):
537+
default_api_endpoint = "https://storage.googleapis.com"
538+
http = _make_requests_session([])
539+
connection = _Connection(http=http)
540+
client = _Client(connection)
541+
batch = self._make_one(client)
542+
self.assertEqual(batch.API_BASE_URL, default_api_endpoint)
543+
self.assertIsNone(batch._client._connection.API_BASE_URL)
544+
self.assertIsNone(batch._client._connection._client_info)
545+
521546

522547
class Test__unpack_batch_response(unittest.TestCase):
523548
def _call_fut(self, headers, content):
@@ -633,6 +658,8 @@ class _Connection(object):
633658

634659
def __init__(self, **kw):
635660
self.__dict__.update(kw)
661+
self._client_info = kw.get("client_info", None)
662+
self.API_BASE_URL = kw.get("api_endpoint", None)
636663

637664
def _make_request(self, method, url, data=None, headers=None, timeout=None):
638665
return self.http.request(
@@ -647,3 +674,4 @@ class _MockObject(object):
647674
class _Client(object):
648675
def __init__(self, connection):
649676
self._base_connection = connection
677+
self._connection = connection

0 commit comments

Comments
 (0)