Skip to content

Commit

Permalink
Bump job.result() coverage back to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut committed Dec 11, 2019
1 parent 25f0260 commit 87d74f7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions bigquery/tests/unit/test_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import concurrent
import copy
import json
import textwrap
import unittest

import mock
import pytest
import requests
from six.moves import http_client

try:
Expand Down Expand Up @@ -4604,6 +4606,26 @@ def test_result_error(self):
expected_line = "{}:{}".format(i, line)
assert expected_line in full_text

def test_result_transport_timeout_error(self):
query = textwrap.dedent(
"""
SELECT foo, bar
FROM table_baz
WHERE foo == bar"""
)

client = _make_client(project=self.PROJECT)
job = self._make_one(self.JOB_ID, query, client)
call_api_patch = mock.patch(
"google.cloud.bigquery.client.Client._call_api",
autospec=True,
side_effect=requests.exceptions.Timeout("Server response took too long."),
)

# Make sure that timeout errors get rebranded to concurrent futures timeout.
with call_api_patch, self.assertRaises(concurrent.futures.TimeoutError):
job.result(timeout=1)

def test__begin_error(self):
from google.cloud import exceptions

Expand Down

0 comments on commit 87d74f7

Please sign in to comment.