File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1818on :mod:`google.api_core`, including both HTTP and gRPC clients.
1919"""
2020
21- from __future__ import absolute_import , unicode_literals
21+ from __future__ import absolute_import
22+ from __future__ import unicode_literals
2223
2324import http .client
25+ from typing import Optional , Dict
2426import warnings
25- from typing import Dict , Optional
2627
2728from google .rpc import error_details_pb2
2829
@@ -656,20 +657,9 @@ def from_grpc_error(rpc_exc):
656657 grpc is not None and isinstance (rpc_exc , grpc .Call )
657658 ) or _is_informative_grpc_error (rpc_exc ):
658659 details , err_info = _parse_grpc_error_details (rpc_exc )
659- message = rpc_exc .details ()
660- if (
661- grpc is not None
662- and rpc_exc .code () == grpc .StatusCode .UNIMPLEMENTED
663- and "Received http2 header with status: 404" in message
664- ):
665- message = (
666- f"{ message } . This usually indicates that the 'api_endpoint' "
667- "configuration in ClientOptions is incorrect, contains a typo, "
668- "or is an invalid regional endpoint for this service."
669- )
670660 return from_grpc_status (
671661 rpc_exc .code (),
672- message ,
662+ rpc_exc . details () ,
673663 errors = (rpc_exc ,),
674664 details = details ,
675665 response = rpc_exc ,
Original file line number Diff line number Diff line change 1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- from google .api_core .gapic_v1 import (
16- client_info ,
17- config ,
18- config_async ,
19- method ,
20- method_async ,
21- routing_header ,
22- )
15+ from google .api_core .gapic_v1 import client_info
16+ from google .api_core .gapic_v1 import config
17+ from google .api_core .gapic_v1 import config_async
18+ from google .api_core .gapic_v1 import method
19+ from google .api_core .gapic_v1 import method_async
20+ from google .api_core .gapic_v1 import routing_header
2321
2422__all__ = [
2523 "client_info" ,
Original file line number Diff line number Diff line change @@ -350,7 +350,7 @@ def prerelease_deps(session):
350350@nox .session (python = DEFAULT_PYTHON_VERSION )
351351def core_deps_from_source (session ):
352352 """Run the test suite installing dependencies from source."""
353- default (session , install_deps_from_source = True )
353+ default (session , prerelease = True )
354354
355355
356356@nox .session (python = DEFAULT_PYTHON_VERSION )
Original file line number Diff line number Diff line change 3131except ImportError : # pragma: NO COVER
3232 pytest .skip ("No GRPC" , allow_module_level = True )
3333
34- from google .api_core import bidi , exceptions
34+ from google .api_core import bidi
35+ from google .api_core import exceptions
3536
3637
3738class Test_RequestQueueGenerator (object ):
@@ -194,7 +195,7 @@ def test_delays_entry_attempts_above_threshold(self):
194195 # (NOTE: not using assert all(...), b/c the coverage check would complain)
195196 for i , entry in enumerate (entries ):
196197 if i != 3 :
197- assert entry ["reported_wait" ] < 0.01
198+ assert entry ["reported_wait" ] == 0.0
198199
199200 # The delayed entry is expected to have been delayed for a significant
200201 # chunk of the full second, and the actual and reported delay times
Original file line number Diff line number Diff line change 2525except ImportError : # pragma: NO COVER
2626 grpc = rpc_status = None
2727
28+ from google .api_core import exceptions
2829from google .protobuf import any_pb2 , json_format
2930from google .rpc import error_details_pb2 , status_pb2
3031
31- from google .api_core import exceptions
32-
3332
3433def test_create_google_cloud_error ():
3534 exception = exceptions .GoogleAPICallError ("Testing" )
@@ -394,18 +393,3 @@ def test_error_details_from_grpc_response_unknown_error():
394393 and exception .domain is None
395394 and exception .metadata is None
396395 )
397-
398-
399- @pytest .mark .skipif (grpc is None , reason = "No grpc" )
400- def test_from_grpc_error_misleading_404 ():
401- message = "Received http2 header with status: 404"
402- error = mock .create_autospec (grpc .Call , instance = True )
403- error .code .return_value = grpc .StatusCode .UNIMPLEMENTED
404- error .details .return_value = message
405-
406- exception = exceptions .from_grpc_error (error )
407-
408- assert isinstance (exception , exceptions .MethodNotImplemented )
409- assert exception .grpc_status_code == grpc .StatusCode .UNIMPLEMENTED
410- assert "Received http2 header with status: 404" in exception .message
411- assert "api_endpoint" in exception .message
You can’t perform that action at this time.
0 commit comments