From 5a6a1bef63f9d50026e67adb1258f4a05ab24eec Mon Sep 17 00:00:00 2001 From: Jon Wayne Parrott Date: Mon, 16 Oct 2017 10:26:36 -0700 Subject: [PATCH] Move modules in google.api.core.helpers up one level, delete google.api.core.helpers. --- core/google/api/core/{helpers => }/datetime_helpers.py | 0 core/google/api/core/gapic_v1/method.py | 4 ++-- core/google/api/core/{helpers => }/general_helpers.py | 0 core/google/api/core/{helpers => }/grpc_helpers.py | 2 +- core/google/api/core/helpers/__init__.py | 0 core/google/api/core/retry.py | 4 ++-- core/google/api/core/timeout.py | 4 ++-- core/tests/unit/api_core/gapic/test_method.py | 2 +- core/tests/unit/api_core/helpers/__init__.py | 0 .../unit/api_core/{helpers => }/test_datetime_helpers.py | 2 +- .../unit/api_core/{helpers => }/test_general_helpers.py | 2 +- .../unit/api_core/{helpers => }/test_grpc_helpers.py | 6 +++--- core/tests/unit/api_core/test_retry.py | 8 ++++---- core/tests/unit/api_core/test_timeout.py | 2 +- 14 files changed, 18 insertions(+), 18 deletions(-) rename core/google/api/core/{helpers => }/datetime_helpers.py (100%) rename core/google/api/core/{helpers => }/general_helpers.py (100%) rename core/google/api/core/{helpers => }/grpc_helpers.py (98%) delete mode 100644 core/google/api/core/helpers/__init__.py delete mode 100644 core/tests/unit/api_core/helpers/__init__.py rename core/tests/unit/api_core/{helpers => }/test_datetime_helpers.py (92%) rename core/tests/unit/api_core/{helpers => }/test_general_helpers.py (95%) rename core/tests/unit/api_core/{helpers => }/test_grpc_helpers.py (96%) diff --git a/core/google/api/core/helpers/datetime_helpers.py b/core/google/api/core/datetime_helpers.py similarity index 100% rename from core/google/api/core/helpers/datetime_helpers.py rename to core/google/api/core/datetime_helpers.py diff --git a/core/google/api/core/gapic_v1/method.py b/core/google/api/core/gapic_v1/method.py index 48accdbb3d51..8d8cc8b27230 100644 --- a/core/google/api/core/gapic_v1/method.py +++ b/core/google/api/core/gapic_v1/method.py @@ -24,10 +24,10 @@ import pkg_resources import six +from google.api.core import general_helpers +from google.api.core import grpc_helpers from google.api.core import page_iterator from google.api.core import timeout -from google.api.core.helpers import general_helpers -from google.api.core.helpers import grpc_helpers _PY_VERSION = platform.python_version() _GRPC_VERSION = pkg_resources.get_distribution('grpcio').version diff --git a/core/google/api/core/helpers/general_helpers.py b/core/google/api/core/general_helpers.py similarity index 100% rename from core/google/api/core/helpers/general_helpers.py rename to core/google/api/core/general_helpers.py diff --git a/core/google/api/core/helpers/grpc_helpers.py b/core/google/api/core/grpc_helpers.py similarity index 98% rename from core/google/api/core/helpers/grpc_helpers.py rename to core/google/api/core/grpc_helpers.py index da9eaf53bc66..9762a3fe5929 100644 --- a/core/google/api/core/helpers/grpc_helpers.py +++ b/core/google/api/core/grpc_helpers.py @@ -18,7 +18,7 @@ import six from google.api.core import exceptions -from google.api.core.helpers import general_helpers +from google.api.core import general_helpers import google.auth import google.auth.transport.grpc import google.auth.transport.requests diff --git a/core/google/api/core/helpers/__init__.py b/core/google/api/core/helpers/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/core/google/api/core/retry.py b/core/google/api/core/retry.py index 625749e8da0d..715b48f3d827 100644 --- a/core/google/api/core/retry.py +++ b/core/google/api/core/retry.py @@ -64,9 +64,9 @@ def check_if_exists(): import six +from google.api.core import datetime_helpers from google.api.core import exceptions -from google.api.core.helpers import datetime_helpers -from google.api.core.helpers import general_helpers +from google.api.core import general_helpers _LOGGER = logging.getLogger(__name__) _DEFAULT_INITIAL_DELAY = 1.0 # seconds diff --git a/core/google/api/core/timeout.py b/core/google/api/core/timeout.py index 1a4d3bfdccef..bbcb68ca4570 100644 --- a/core/google/api/core/timeout.py +++ b/core/google/api/core/timeout.py @@ -57,8 +57,8 @@ def is_thing_ready(timeout=None): import six -from google.api.core.helpers import datetime_helpers -from google.api.core.helpers import general_helpers +from google.api.core import datetime_helpers +from google.api.core import general_helpers _DEFAULT_INITIAL_TIMEOUT = 5.0 # seconds _DEFAULT_MAXIMUM_TIMEOUT = 30.0 # seconds diff --git a/core/tests/unit/api_core/gapic/test_method.py b/core/tests/unit/api_core/gapic/test_method.py index ca6543af6cd6..cdc34fdc1eaa 100644 --- a/core/tests/unit/api_core/gapic/test_method.py +++ b/core/tests/unit/api_core/gapic/test_method.py @@ -150,7 +150,7 @@ def test_wrap_method_with_overriding_retry_and_timeout(unusued_sleep): @mock.patch('time.sleep') @mock.patch( - 'google.api.core.helpers.datetime_helpers.utcnow', + 'google.api.core.datetime_helpers.utcnow', side_effect=_utcnow_monotonic(), autospec=True) def test_wrap_method_with_overriding_retry_deadline(utcnow, unused_sleep): diff --git a/core/tests/unit/api_core/helpers/__init__.py b/core/tests/unit/api_core/helpers/__init__.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/core/tests/unit/api_core/helpers/test_datetime_helpers.py b/core/tests/unit/api_core/test_datetime_helpers.py similarity index 92% rename from core/tests/unit/api_core/helpers/test_datetime_helpers.py rename to core/tests/unit/api_core/test_datetime_helpers.py index cf1db713b5fa..f0e4f776eda5 100644 --- a/core/tests/unit/api_core/helpers/test_datetime_helpers.py +++ b/core/tests/unit/api_core/test_datetime_helpers.py @@ -14,7 +14,7 @@ import datetime -from google.api.core.helpers import datetime_helpers +from google.api.core import datetime_helpers def test_utcnow(): diff --git a/core/tests/unit/api_core/helpers/test_general_helpers.py b/core/tests/unit/api_core/test_general_helpers.py similarity index 95% rename from core/tests/unit/api_core/helpers/test_general_helpers.py rename to core/tests/unit/api_core/test_general_helpers.py index 9b39ea39d1c9..2dc8dfe72e5f 100644 --- a/core/tests/unit/api_core/helpers/test_general_helpers.py +++ b/core/tests/unit/api_core/test_general_helpers.py @@ -14,7 +14,7 @@ import functools -from google.api.core.helpers import general_helpers +from google.api.core import general_helpers def test_wraps_normal_func(): diff --git a/core/tests/unit/api_core/helpers/test_grpc_helpers.py b/core/tests/unit/api_core/test_grpc_helpers.py similarity index 96% rename from core/tests/unit/api_core/helpers/test_grpc_helpers.py rename to core/tests/unit/api_core/test_grpc_helpers.py index 8ee08d87a66f..e95ace8ecce9 100644 --- a/core/tests/unit/api_core/helpers/test_grpc_helpers.py +++ b/core/tests/unit/api_core/test_grpc_helpers.py @@ -17,7 +17,7 @@ import pytest from google.api.core import exceptions -from google.api.core.helpers import grpc_helpers +from google.api.core import grpc_helpers def test__patch_callable_name(): @@ -110,7 +110,7 @@ def test_wrap_stream_errors_iterator(): assert exc_info.value.response == grpc_error -@mock.patch('google.api.core.helpers.grpc_helpers._wrap_unary_errors') +@mock.patch('google.api.core.grpc_helpers._wrap_unary_errors') def test_wrap_errors_non_streaming(wrap_unary_errors): callable_ = mock.create_autospec(grpc.UnaryUnaryMultiCallable) @@ -120,7 +120,7 @@ def test_wrap_errors_non_streaming(wrap_unary_errors): wrap_unary_errors.assert_called_once_with(callable_) -@mock.patch('google.api.core.helpers.grpc_helpers._wrap_stream_errors') +@mock.patch('google.api.core.grpc_helpers._wrap_stream_errors') def test_wrap_errors_streaming(wrap_stream_errors): callable_ = mock.create_autospec(grpc.UnaryStreamMultiCallable) diff --git a/core/tests/unit/api_core/test_retry.py b/core/tests/unit/api_core/test_retry.py index 432ccb1438db..702e868439a6 100644 --- a/core/tests/unit/api_core/test_retry.py +++ b/core/tests/unit/api_core/test_retry.py @@ -57,7 +57,7 @@ def test_exponential_sleep_generator_base_2(uniform): @mock.patch('time.sleep', autospec=True) @mock.patch( - 'google.api.core.helpers.datetime_helpers.utcnow', + 'google.api.core.datetime_helpers.utcnow', return_value=datetime.datetime.min, autospec=True) def test_retry_target_success(utcnow, sleep): @@ -79,7 +79,7 @@ def target(): @mock.patch('time.sleep', autospec=True) @mock.patch( - 'google.api.core.helpers.datetime_helpers.utcnow', + 'google.api.core.datetime_helpers.utcnow', return_value=datetime.datetime.min, autospec=True) def test_retry_target_w_on_error(utcnow, sleep): @@ -107,7 +107,7 @@ def target(): @mock.patch('time.sleep', autospec=True) @mock.patch( - 'google.api.core.helpers.datetime_helpers.utcnow', + 'google.api.core.datetime_helpers.utcnow', return_value=datetime.datetime.min, autospec=True) def test_retry_target_non_retryable_error(utcnow, sleep): @@ -124,7 +124,7 @@ def test_retry_target_non_retryable_error(utcnow, sleep): @mock.patch('time.sleep', autospec=True) @mock.patch( - 'google.api.core.helpers.datetime_helpers.utcnow', autospec=True) + 'google.api.core.datetime_helpers.utcnow', autospec=True) def test_retry_target_deadline_exceeded(utcnow, sleep): predicate = retry.if_exception_type(ValueError) exception = ValueError('meep') diff --git a/core/tests/unit/api_core/test_timeout.py b/core/tests/unit/api_core/test_timeout.py index 27c6134834d5..fdca6a758820 100644 --- a/core/tests/unit/api_core/test_timeout.py +++ b/core/tests/unit/api_core/test_timeout.py @@ -28,7 +28,7 @@ def test__exponential_timeout_generator_base_2(): assert result == [1, 2, 4, 8, 16, 32, 60, 60] -@mock.patch('google.api.core.helpers.datetime_helpers.utcnow', autospec=True) +@mock.patch('google.api.core.datetime_helpers.utcnow', autospec=True) def test__exponential_timeout_generator_base_deadline(utcnow): # Make each successive call to utcnow() advance one second. utcnow.side_effect = [