Skip to content

Commit

Permalink
Mock external calls in one of BigQuery unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut committed Jul 22, 2019
1 parent 1921389 commit 14896ee
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion bigquery/tests/unit/test_magics.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,17 @@ def test_bigquery_magic_w_maximum_bytes_billed_invalid():
ip.extension_manager.load_extension("google.cloud.bigquery")
magics.context._project = None

credentials_mock = mock.create_autospec(
google.auth.credentials.Credentials, instance=True
)
default_patch = mock.patch(
"google.auth.default", return_value=(credentials_mock, "general-project")
)
client_query_patch = mock.patch("google.cloud.bigquery.client.Client.query")

sql = "SELECT 17 AS num"

with pytest.raises(ValueError):
with pytest.raises(ValueError), default_patch, client_query_patch:
ip.run_cell_magic("bigquery", "--maximum_bytes_billed=abc", sql)


Expand Down

0 comments on commit 14896ee

Please sign in to comment.