3636
3737from google .gax import (
3838 api_callable , bundling , BackoffSettings , BundleDescriptor , BundleOptions ,
39- CallSettings , CallOptions , INITIAL_PAGE , PageDescriptor , RetryOptions )
39+ _CallSettings , CallOptions , INITIAL_PAGE , PageDescriptor , RetryOptions )
4040from google .gax .errors import GaxError , RetryError
4141
4242
@@ -116,19 +116,19 @@ class AnotherException(Exception):
116116class TestCreateApiCallable (unittest2 .TestCase ):
117117
118118 def test_call_api_call (self ):
119- settings = CallSettings ()
119+ settings = _CallSettings ()
120120 my_callable = api_callable .create_api_call (
121121 lambda _req , _timeout : 42 , settings )
122122 self .assertEqual (my_callable (None ), 42 )
123123
124124 def test_call_override (self ):
125- settings = CallSettings (timeout = 10 )
125+ settings = _CallSettings (timeout = 10 )
126126 my_callable = api_callable .create_api_call (
127127 lambda _req , timeout : timeout , settings )
128128 self .assertEqual (my_callable (None , CallOptions (timeout = 20 )), 20 )
129129
130130 def test_call_kwargs (self ):
131- settings = CallSettings (kwargs = {'key' : 'value' })
131+ settings = _CallSettings (kwargs = {'key' : 'value' })
132132 my_callable = api_callable .create_api_call (
133133 lambda _req , _timeout , ** kwargs : kwargs ['key' ], settings )
134134 self .assertEqual (my_callable (None ), 'value' )
@@ -150,7 +150,7 @@ def test_retry(self, mock_exc_to_code, mock_time):
150150 (to_attempt - 1 ) + [mock .DEFAULT ])
151151 mock_call .return_value = 1729
152152 mock_time .return_value = 0
153- settings = CallSettings (timeout = 0 , retry = retry )
153+ settings = _CallSettings (timeout = 0 , retry = retry )
154154 my_callable = api_callable .create_api_call (mock_call , settings )
155155 self .assertEqual (my_callable (None ), 1729 )
156156 self .assertEqual (mock_call .call_count , to_attempt )
@@ -163,7 +163,7 @@ def test_no_retry_if_no_codes(self, mock_time):
163163 mock_call .side_effect = CustomException ('' , _FAKE_STATUS_CODE_1 )
164164 mock_time .return_value = 0
165165
166- settings = CallSettings (timeout = 0 , retry = retry )
166+ settings = _CallSettings (timeout = 0 , retry = retry )
167167 my_callable = api_callable .create_api_call (mock_call , settings )
168168 self .assertRaises (CustomException , my_callable , None )
169169 self .assertEqual (mock_call .call_count , 1 )
@@ -179,7 +179,7 @@ def fake_call(dummy_request, dummy_timeout):
179179 BackoffSettings (0 , 0 , 0 , 0 , 0 , 0 , 1 ))
180180 mock_time .side_effect = [0 , 2 ]
181181 mock_exc_to_code .side_effect = lambda e : e .code
182- settings = CallSettings (timeout = 0 , retry = retry )
182+ settings = _CallSettings (timeout = 0 , retry = retry )
183183 my_callable = api_callable .create_api_call (fake_call , settings )
184184
185185 try :
@@ -198,7 +198,7 @@ def test_retry_times_out_simple(self, mock_exc_to_code, mock_time):
198198 mock_call = mock .Mock ()
199199 mock_call .side_effect = CustomException ('' , _FAKE_STATUS_CODE_1 )
200200 mock_time .side_effect = ([0 ] * to_attempt + [2 ])
201- settings = CallSettings (timeout = 0 , retry = retry )
201+ settings = _CallSettings (timeout = 0 , retry = retry )
202202 my_callable = api_callable .create_api_call (mock_call , settings )
203203
204204 try :
@@ -219,7 +219,7 @@ def test_retry_aborts_on_unexpected_exception(
219219 mock_call = mock .Mock ()
220220 mock_call .side_effect = CustomException ('' , _FAKE_STATUS_CODE_2 )
221221 mock_time .return_value = 0
222- settings = CallSettings (timeout = 0 , retry = retry )
222+ settings = _CallSettings (timeout = 0 , retry = retry )
223223 my_callable = api_callable .create_api_call (mock_call , settings )
224224 self .assertRaises (Exception , my_callable , None )
225225 self .assertEqual (mock_call .call_count , 1 )
@@ -230,7 +230,7 @@ def test_retry_times_out_no_response(self, mock_time):
230230 retry = RetryOptions (
231231 [_FAKE_STATUS_CODE_1 ],
232232 BackoffSettings (0 , 0 , 0 , 0 , 0 , 0 , 0 ))
233- settings = CallSettings (timeout = 0 , retry = retry )
233+ settings = _CallSettings (timeout = 0 , retry = retry )
234234 my_callable = api_callable .create_api_call (lambda : None , settings )
235235
236236 self .assertRaises (RetryError , my_callable , None )
@@ -258,7 +258,7 @@ def api_call(dummy_request, timeout, **dummy_kwargs):
258258
259259 params = BackoffSettings (3 , 2 , 24 , 5 , 2 , 80 , 2500 )
260260 retry = RetryOptions ([_FAKE_STATUS_CODE_1 ], params )
261- settings = CallSettings (timeout = 0 , retry = retry )
261+ settings = _CallSettings (timeout = 0 , retry = retry )
262262 my_callable = api_callable .create_api_call (mock_call , settings )
263263
264264 try :
@@ -315,7 +315,7 @@ def grpc_return_value(request, *dummy_args, **dummy_kwargs):
315315
316316 with mock .patch ('grpc.UnaryUnaryMultiCallable' ) as mock_grpc :
317317 mock_grpc .side_effect = grpc_return_value
318- settings = CallSettings (
318+ settings = _CallSettings (
319319 page_descriptor = fake_grpc_func_descriptor , timeout = 0 )
320320 my_callable = api_callable .create_api_call (
321321 mock_grpc , settings = settings )
@@ -344,7 +344,7 @@ def grpc_return_value(request, *dummy_args, **dummy_kwargs):
344344 expected )
345345
346346 def test_bundling_page_streaming_error (self ):
347- settings = CallSettings (
347+ settings = _CallSettings (
348348 page_descriptor = object (), bundle_descriptor = object (),
349349 bundler = object ())
350350 with self .assertRaises (ValueError ):
@@ -362,7 +362,7 @@ def __init__(self, elements=None):
362362 def my_func (request , dummy_timeout ):
363363 return len (request .elements )
364364
365- settings = CallSettings (
365+ settings = _CallSettings (
366366 bundler = bundler , bundle_descriptor = fake_grpc_func_descriptor ,
367367 timeout = 0 )
368368 my_callable = api_callable .create_api_call (my_func , settings )
@@ -478,9 +478,9 @@ def other_error_func(*dummy_args, **dummy_kwargs):
478478 raise AnotherException
479479
480480 gax_error_callable = api_callable .create_api_call (
481- abortion_error_func , CallSettings ())
481+ abortion_error_func , _CallSettings ())
482482 self .assertRaises (GaxError , gax_error_callable , None )
483483
484484 other_error_callable = api_callable .create_api_call (
485- other_error_func , CallSettings ())
485+ other_error_func , _CallSettings ())
486486 self .assertRaises (AnotherException , other_error_callable , None )
0 commit comments