Skip to content

Commit 5e2b474

Browse files
authored
Update error in system tests that expect error for wrong location (googleapis#7286)
We used to get BadRequest for querying with the wrong location. Now we get NotFound. I update the test to just look for the base class of GoogleAPICallError, since it seems we aren't guarnteed the actual status code.
1 parent 8c988bc commit 5e2b474

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

bigquery/tests/system.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
from google.api_core.exceptions import BadRequest
4949
from google.api_core.exceptions import Conflict
5050
from google.api_core.exceptions import Forbidden
51+
from google.api_core.exceptions import GoogleAPICallError
5152
from google.api_core.exceptions import NotFound
5253
from google.api_core.exceptions import InternalServerError
5354
from google.api_core.exceptions import ServiceUnavailable
@@ -765,17 +766,17 @@ def test_load_table_from_file_w_explicit_location(self):
765766
self.assertTrue(eu_query.done)
766767

767768
# Cannot query from US.
768-
with self.assertRaises(BadRequest):
769+
with self.assertRaises(GoogleAPICallError):
769770
list(client.query(query_string, location="US", job_config=query_config))
770771

771772
# Cannot copy from US.
772-
with self.assertRaises(BadRequest):
773+
with self.assertRaises(GoogleAPICallError):
773774
client.copy_table(
774775
table_ref, dataset.table("letters2_us"), location="US"
775776
).result()
776777

777778
# Cannot extract from US.
778-
with self.assertRaises(BadRequest):
779+
with self.assertRaises(GoogleAPICallError):
779780
client.extract_table(
780781
table_ref, "gs://{}/letters-us.csv".format(bucket_name), location="US"
781782
).result()

0 commit comments

Comments
 (0)