aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorarithmetic1728 <58957152+arithmetic1728@users.noreply.github.com>2020-07-21 10:09:37 -0700
committerGitHub <noreply@github.com>2020-07-21 10:09:37 -0700
commit2010373b27536d1191175624b297a709d70153fa (patch)
tree472c9c14e4ac1c60634ecf337b8b50efa9c96d04 /tests
parente2d9a7b209b7dfab300dc848fabbae8f42a2ab19 (diff)
downloadpython-api-core-2010373b27536d1191175624b297a709d70153fa.tar.gz
fix: _determine_timeout problem handling float type timeout (#64)
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/gapic/test_method.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/unit/gapic/test_method.py b/tests/unit/gapic/test_method.py
index 0f9bee9..1ae27de 100644
--- a/tests/unit/gapic/test_method.py
+++ b/tests/unit/gapic/test_method.py
@@ -32,6 +32,27 @@ def _utcnow_monotonic():
curr_value += delta
+def test__determine_timeout():
+ # Check _determine_timeout always returns a Timeout object.
+ timeout_type_timeout = timeout.ConstantTimeout(600.0)
+ returned_timeout = google.api_core.gapic_v1.method._determine_timeout(
+ 600.0, 600.0, None
+ )
+ assert isinstance(returned_timeout, timeout.ConstantTimeout)
+ returned_timeout = google.api_core.gapic_v1.method._determine_timeout(
+ 600.0, timeout_type_timeout, None
+ )
+ assert isinstance(returned_timeout, timeout.ConstantTimeout)
+ returned_timeout = google.api_core.gapic_v1.method._determine_timeout(
+ timeout_type_timeout, 600.0, None
+ )
+ assert isinstance(returned_timeout, timeout.ConstantTimeout)
+ returned_timeout = google.api_core.gapic_v1.method._determine_timeout(
+ timeout_type_timeout, timeout_type_timeout, None
+ )
+ assert isinstance(returned_timeout, timeout.ConstantTimeout)
+
+
def test_wrap_method_basic():
method = mock.Mock(spec=["__call__"], return_value=42)
@@ -154,7 +175,8 @@ def test_wrap_method_with_default_retry_and_timeout_using_sentinel(unusued_sleep
@mock.patch("time.sleep")
def test_wrap_method_with_overriding_retry_and_timeout(unusued_sleep):
- method = mock.Mock(spec=["__call__"], side_effect=[exceptions.NotFound(None), 42])
+ method = mock.Mock(spec=["__call__"], side_effect=[
+ exceptions.NotFound(None), 42])
default_retry = retry.Retry()
default_timeout = timeout.ConstantTimeout(60)
wrapped_method = google.api_core.gapic_v1.method.wrap_method(