Skip to content

Commit 87d74f7

Browse files
committed
Bump job.result() coverage back to 100%
1 parent 25f0260 commit 87d74f7

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

bigquery/tests/unit/test_job.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import concurrent
1516
import copy
1617
import json
1718
import textwrap
1819
import unittest
1920

2021
import mock
2122
import pytest
23+
import requests
2224
from six.moves import http_client
2325

2426
try:
@@ -4604,6 +4606,26 @@ def test_result_error(self):
46044606
expected_line = "{}:{}".format(i, line)
46054607
assert expected_line in full_text
46064608

4609+
def test_result_transport_timeout_error(self):
4610+
query = textwrap.dedent(
4611+
"""
4612+
SELECT foo, bar
4613+
FROM table_baz
4614+
WHERE foo == bar"""
4615+
)
4616+
4617+
client = _make_client(project=self.PROJECT)
4618+
job = self._make_one(self.JOB_ID, query, client)
4619+
call_api_patch = mock.patch(
4620+
"google.cloud.bigquery.client.Client._call_api",
4621+
autospec=True,
4622+
side_effect=requests.exceptions.Timeout("Server response took too long."),
4623+
)
4624+
4625+
# Make sure that timeout errors get rebranded to concurrent futures timeout.
4626+
with call_api_patch, self.assertRaises(concurrent.futures.TimeoutError):
4627+
job.result(timeout=1)
4628+
46074629
def test__begin_error(self):
46084630
from google.cloud import exceptions
46094631

0 commit comments

Comments
 (0)