Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit 189f559

Browse files
committed
fix cover for retry.py
1 parent c0af0d0 commit 189f559

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

google/cloud/bigquery/retry.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ def _query_job_insert_should_retry(exc):
175175
# doesn't actually exist and try again. We can't add 404 to the default
176176
# job_retry because that happens for errors like "this table does not
177177
# exist", which probably won't resolve with a retry.
178-
179178
if isinstance(exc, exceptions.RetryError):
180179
exc = exc.cause
181180

tests/unit/test_client.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5414,9 +5414,14 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_retries_404_and_query
54145414
creds = _make_credentials()
54155415
http = object()
54165416
client = self._make_one(project=self.PROJECT, credentials=creds, _http=http)
5417+
5418+
# We're mocking QueryJob._begin, so that the connection should only get
5419+
# jobs.get requests.
5420+
job_create_error = google.api_core.exceptions.Conflict("Job already exists.")
5421+
job_begin_patcher = mock.patch.object(
5422+
bqjob.QueryJob, "_begin", side_effect=job_create_error
5423+
)
54175424
conn = client._connection = make_connection(
5418-
# We're mocking QueryJob._begin, so this is only going to be
5419-
# jobs.get requests and responses.
54205425
google.api_core.exceptions.NotFound("we lost your job again, sorry"),
54215426
{
54225427
"jobReference": {
@@ -5428,10 +5433,8 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_retries_404_and_query
54285433
)
54295434

54305435
# Choose a small deadline so the 404 retries give up.
5431-
retry = google.cloud.bigquery.retry.DEFAULT_RETRY.with_deadline(1)
5432-
job_create_error = google.api_core.exceptions.Conflict("Job already exists.")
5433-
job_begin_patcher = mock.patch.object(
5434-
bqjob.QueryJob, "_begin", side_effect=job_create_error
5436+
retry = (
5437+
google.cloud.bigquery.retry._DEFAULT_GET_JOB_CONFLICT_RETRY.with_deadline(1)
54355438
)
54365439
job_id_patcher = mock.patch.object(
54375440
google.cloud.bigquery._job_helpers,
@@ -5447,7 +5450,7 @@ def test_query_job_rpc_fail_w_conflict_random_id_job_fetch_retries_404_and_query
54475450
with freezegun.freeze_time(
54485451
"2025-01-01 00:00:00",
54495452
# 10x the retry deadline to guarantee a timeout.
5450-
auto_tick_seconds=100,
5453+
auto_tick_seconds=10,
54515454
), job_begin_patcher, job_id_patcher, retry_patcher:
54525455
# If get job request fails there does exist a job
54535456
# with this ID already, retry 404 until we get it (or fails for a

0 commit comments

Comments
 (0)