Skip to content

Commit 8f3f6e3

Browse files
committed
fix failing tests
1 parent 12b0ab4 commit 8f3f6e3

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

tests/unit/test_client_resumable_media_upload.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def _make_resumable_upload_responses(num_bytes):
8080
return [
8181
_make_response(
8282
http.client.OK,
83-
headers={"Location": "http://test.invalid/upload-id"},
83+
headers={"location": "http://test.invalid/upload-id"},
8484
),
8585
_make_response(
8686
http.client.OK, content=json.dumps({"size": num_bytes}).encode("utf-8")
@@ -197,15 +197,15 @@ def test_initiate_resumable_upload_with_retry():
197197

198198

199199
def _do_multipart_upload_success_helper(
200-
client, get_boundary, num_retries=None, project=None, mtls=False
200+
get_boundary, num_retries=None, project=None, mtls=False
201201
):
202202
from google.cloud.bigquery.client import _get_upload_headers
203203
from google.cloud.bigquery.job import LoadJob
204204
from google.cloud.bigquery.job import LoadJobConfig
205205
from google.cloud.bigquery.job import SourceFormat
206206

207207
fake_transport = _mock_transport(http.client.OK, {})
208-
client._transport = fake_transport
208+
client = _make_client(_http=fake_transport)
209209
conn = client._connection = make_connection()
210210
if mtls:
211211
conn.get_api_base_url_for_mtls = mock.Mock(return_value="https://foo.mtls")
@@ -233,7 +233,7 @@ def _do_multipart_upload_success_helper(
233233

234234
host_name = "https://foo.mtls" if mtls else "https://bigquery.googleapis.com"
235235
upload_url = (
236-
f"{host_name}/upload/bigquery/v2/projects/{project}" "?uploadType=multipart"
236+
f"{host_name}/upload/bigquery/v2/projects/{project}/jobs?uploadType=multipart"
237237
)
238238
payload = (
239239
b"--==0==\r\n"
@@ -256,26 +256,22 @@ def _do_multipart_upload_success_helper(
256256

257257
@mock.patch("google.resumable_media._upload.get_boundary", return_value=b"==0==")
258258
def test__do_multipart_upload(get_boundary):
259-
client = _make_client()
260-
_do_multipart_upload_success_helper(client, get_boundary)
259+
_do_multipart_upload_success_helper(get_boundary)
261260

262261

263262
@mock.patch("google.resumable_media._upload.get_boundary", return_value=b"==0==")
264263
def test__do_multipart_upload_mtls(get_boundary):
265-
client = _make_client()
266-
_do_multipart_upload_success_helper(client, get_boundary, mtls=True)
264+
_do_multipart_upload_success_helper(get_boundary, mtls=True)
267265

268266

269267
@mock.patch("google.resumable_media._upload.get_boundary", return_value=b"==0==")
270268
def test_do_multipart_upload_with_retry(get_boundary):
271-
client = _make_client()
272-
_do_multipart_upload_success_helper(client, get_boundary, num_retries=8)
269+
_do_multipart_upload_success_helper(get_boundary, num_retries=8)
273270

274271

275272
@mock.patch("google.resumable_media._upload.get_boundary", return_value=b"==0==")
276273
def test__do_multipart_upload_with_custom_project(get_boundary):
277-
client = _make_client()
278-
_do_multipart_upload_success_helper(client, get_boundary, project="custom-project")
274+
_do_multipart_upload_success_helper(get_boundary, project="custom-project")
279275

280276

281277
def test__do_resumable_upload():
@@ -388,7 +384,8 @@ def test__do_multipart_upload_wrong_size():
388384
def test_schema_from_json_with_file_path():
389385
from google.cloud.bigquery.schema import SchemaField
390386

391-
file_content = """[
387+
file_content = """
388+
[
392389
{
393390
"description": "quarter",
394391
"mode": "REQUIRED",

0 commit comments

Comments
 (0)