diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index b724bada..daf3f391 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -11,15 +11,6 @@ branchProtectionRules: # No Kokoro: the following are Github actions - 'lint' - 'mypy' - - 'unit_grpc_gcp-3.7' - - 'unit_grpc_gcp-3.8' - - 'unit_grpc_gcp-3.9' - - 'unit_grpc_gcp-3.10' - - 'unit_grpc_gcp-3.11' - - 'unit_grpc_gcp-3.12' - - 'unit_grpc_gcp-3.13' - - 'unit_grpc_gcp-3.14' - - 'unit-3.7' - 'unit-3.8' - 'unit-3.9' - 'unit-3.10' @@ -32,7 +23,6 @@ branchProtectionRules: - 'unit_wo_grpc-3.12' - 'unit_wo_grpc-3.13' - 'unit_wo_grpc-3.14' - - 'unit_w_prerelease_deps-3.7' - 'unit_w_prerelease_deps-3.8' - 'unit_w_prerelease_deps-3.9' - 'unit_w_prerelease_deps-3.10' @@ -40,7 +30,6 @@ branchProtectionRules: - 'unit_w_prerelease_deps-3.12' - 'unit_w_prerelease_deps-3.13' - 'unit_w_prerelease_deps-3.14' - - 'unit_w_async_rest_extra-3.7' - 'unit_w_async_rest_extra-3.8' - 'unit_w_async_rest_extra-3.9' - 'unit_w_async_rest_extra-3.10' diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml index f260a6a5..2b797e37 100644 --- a/.github/workflows/unittest.yml +++ b/.github/workflows/unittest.yml @@ -14,9 +14,8 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - option: ["", "_grpc_gcp", "_wo_grpc", "_w_prerelease_deps", "_w_async_rest_extra"] + option: ["", "_wo_grpc", "_w_prerelease_deps", "_w_async_rest_extra"] python: - - "3.7" - "3.8" - "3.9" - "3.10" @@ -25,8 +24,6 @@ jobs: - "3.13" - "3.14" exclude: - - option: "_wo_grpc" - python: 3.7 - option: "_wo_grpc" python: 3.8 - option: "_wo_grpc" diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 1a1f608b..57f47416 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -21,7 +21,7 @@ In order to add a feature: documentation. - The feature must work fully on the following CPython versions: - 3.7, 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13 on both UNIX and Windows. + 3.8, 3.9, 3.10, 3.11, 3.12 and 3.13 on both UNIX and Windows. - The feature must not add unnecessary dependencies (where "unnecessary" is of course subjective, but new dependencies should @@ -197,7 +197,6 @@ Supported Python Versions We support: -- `Python 3.7`_ - `Python 3.8`_ - `Python 3.9`_ - `Python 3.10`_ @@ -205,7 +204,6 @@ We support: - `Python 3.12`_ - `Python 3.13`_ -.. _Python 3.7: https://docs.python.org/3.7/ .. _Python 3.8: https://docs.python.org/3.8/ .. _Python 3.9: https://docs.python.org/3.9/ .. _Python 3.10: https://docs.python.org/3.10/ diff --git a/README.rst b/README.rst index 58ae26cb..8322a295 100644 --- a/README.rst +++ b/README.rst @@ -16,7 +16,7 @@ common helpers used by all Google API clients. For more information, see the Supported Python Versions ------------------------- -Python >= 3.7 +Python >= 3.8 Unsupported Python Versions diff --git a/google/api_core/grpc_helpers.py b/google/api_core/grpc_helpers.py index 07963024..ec137ad9 100644 --- a/google/api_core/grpc_helpers.py +++ b/google/api_core/grpc_helpers.py @@ -17,7 +17,6 @@ import collections import functools -import warnings import grpc @@ -26,27 +25,6 @@ import google.auth.credentials import google.auth.transport.grpc import google.auth.transport.requests -import google.protobuf - -PROTOBUF_VERSION = google.protobuf.__version__ - -# The grpcio-gcp package only has support for protobuf < 4 -if PROTOBUF_VERSION[0:2] == "3.": # pragma: NO COVER - try: - import grpc_gcp - - warnings.warn( - """Support for grpcio-gcp is deprecated. This feature will be - removed from `google-api-core` after January 1, 2024. If you need to - continue to use this feature, please pin to a specific version of - `google-api-core`.""", - DeprecationWarning, - ) - HAS_GRPC_GCP = True - except ImportError: - HAS_GRPC_GCP = False -else: - HAS_GRPC_GCP = False # The list of gRPC Callable interfaces that return iterators. @@ -389,21 +367,6 @@ def create_channel( quota_project_id=quota_project_id, default_host=default_host, ) - - # Note that grpcio-gcp is deprecated - if HAS_GRPC_GCP: # pragma: NO COVER - if compression is not None and compression != grpc.Compression.NoCompression: - warnings.warn( - "The `compression` argument is ignored for grpc_gcp.secure_channel creation.", - DeprecationWarning, - ) - if attempt_direct_path: - warnings.warn( - """The `attempt_direct_path` argument is ignored for grpc_gcp.secure_channel creation.""", - DeprecationWarning, - ) - return grpc_gcp.secure_channel(target, composite_credentials, **kwargs) - if attempt_direct_path: target = _modify_target_for_direct_path(target) diff --git a/google/api_core/grpc_helpers_async.py b/google/api_core/grpc_helpers_async.py index af661430..c126a0cd 100644 --- a/google/api_core/grpc_helpers_async.py +++ b/google/api_core/grpc_helpers_async.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -"""AsyncIO helpers for :mod:`grpc` supporting 3.7+. +"""AsyncIO helpers for :mod:`grpc` supporting 3.8+. Please combine more detailed docstring in grpc_helpers.py to use following functions. This module is implementing the same surface with AsyncIO semantics. @@ -219,7 +219,7 @@ def create_channel( default_host=None, compression=None, attempt_direct_path: Optional[bool] = False, - **kwargs + **kwargs, ): """Create an AsyncIO secure channel with credentials. diff --git a/google/api_core/operation.py b/google/api_core/operation.py index 4b9c9a58..5206243a 100644 --- a/google/api_core/operation.py +++ b/google/api_core/operation.py @@ -78,7 +78,7 @@ def __init__( result_type, metadata_type=None, polling=polling.DEFAULT_POLLING, - **kwargs + **kwargs, ): super(Operation, self).__init__(polling=polling, **kwargs) self._operation = operation diff --git a/google/api_core/operations_v1/pagers.py b/google/api_core/operations_v1/pagers.py index 132f1c66..76efd594 100644 --- a/google/api_core/operations_v1/pagers.py +++ b/google/api_core/operations_v1/pagers.py @@ -48,7 +48,7 @@ def __init__( request: operations_pb2.ListOperationsRequest, response: operations_pb2.ListOperationsResponse, *, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, str]] = (), ): super().__init__( method=method, request=request, response=response, metadata=metadata diff --git a/google/api_core/operations_v1/pagers_async.py b/google/api_core/operations_v1/pagers_async.py index e2909dd5..4bb7f8c7 100644 --- a/google/api_core/operations_v1/pagers_async.py +++ b/google/api_core/operations_v1/pagers_async.py @@ -48,7 +48,7 @@ def __init__( request: operations_pb2.ListOperationsRequest, response: operations_pb2.ListOperationsResponse, *, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, str]] = (), ): super().__init__( method=method, request=request, response=response, metadata=metadata diff --git a/google/api_core/operations_v1/pagers_base.py b/google/api_core/operations_v1/pagers_base.py index 24caf74f..5ef8384e 100644 --- a/google/api_core/operations_v1/pagers_base.py +++ b/google/api_core/operations_v1/pagers_base.py @@ -47,7 +47,7 @@ def __init__( request: operations_pb2.ListOperationsRequest, response: operations_pb2.ListOperationsResponse, *, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, str]] = (), ): """Instantiate the pager. diff --git a/google/api_core/operations_v1/transports/base.py b/google/api_core/operations_v1/transports/base.py index 71764c1e..dcd27485 100644 --- a/google/api_core/operations_v1/transports/base.py +++ b/google/api_core/operations_v1/transports/base.py @@ -235,8 +235,8 @@ def _convert_protobuf_message_to_dict( A dict representation of the protocol buffer message. """ # TODO(https://github.com/googleapis/python-api-core/issues/643): For backwards compatibility - # with protobuf 3.x 4.x, Remove once support for protobuf 3.x and 4.x is dropped. - if PROTOBUF_VERSION[0:2] in ["3.", "4."]: + # with protobuf 4.x, Remove once support for protobuf 4.x is dropped. + if PROTOBUF_VERSION[0:2] == "4.": result = json_format.MessageToDict( message, preserving_proto_field_name=True, diff --git a/noxfile.py b/noxfile.py index ac21330e..0af0b38b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -28,7 +28,7 @@ # Black and flake8 clash on the syntax for ignoring flake8's F401 in this file. BLACK_EXCLUDES = ["--exclude", "^/google/api_core/operations_v1/__init__.py"] -PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] +PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13", "3.14"] DEFAULT_PYTHON_VERSION = "3.10" CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -36,7 +36,6 @@ # 'docfx' is excluded since it only needs to run in 'docs-presubmit' nox.options.sessions = [ "unit", - "unit_grpc_gcp", "unit_wo_grpc", "unit_w_prerelease_deps", "unit_w_async_rest_extra", @@ -124,7 +123,6 @@ def default(session, install_grpc=True, prerelease=False, install_async_rest=Fal session.install( "dataclasses", - "mock; python_version=='3.7'", "pytest", "pytest-cov", "pytest-xdist", @@ -225,25 +223,6 @@ def unit_w_prerelease_deps(session): default(session, prerelease=True) -@nox.session(python=PYTHON_VERSIONS) -def unit_grpc_gcp(session): - """ - Run the unit test suite with grpcio-gcp installed. - `grpcio-gcp` doesn't support protobuf 4+. - Remove extra `grpcgcp` when protobuf 3.x is dropped. - https://github.com/googleapis/python-api-core/issues/594 - """ - constraints_path = str( - CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" - ) - # Install grpcio-gcp - session.install("-e", ".[grpcgcp]", "-c", constraints_path) - # Install protobuf < 4.0.0 - session.install("protobuf<4.0.0") - - default(session) - - @nox.session(python=PYTHON_VERSIONS) def unit_wo_grpc(session): """Run the unit test suite w/o grpcio installed""" @@ -280,7 +259,6 @@ def mypy(session): "types-requests", "types-protobuf", "types-dataclasses", - "types-mock; python_version=='3.7'", ) session.run("mypy", "google", "tests") diff --git a/pyproject.toml b/pyproject.toml index da404ab3..54a65cb3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ build-backend = "setuptools.build_meta" name = "google-api-core" authors = [{ name = "Google LLC", email = "googleapis-packages@google.com" }] license = { text = "Apache 2.0" } -requires-python = ">=3.7" +requires-python = ">=3.8" readme = "README.rst" description = "Google API client core library" classifiers = [ @@ -33,7 +33,6 @@ classifiers = [ "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -44,8 +43,8 @@ classifiers = [ "Topic :: Internet", ] dependencies = [ - "googleapis-common-protos >= 1.56.2, < 2.0.0", - "protobuf >= 3.19.5, < 7.0.0, != 3.20.0, != 3.20.1, != 4.21.0, != 4.21.1, != 4.21.2, != 4.21.3, != 4.21.4, != 4.21.5", + "googleapis-common-protos >= 1.63.2, < 2.0.0", + "protobuf >= 4.25.8, < 7.0.0", "proto-plus >= 1.22.3, < 2.0.0", "proto-plus >= 1.25.0, < 2.0.0; python_version >= '3.13'", "google-auth >= 2.14.1, < 3.0.0", @@ -65,8 +64,6 @@ grpc = [ "grpcio-status >= 1.33.2, < 2.0.0", "grpcio-status >= 1.49.1, < 2.0.0; python_version >= '3.11'", ] -grpcgcp = ["grpcio-gcp >= 0.2.2, < 1.0.0"] -grpcio-gcp = ["grpcio-gcp >= 0.2.2, < 1.0.0"] [tool.setuptools.dynamic] version = { attr = "google.api_core.version.__version__" } @@ -77,7 +74,7 @@ version = { attr = "google.api_core.version.__version__" } include = ["google*"] [tool.mypy] -python_version = "3.7" +python_version = "3.8" namespace_packages = true ignore_missing_imports = true @@ -89,9 +86,6 @@ filterwarnings = [ "ignore:.*The --rsyncdir command line argument and rsyncdirs config variable are deprecated:DeprecationWarning", # Remove once https://github.com/protocolbuffers/protobuf/issues/12186 is fixed "ignore:.*custom tp_new.*in Python 3.14:DeprecationWarning", - # Remove once support for python 3.7 is dropped - # This warning only appears when using python 3.7 - "ignore:.*Using or importing the ABCs from.*collections:DeprecationWarning", # Remove once support for grpcio-gcp is deprecated # See https://github.com/googleapis/python-api-core/blob/42e8b6e6f426cab749b34906529e8aaf3f133d75/google/api_core/grpc_helpers.py#L39-L45 "ignore:.*Support for grpcio-gcp is deprecated:DeprecationWarning", @@ -102,6 +96,4 @@ filterwarnings = [ "ignore:.*pkg_resources is deprecated as an API:DeprecationWarning", # Remove once https://github.com/grpc/grpc/issues/35086 is fixed (and version newer than 1.60.0 is published) "ignore:There is no current event loop:DeprecationWarning", - # Remove after support for Python 3.7 is dropped - "ignore:After January 1, 2024, new releases of this library will drop support for Python 3.7:DeprecationWarning", ] diff --git a/setup.cfg b/setup.cfg index f7b5a3bc..3b1d1703 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [pytype] -python_version = 3.7 +python_version = 3.8 inputs = google/ exclude = diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt deleted file mode 100644 index 4ce1c899..00000000 --- a/testing/constraints-3.7.txt +++ /dev/null @@ -1,15 +0,0 @@ -# This constraints file is used to check that lower bounds -# are correct in setup.py -# List *all* library dependencies and extras in this file. -# Pin the version to the lower bound. -# -# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", -# Then this file should have foo==1.14.0 -googleapis-common-protos==1.56.2 -protobuf==3.19.5 -google-auth==2.14.1 -requests==2.18.0 -grpcio==1.33.2 -grpcio-status==1.33.2 -grpcio-gcp==0.2.2 -proto-plus==1.22.3 diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt index 1b5bb58e..c2abb239 100644 --- a/testing/constraints-3.8.txt +++ b/testing/constraints-3.8.txt @@ -1,2 +1,14 @@ -googleapis-common-protos==1.56.3 -protobuf==4.21.6 \ No newline at end of file +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List *all* library dependencies and extras in this file. +# Pin the version to the lower bound. +# +# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", +# Then this file should have foo==1.14.0 +googleapis-common-protos==1.63.2 +protobuf==4.25.8 +google-auth==2.14.1 +requests==2.18.0 +grpcio==1.33.2 +grpcio-status==1.33.2 +proto-plus==1.22.3 \ No newline at end of file diff --git a/testing/constraints-async-rest-3.7.txt b/testing/constraints-async-rest-3.8.txt similarity index 85% rename from testing/constraints-async-rest-3.7.txt rename to testing/constraints-async-rest-3.8.txt index 7aedeb1c..d6f92392 100644 --- a/testing/constraints-async-rest-3.7.txt +++ b/testing/constraints-async-rest-3.8.txt @@ -5,13 +5,12 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -googleapis-common-protos==1.56.2 -protobuf==3.19.5 +googleapis-common-protos==1.63.2 +protobuf==4.25.8 google-auth==2.35.0 # from google-auth[aiohttp] aiohttp==3.6.2 requests==2.20.0 grpcio==1.33.2 grpcio-status==1.33.2 -grpcio-gcp==0.2.2 proto-plus==1.22.3 diff --git a/tests/asyncio/test_rest_streaming_async.py b/tests/asyncio/test_rest_streaming_async.py index c9caa2b1..13549c7f 100644 --- a/tests/asyncio/test_rest_streaming_async.py +++ b/tests/asyncio/test_rest_streaming_async.py @@ -292,7 +292,6 @@ async def test_next_escaped_characters_in_string( @pytest.mark.asyncio @pytest.mark.parametrize("response_type", [EchoResponse, httpbody_pb2.HttpBody]) async def test_next_not_array(response_type): - data = '{"hello": 0}' with mock.patch.object( ResponseMock, "content", return_value=mock_async_gen(data) @@ -352,7 +351,6 @@ async def test_check_buffer(response_type, return_value): @pytest.mark.asyncio @pytest.mark.parametrize("response_type", [EchoResponse, httpbody_pb2.HttpBody]) async def test_next_html(response_type): - data = "" with mock.patch.object( ResponseMock, "content", return_value=mock_async_gen(data) diff --git a/tests/unit/operations_v1/test_operations_rest_client.py b/tests/unit/operations_v1/test_operations_rest_client.py index d1f6e0eb..87701c2a 100644 --- a/tests/unit/operations_v1/test_operations_rest_client.py +++ b/tests/unit/operations_v1/test_operations_rest_client.py @@ -225,7 +225,6 @@ def test_operations_client_service_account_always_use_jwt(transport_class): PYPARAM_CLIENT, ) def test_operations_client_from_service_account_file(client_class): - if "async" in str(client_class): # TODO(): Add support for service account creds to async REST transport. with pytest.raises(NotImplementedError): @@ -1045,7 +1044,6 @@ async def test_cancel_operation_rest_failure_async(): PYPARAM_CLIENT_TRANSPORT_CREDENTIALS, ) def test_credentials_transport_error(client_class, transport_class, credentials): - # It is an error to provide credentials and a transport instance. transport = transport_class(credentials=credentials) with pytest.raises(ValueError): diff --git a/tests/unit/test_client_logging.py b/tests/unit/test_client_logging.py index b3b0b5c8..c73b269f 100644 --- a/tests/unit/test_client_logging.py +++ b/tests/unit/test_client_logging.py @@ -88,7 +88,6 @@ def test_setup_logging_w_incorrect_scope(): def test_initialize_logging(): - with mock.patch("os.getenv", return_value="foogle.bar"): with mock.patch("google.api_core.client_logging._BASE_LOGGER_NAME", "foogle"): initialize_logging() diff --git a/tests/unit/test_client_options.py b/tests/unit/test_client_options.py index 396d6627..3a57ee7d 100644 --- a/tests/unit/test_client_options.py +++ b/tests/unit/test_client_options.py @@ -27,7 +27,6 @@ def get_client_encrypted_cert(): def test_constructor(): - options = client_options.ClientOptions( api_endpoint="foo.googleapis.com", client_cert_source=get_client_cert, @@ -54,7 +53,6 @@ def test_constructor(): def test_constructor_with_encrypted_cert_source(): - options = client_options.ClientOptions( api_endpoint="foo.googleapis.com", client_encrypted_cert_source=get_client_encrypted_cert, @@ -78,7 +76,6 @@ def test_constructor_with_both_cert_sources(): def test_constructor_with_api_key(): - options = client_options.ClientOptions( api_endpoint="foo.googleapis.com", client_cert_source=get_client_cert, diff --git a/tests/unit/test_grpc_helpers.py b/tests/unit/test_grpc_helpers.py index 8de9d8c0..a5f4a39b 100644 --- a/tests/unit/test_grpc_helpers.py +++ b/tests/unit/test_grpc_helpers.py @@ -403,16 +403,9 @@ def test_create_channel_implicit( google_auth_default.assert_called_once_with(scopes=None, default_scopes=None) - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - # The original target is the expected target - expected_target = target - grpc_secure_channel.assert_called_once_with( - expected_target, composite_creds, None - ) - else: - grpc_secure_channel.assert_called_once_with( - expected_target, composite_creds, compression=grpc.Compression.Gzip - ) + grpc_secure_channel.assert_called_once_with( + expected_target, composite_creds, compression=grpc.Compression.Gzip + ) @pytest.mark.parametrize( @@ -462,16 +455,9 @@ def test_create_channel_implicit_with_default_host( mock.sentinel.credentials, mock.sentinel.Request, default_host=default_host ) - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - # The original target is the expected target - expected_target = target - grpc_secure_channel.assert_called_once_with( - expected_target, composite_creds, None - ) - else: - grpc_secure_channel.assert_called_once_with( - expected_target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + expected_target, composite_creds, compression=None + ) @pytest.mark.parametrize( @@ -504,12 +490,9 @@ def test_create_channel_implicit_with_ssl_creds( composite_creds_call.assert_called_once_with(ssl_creds, mock.ANY) composite_creds = composite_creds_call.return_value - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) def test_create_channel_implicit_with_ssl_creds_attempt_direct_path_true(): @@ -542,12 +525,9 @@ def test_create_channel_implicit_with_scopes( default.assert_called_once_with(scopes=["one", "two"], default_scopes=None) - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) @mock.patch("grpc.compute_engine_channel_credentials") @@ -569,12 +549,9 @@ def test_create_channel_implicit_with_default_scopes( default.assert_called_once_with(scopes=None, default_scopes=["three", "four"]) - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) def test_create_channel_explicit_with_duplicate_credentials(): @@ -603,12 +580,9 @@ def test_create_channel_explicit(grpc_secure_channel, auth_creds, composite_cred assert channel is grpc_secure_channel.return_value - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) @mock.patch("grpc.compute_engine_channel_credentials") @@ -629,12 +603,9 @@ def test_create_channel_explicit_scoped(grpc_secure_channel, composite_creds_cal assert channel is grpc_secure_channel.return_value - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) @mock.patch("grpc.compute_engine_channel_credentials") @@ -659,12 +630,9 @@ def test_create_channel_explicit_default_scopes( assert channel is grpc_secure_channel.return_value - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) @mock.patch("grpc.compute_engine_channel_credentials") @@ -687,12 +655,9 @@ def test_create_channel_explicit_with_quota_project( assert channel is grpc_secure_channel.return_value - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) @mock.patch("grpc.compute_engine_channel_credentials") @@ -718,12 +683,9 @@ def test_create_channel_with_credentials_file( assert channel is grpc_secure_channel.return_value - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) @mock.patch("grpc.compute_engine_channel_credentials") @@ -752,12 +714,9 @@ def test_create_channel_with_credentials_file_and_scopes( assert channel is grpc_secure_channel.return_value - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) @mock.patch("grpc.compute_engine_channel_credentials") @@ -786,44 +745,9 @@ def test_create_channel_with_credentials_file_and_default_scopes( assert channel is grpc_secure_channel.return_value - if grpc_helpers.HAS_GRPC_GCP: # pragma: NO COVER - grpc_secure_channel.assert_called_once_with(target, composite_creds, None) - else: - grpc_secure_channel.assert_called_once_with( - target, composite_creds, compression=None - ) - - -@pytest.mark.skipif( - not grpc_helpers.HAS_GRPC_GCP, reason="grpc_gcp module not available" -) -@mock.patch("grpc_gcp.secure_channel") -def test_create_channel_with_grpc_gcp(grpc_gcp_secure_channel): # pragma: NO COVER - target = "example.com:443" - scopes = ["test_scope"] - - credentials = mock.create_autospec(google.auth.credentials.Scoped, instance=True) - credentials.requires_scopes = True - - grpc_helpers.create_channel(target, credentials=credentials, scopes=scopes) - grpc_gcp_secure_channel.assert_called() - - credentials.with_scopes.assert_called_once_with(scopes, default_scopes=None) - - -@pytest.mark.skipif(grpc_helpers.HAS_GRPC_GCP, reason="grpc_gcp module not available") -@mock.patch("grpc.secure_channel") -def test_create_channel_without_grpc_gcp(grpc_secure_channel): - target = "example.com:443" - scopes = ["test_scope"] - - credentials = mock.create_autospec(google.auth.credentials.Scoped, instance=True) - credentials.requires_scopes = True - - grpc_helpers.create_channel(target, credentials=credentials, scopes=scopes) - grpc_secure_channel.assert_called() - - credentials.with_scopes.assert_called_once_with(scopes, default_scopes=None) + grpc_secure_channel.assert_called_once_with( + target, composite_creds, compression=None + ) class TestChannelStub(object): diff --git a/tests/unit/test_page_iterator.py b/tests/unit/test_page_iterator.py index 560722c5..ba0fbba4 100644 --- a/tests/unit/test_page_iterator.py +++ b/tests/unit/test_page_iterator.py @@ -360,7 +360,6 @@ def test__has_next_page_w_max_results_not_done(self): assert iterator._has_next_page() def test__has_next_page_w_max_results_done(self): - iterator = page_iterator.HTTPIterator( mock.sentinel.client, mock.sentinel.api_request,