2020
2121
2222@unittest .skipUnless (_HAVE_GRPC , 'No gRPC' )
23- class Test__grpc_catch_rendezvous (unittest .TestCase ):
23+ class Test__catch_remap_gax_error (unittest .TestCase ):
2424
2525 def _call_fut (self ):
26- from google .cloud .datastore ._gax import _grpc_catch_rendezvous
26+ from google .cloud .datastore ._gax import _catch_remap_gax_error
2727
28- return _grpc_catch_rendezvous ()
28+ return _catch_remap_gax_error ()
2929
3030 @staticmethod
3131 def _fake_method (exc , result = None ):
@@ -48,37 +48,7 @@ def test_success(self):
4848 result = self ._fake_method (None , expected )
4949 self .assertIs (result , expected )
5050
51- def test_failure_aborted (self ):
52- from grpc import StatusCode
53- from google .cloud .exceptions import Conflict
54-
55- details = 'Bad things.'
56- exc = self ._make_rendezvous (StatusCode .ABORTED , details )
57- with self .assertRaises (Conflict ):
58- with self ._call_fut ():
59- self ._fake_method (exc )
60-
61- def test_failure_invalid_argument (self ):
62- from grpc import StatusCode
63- from google .cloud .exceptions import BadRequest
64-
65- details = ('Cannot have inequality filters on multiple '
66- 'properties: [created, priority]' )
67- exc = self ._make_rendezvous (StatusCode .INVALID_ARGUMENT , details )
68- with self .assertRaises (BadRequest ):
69- with self ._call_fut ():
70- self ._fake_method (exc )
71-
72- def test_failure_cancelled (self ):
73- from google .cloud .exceptions import GrpcRendezvous
74- from grpc import StatusCode
75-
76- exc = self ._make_rendezvous (StatusCode .CANCELLED , None )
77- with self .assertRaises (GrpcRendezvous ):
78- with self ._call_fut ():
79- self ._fake_method (exc )
80-
81- def test_commit_failure_non_grpc_err (self ):
51+ def test_non_grpc_err (self ):
8252 exc = RuntimeError ('Not a gRPC error' )
8353 with self .assertRaises (RuntimeError ):
8454 with self ._call_fut ():
@@ -132,7 +102,7 @@ def test_lookup(self):
132102 return_value = None )
133103 patch2 = mock .patch .object (datastore_client .DatastoreClient , 'lookup' )
134104 patch3 = mock .patch (
135- 'google.cloud.datastore._gax._grpc_catch_rendezvous ' )
105+ 'google.cloud.datastore._gax._catch_remap_gax_error ' )
136106
137107 with patch1 as mock_constructor :
138108 ds_api = self ._make_one ()
@@ -153,7 +123,7 @@ def test_run_query(self):
153123 patch2 = mock .patch .object (
154124 datastore_client .DatastoreClient , 'run_query' )
155125 patch3 = mock .patch (
156- 'google.cloud.datastore._gax._grpc_catch_rendezvous ' )
126+ 'google.cloud.datastore._gax._catch_remap_gax_error ' )
157127
158128 with patch1 as mock_constructor :
159129 ds_api = self ._make_one ()
@@ -174,7 +144,7 @@ def test_begin_transaction(self):
174144 patch2 = mock .patch .object (
175145 datastore_client .DatastoreClient , 'begin_transaction' )
176146 patch3 = mock .patch (
177- 'google.cloud.datastore._gax._grpc_catch_rendezvous ' )
147+ 'google.cloud.datastore._gax._catch_remap_gax_error ' )
178148
179149 with patch1 as mock_constructor :
180150 ds_api = self ._make_one ()
@@ -195,7 +165,7 @@ def test_commit(self):
195165 return_value = None )
196166 patch2 = mock .patch .object (datastore_client .DatastoreClient , 'commit' )
197167 patch3 = mock .patch (
198- 'google.cloud.datastore._gax._grpc_catch_rendezvous ' )
168+ 'google.cloud.datastore._gax._catch_remap_gax_error ' )
199169
200170 with patch1 as mock_constructor :
201171 ds_api = self ._make_one ()
@@ -216,7 +186,7 @@ def test_rollback(self):
216186 patch2 = mock .patch .object (
217187 datastore_client .DatastoreClient , 'rollback' )
218188 patch3 = mock .patch (
219- 'google.cloud.datastore._gax._grpc_catch_rendezvous ' )
189+ 'google.cloud.datastore._gax._catch_remap_gax_error ' )
220190
221191 with patch1 as mock_constructor :
222192 ds_api = self ._make_one ()
@@ -237,7 +207,7 @@ def test_allocate_ids(self):
237207 patch2 = mock .patch .object (
238208 datastore_client .DatastoreClient , 'allocate_ids' )
239209 patch3 = mock .patch (
240- 'google.cloud.datastore._gax._grpc_catch_rendezvous ' )
210+ 'google.cloud.datastore._gax._catch_remap_gax_error ' )
241211
242212 with patch1 as mock_constructor :
243213 ds_api = self ._make_one ()
0 commit comments