Skip to content

Commit

Permalink
Mock external calls in one of BigQuery unit tests (#8727)
Browse files Browse the repository at this point in the history
  • Loading branch information
plamut authored and tswast committed Jul 22, 2019
1 parent 1921389 commit 5bc8505
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 5bc8505

Please sign in to comment.