diff --git a/tests/unit/gapic/test_method.py b/tests/unit/gapic/test_method.py index 927902bf0..29e8fc217 100644 --- a/tests/unit/gapic/test_method.py +++ b/tests/unit/gapic/test_method.py @@ -192,6 +192,7 @@ def test_wrap_method_with_overriding_retry_timeout_compression(unused_sleep): ) +@pytest.mark.skip(reason="Known flaky due to floating point comparison. #866") def test_wrap_method_with_overriding_timeout_as_a_number(): method = mock.Mock(spec=["__call__"], return_value=42) default_retry = retry.Retry() @@ -200,6 +201,8 @@ def test_wrap_method_with_overriding_timeout_as_a_number(): method, default_retry, default_timeout ) + # Using "result = wrapped_method(timeout=22)" fails since wrapped_method + # does floating point calculations that results in 21.987.. instead of 22 result = wrapped_method(timeout=22) assert result == 42 @@ -210,6 +213,24 @@ def test_wrap_method_with_overriding_timeout_as_a_number(): assert actual_timeout == pytest.approx(22, abs=0.01) +def test_wrap_method_with_overriding_constant_timeout(): + method = mock.Mock(spec=["__call__"], return_value=42) + default_retry = retry.Retry() + default_timeout = timeout.ConstantTimeout(60) + wrapped_method = google.api_core.gapic_v1.method.wrap_method( + method, default_retry, default_timeout + ) + + result = wrapped_method(timeout=timeout.ConstantTimeout(22)) + + assert result == 42 + + actual_timeout = method.call_args[1]["timeout"] + metadata = method.call_args[1]["metadata"] + assert metadata == mock.ANY + assert actual_timeout == 22 + + def test_wrap_method_with_call(): method = mock.Mock() mock_call = mock.Mock() diff --git a/tests/unit/gapic/test_routing_header.py b/tests/unit/gapic/test_routing_header.py index 2c8c75469..f0ec82ec6 100644 --- a/tests/unit/gapic/test_routing_header.py +++ b/tests/unit/gapic/test_routing_header.py @@ -90,8 +90,8 @@ def test__urlencode_param(key, value, expected): def test__urlencode_param_caching_performance(): import time - key = "key" * 100 - value = "value" * 100 + key = "key" * 10000 + value = "value" * 10000 # time with empty cache start_time = time.perf_counter() routing_header._urlencode_param(key, value)