From 4d42061e50feb063e54fd6a43aa70dbf2aa0a786 Mon Sep 17 00:00:00 2001 From: Tim Swast Date: Mon, 4 Feb 2019 14:53:30 -0800 Subject: [PATCH] Update error in system tests that expect error for wrong location (#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. --- tests/system.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/system.py b/tests/system.py index 1f0755cd6..04c4c3bf1 100644 --- a/tests/system.py +++ b/tests/system.py @@ -48,6 +48,7 @@ from google.api_core.exceptions import BadRequest from google.api_core.exceptions import Conflict from google.api_core.exceptions import Forbidden +from google.api_core.exceptions import GoogleAPICallError from google.api_core.exceptions import NotFound from google.api_core.exceptions import InternalServerError from google.api_core.exceptions import ServiceUnavailable @@ -765,17 +766,17 @@ def test_load_table_from_file_w_explicit_location(self): self.assertTrue(eu_query.done) # Cannot query from US. - with self.assertRaises(BadRequest): + with self.assertRaises(GoogleAPICallError): list(client.query(query_string, location="US", job_config=query_config)) # Cannot copy from US. - with self.assertRaises(BadRequest): + with self.assertRaises(GoogleAPICallError): client.copy_table( table_ref, dataset.table("letters2_us"), location="US" ).result() # Cannot extract from US. - with self.assertRaises(BadRequest): + with self.assertRaises(GoogleAPICallError): client.extract_table( table_ref, "gs://{}/letters-us.csv".format(bucket_name), location="US" ).result()