@@ -81,9 +81,10 @@ def test_wrap_method_with_merged_metadata():
8181
8282@mock .patch ('time.sleep' )
8383def test_wrap_method_with_default_retry_and_timeout (unusued_sleep ):
84- method = mock .Mock (spec = ['__call__' ], side_effect = [
85- exceptions .InternalServerError (None ),
86- 42 ])
84+ method = mock .Mock (
85+ spec = ['__call__' ],
86+ side_effect = [exceptions .InternalServerError (None ), 42 ]
87+ )
8788 default_retry = retry .Retry ()
8889 default_timeout = timeout .ConstantTimeout (60 )
8990 wrapped_method = google .api .core .gapic_v1 .method .wrap_method (
@@ -96,11 +97,33 @@ def test_wrap_method_with_default_retry_and_timeout(unusued_sleep):
9697 method .assert_called_with (timeout = 60 , metadata = mock .ANY )
9798
9899
100+ @mock .patch ('time.sleep' )
101+ def test_wrap_method_with_default_retry_and_timeout_using_sentinel (
102+ unusued_sleep ):
103+ method = mock .Mock (
104+ spec = ['__call__' ],
105+ side_effect = [exceptions .InternalServerError (None ), 42 ]
106+ )
107+ default_retry = retry .Retry ()
108+ default_timeout = timeout .ConstantTimeout (60 )
109+ wrapped_method = google .api .core .gapic_v1 .method .wrap_method (
110+ method , default_retry , default_timeout )
111+
112+ result = wrapped_method (
113+ retry = google .api .core .gapic_v1 .method .DEFAULT ,
114+ timeout = google .api .core .gapic_v1 .method .DEFAULT )
115+
116+ assert result == 42
117+ assert method .call_count == 2
118+ method .assert_called_with (timeout = 60 , metadata = mock .ANY )
119+
120+
99121@mock .patch ('time.sleep' )
100122def test_wrap_method_with_overriding_retry_and_timeout (unusued_sleep ):
101- method = mock .Mock (spec = ['__call__' ], side_effect = [
102- exceptions .NotFound (None ),
103- 42 ])
123+ method = mock .Mock (
124+ spec = ['__call__' ],
125+ side_effect = [exceptions .NotFound (None ), 42 ]
126+ )
104127 default_retry = retry .Retry ()
105128 default_timeout = timeout .ConstantTimeout (60 )
106129 wrapped_method = google .api .core .gapic_v1 .method .wrap_method (
@@ -117,8 +140,10 @@ def test_wrap_method_with_overriding_retry_and_timeout(unusued_sleep):
117140
118141@mock .patch ('time.sleep' )
119142def test_wrap_method_with_overriding_retry_deadline (unusued_sleep ):
120- method = mock .Mock (spec = ['__call__' ], side_effect = ([
121- exceptions .InternalServerError (None )] * 3 ) + [42 ])
143+ method = mock .Mock (
144+ spec = ['__call__' ],
145+ side_effect = ([exceptions .InternalServerError (None )] * 3 ) + [42 ]
146+ )
122147 default_retry = retry .Retry ()
123148 default_timeout = timeout .ExponentialTimeout (deadline = 60 )
124149 wrapped_method = google .api .core .gapic_v1 .method .wrap_method (
0 commit comments