|
17 | 17 | import unittest |
18 | 18 | from unittest import mock |
19 | 19 |
|
20 | | -from google.api_core import exceptions |
21 | | -import google.api_core.retry |
22 | 20 | from google.api_core.future import polling |
23 | 21 | import pytest |
24 | 22 |
|
@@ -882,50 +880,6 @@ def test_cancel_explicit(self): |
882 | 880 | ) |
883 | 881 | self.assertEqual(job._properties, expected) |
884 | 882 |
|
885 | | - def test_cancel_w_custom_retry(self): |
886 | | - from google.cloud.bigquery.retry import DEFAULT_RETRY |
887 | | - |
888 | | - api_path = "/projects/{}/jobs/{}/cancel".format(self.PROJECT, self.JOB_ID) |
889 | | - resource = { |
890 | | - "jobReference": { |
891 | | - "jobId": self.JOB_ID, |
892 | | - "projectId": self.PROJECT, |
893 | | - "location": None, |
894 | | - }, |
895 | | - "configuration": {"test": True}, |
896 | | - } |
897 | | - expected = resource.copy() |
898 | | - expected["statistics"] = {} |
899 | | - response = {"job": resource} |
900 | | - job = self._set_properties_job() |
901 | | - |
902 | | - api_request_patcher = mock.patch.object( |
903 | | - job._client._connection, "api_request", side_effect=[ValueError, response] |
904 | | - ) |
905 | | - retry = DEFAULT_RETRY.with_deadline(1).with_predicate( |
906 | | - lambda exc: isinstance(exc, ValueError) |
907 | | - ) |
908 | | - |
909 | | - with api_request_patcher as fake_api_request: |
910 | | - with mock.patch( |
911 | | - "google.cloud.bigquery.opentelemetry_tracing._get_final_span_attributes" |
912 | | - ) as final_attributes: |
913 | | - result = job.cancel(retry=retry, timeout=7.5) |
914 | | - |
915 | | - final_attributes.assert_called() |
916 | | - |
917 | | - self.assertTrue(result) |
918 | | - self.assertEqual(job._properties, expected) |
919 | | - self.assertEqual( |
920 | | - fake_api_request.call_args_list, |
921 | | - [ |
922 | | - mock.call(method="POST", path=api_path, query_params={}, timeout=7.5), |
923 | | - mock.call( |
924 | | - method="POST", path=api_path, query_params={}, timeout=7.5 |
925 | | - ), # was retried once |
926 | | - ], |
927 | | - ) |
928 | | - |
929 | 883 | def test__set_future_result_wo_done(self): |
930 | 884 | client = _make_client(project=self.PROJECT) |
931 | 885 | job = self._make_one(self.JOB_ID, client) |
@@ -1069,64 +1023,6 @@ def test_result_default_wo_state(self): |
1069 | 1023 | ) |
1070 | 1024 | conn.api_request.assert_has_calls([begin_call, begin_call, reload_call]) |
1071 | 1025 |
|
1072 | | - def test_result_w_retry_wo_state(self): |
1073 | | - from google.cloud.bigquery.retry import DEFAULT_GET_JOB_TIMEOUT |
1074 | | - |
1075 | | - begun_job_resource = _make_job_resource( |
1076 | | - job_id=self.JOB_ID, project_id=self.PROJECT, location="EU", started=True |
1077 | | - ) |
1078 | | - done_job_resource = _make_job_resource( |
1079 | | - job_id=self.JOB_ID, |
1080 | | - project_id=self.PROJECT, |
1081 | | - location="EU", |
1082 | | - started=True, |
1083 | | - ended=True, |
1084 | | - ) |
1085 | | - conn = make_connection( |
1086 | | - exceptions.NotFound("not normally retriable"), |
1087 | | - begun_job_resource, |
1088 | | - exceptions.NotFound("not normally retriable"), |
1089 | | - done_job_resource, |
1090 | | - ) |
1091 | | - client = _make_client(project=self.PROJECT, connection=conn) |
1092 | | - job = self._make_one( |
1093 | | - self._job_reference(self.JOB_ID, self.PROJECT, "EU"), client |
1094 | | - ) |
1095 | | - custom_predicate = mock.Mock() |
1096 | | - custom_predicate.return_value = True |
1097 | | - custom_retry = google.api_core.retry.Retry( |
1098 | | - predicate=custom_predicate, |
1099 | | - initial=0.001, |
1100 | | - maximum=0.001, |
1101 | | - deadline=0.1, |
1102 | | - ) |
1103 | | - self.assertIs(job.result(retry=custom_retry), job) |
1104 | | - |
1105 | | - begin_call = mock.call( |
1106 | | - method="POST", |
1107 | | - path=f"/projects/{self.PROJECT}/jobs", |
1108 | | - data={ |
1109 | | - "jobReference": { |
1110 | | - "jobId": self.JOB_ID, |
1111 | | - "projectId": self.PROJECT, |
1112 | | - "location": "EU", |
1113 | | - } |
1114 | | - }, |
1115 | | - timeout=None, |
1116 | | - ) |
1117 | | - reload_call = mock.call( |
1118 | | - method="GET", |
1119 | | - path=f"/projects/{self.PROJECT}/jobs/{self.JOB_ID}", |
1120 | | - query_params={ |
1121 | | - "projection": "full", |
1122 | | - "location": "EU", |
1123 | | - }, |
1124 | | - timeout=DEFAULT_GET_JOB_TIMEOUT, |
1125 | | - ) |
1126 | | - conn.api_request.assert_has_calls( |
1127 | | - [begin_call, begin_call, reload_call, reload_call] |
1128 | | - ) |
1129 | | - |
1130 | 1026 | def test_result_explicit_w_state(self): |
1131 | 1027 | conn = make_connection() |
1132 | 1028 | client = _make_client(project=self.PROJECT, connection=conn) |
|
0 commit comments