diff --git a/.flake8 b/.flake8 index 29227d4..2e43874 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7..757c9dc 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 +# created: 2022-05-05T22:08:23.383410683Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 0000000..311ebbb --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,3 @@ +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/auto-approve +processes: + - "OwlBotTemplateChanges" diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 0000000..41bff0b --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +requestsize: + enabled: true diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e..6def37a 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,8 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb..238b87b 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a7..46d2371 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 diff --git a/CHANGELOG.md b/CHANGELOG.md index ba309f6..ec18a7d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,18 @@ # Changelog -### [1.3.1](https://github.com/googleapis/python-debugger-client/compare/v1.3.0...v1.3.1) (2022-03-05) +## [1.3.2](https://github.com/googleapis/python-debugger-client/compare/v1.3.1...v1.3.2) (2022-06-03) + + +### Bug Fixes + +* **deps:** require protobuf <4.0.0dev ([#100](https://github.com/googleapis/python-debugger-client/issues/100)) ([2a37072](https://github.com/googleapis/python-debugger-client/commit/2a37072151041db69d2c71fd31a9e5bfa5256218)) + + +### Documentation + +* fix changelog header to consistent size ([#101](https://github.com/googleapis/python-debugger-client/issues/101)) ([835df83](https://github.com/googleapis/python-debugger-client/commit/835df83d50beeb0ab452264f2ebb7cc8657b8c0a)) + +## [1.3.1](https://github.com/googleapis/python-debugger-client/compare/v1.3.0...v1.3.1) (2022-03-05) ### Bug Fixes @@ -19,7 +31,7 @@ * resolve DuplicateCredentialArgs error when using credentials_file ([a4fe64d](https://github.com/googleapis/python-debugger-client/commit/a4fe64ddb07ff580ec7ba64fe02629678117a1bf)) -### [1.2.1](https://www.github.com/googleapis/python-debugger-client/compare/v1.2.0...v1.2.1) (2021-11-01) +## [1.2.1](https://www.github.com/googleapis/python-debugger-client/compare/v1.2.0...v1.2.1) (2021-11-01) ### Bug Fixes @@ -46,14 +58,14 @@ * add context manager support in client ([#38](https://www.github.com/googleapis/python-debugger-client/issues/38)) ([d8ef19f](https://www.github.com/googleapis/python-debugger-client/commit/d8ef19fdee913a1b8988fd54938bf2b8f4b11233)) -### [1.0.2](https://www.github.com/googleapis/python-debugger-client/compare/v1.0.1...v1.0.2) (2021-10-07) +## [1.0.2](https://www.github.com/googleapis/python-debugger-client/compare/v1.0.1...v1.0.2) (2021-10-07) ### Bug Fixes * **deps:** require google-cloud-source-context 1.0.0 ([#35](https://www.github.com/googleapis/python-debugger-client/issues/35)) ([1db551b](https://www.github.com/googleapis/python-debugger-client/commit/1db551b8a06f85377052f0408a59e012677f94ff)) -### [1.0.1](https://www.github.com/googleapis/python-debugger-client/compare/v1.0.0...v1.0.1) (2021-09-24) +## [1.0.1](https://www.github.com/googleapis/python-debugger-client/compare/v1.0.0...v1.0.1) (2021-09-24) ### Bug Fixes @@ -67,7 +79,7 @@ * bump release level to production/stable ([#18](https://www.github.com/googleapis/python-debugger-client/issues/18)) ([2eb231c](https://www.github.com/googleapis/python-debugger-client/commit/2eb231ca3913485e2d33d7ca1c5aa0a7c69c6872)) -### [0.1.3](https://www.github.com/googleapis/python-debugger-client/compare/v0.1.2...v0.1.3) (2021-07-29) +## [0.1.3](https://www.github.com/googleapis/python-debugger-client/compare/v0.1.2...v0.1.3) (2021-07-29) ### Bug Fixes @@ -84,14 +96,14 @@ * release as 0.1.3 ([#15](https://www.github.com/googleapis/python-debugger-client/issues/15)) ([bdc4b8f](https://www.github.com/googleapis/python-debugger-client/commit/bdc4b8f52863c4993dcc8648e0fa50ba1654e3ff)) -### [0.1.2](https://www.github.com/googleapis/python-debugger-client/compare/v0.1.1...v0.1.2) (2021-07-21) +## [0.1.2](https://www.github.com/googleapis/python-debugger-client/compare/v0.1.1...v0.1.2) (2021-07-21) ### Bug Fixes * **deps:** pin 'google-{api,cloud}-core', 'google-auth' to allow 2.x versions ([#9](https://www.github.com/googleapis/python-debugger-client/issues/9)) ([e465487](https://www.github.com/googleapis/python-debugger-client/commit/e465487f8c682efdacaf977085d3143af2d146da)) -### [0.1.1](https://www.github.com/googleapis/python-debugger-client/compare/v0.1.0...v0.1.1) (2021-07-14) +## [0.1.1](https://www.github.com/googleapis/python-debugger-client/compare/v0.1.0...v0.1.1) (2021-07-14) ### Bug Fixes diff --git a/docs/conf.py b/docs/conf.py index 8161a89..fef6440 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -361,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/debugger_v2/services/controller2/async_client.py b/google/cloud/debugger_v2/services/controller2/async_client.py index c08f317..8f6c5a4 100644 --- a/google/cloud/debugger_v2/services/controller2/async_client.py +++ b/google/cloud/debugger_v2/services/controller2/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -240,21 +240,20 @@ async def register_debuggee( format. Agents must handle ``debuggee_id`` value changing upon re-registration. - .. code-block:: python from google.cloud import debugger_v2 - def sample_register_debuggee(): + async def sample_register_debuggee(): # Create a client - client = debugger_v2.Controller2Client() + client = debugger_v2.Controller2AsyncClient() # Initialize request argument(s) request = debugger_v2.RegisterDebuggeeRequest( ) # Make the request - response = client.register_debuggee(request=request) + response = await client.register_debuggee(request=request) # Handle the response print(response) @@ -306,7 +305,12 @@ def sample_register_debuggee(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -335,14 +339,13 @@ async def list_active_breakpoints( breakpoints that are completed until the controller removes them from the active list to avoid setting those breakpoints again. - .. code-block:: python from google.cloud import debugger_v2 - def sample_list_active_breakpoints(): + async def sample_list_active_breakpoints(): # Create a client - client = debugger_v2.Controller2Client() + client = debugger_v2.Controller2AsyncClient() # Initialize request argument(s) request = debugger_v2.ListActiveBreakpointsRequest( @@ -350,7 +353,7 @@ def sample_list_active_breakpoints(): ) # Make the request - response = client.list_active_breakpoints(request=request) + response = await client.list_active_breakpoints(request=request) # Handle the response print(response) @@ -410,8 +413,21 @@ def sample_list_active_breakpoints(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("debuggee_id", request.debuggee_id),) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -436,14 +452,13 @@ async def update_active_breakpoint( changes such as canonicalizing a value or snapping the location to the correct line of code. - .. code-block:: python from google.cloud import debugger_v2 - def sample_update_active_breakpoint(): + async def sample_update_active_breakpoint(): # Create a client - client = debugger_v2.Controller2Client() + client = debugger_v2.Controller2AsyncClient() # Initialize request argument(s) request = debugger_v2.UpdateActiveBreakpointRequest( @@ -451,7 +466,7 @@ def sample_update_active_breakpoint(): ) # Make the request - response = client.update_active_breakpoint(request=request) + response = await client.update_active_breakpoint(request=request) # Handle the response print(response) @@ -525,8 +540,24 @@ def sample_update_active_breakpoint(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("debuggee_id", request.debuggee_id), + ("breakpoint.id", request.breakpoint_.id), + ) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/debugger_v2/services/controller2/client.py b/google/cloud/debugger_v2/services/controller2/client.py index f3914f5..06787c5 100644 --- a/google/cloud/debugger_v2/services/controller2/client.py +++ b/google/cloud/debugger_v2/services/controller2/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -53,7 +53,10 @@ class Controller2ClientMeta(type): _transport_registry["grpc"] = Controller2GrpcTransport _transport_registry["grpc_asyncio"] = Controller2GrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[Controller2Transport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[Controller2Transport]: """Returns an appropriate transport class. Args: @@ -180,7 +183,9 @@ def transport(self) -> Controller2Transport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -193,9 +198,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -204,9 +213,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -215,9 +228,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -226,10 +243,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -425,7 +446,6 @@ def register_debuggee( format. Agents must handle ``debuggee_id`` value changing upon re-registration. - .. code-block:: python from google.cloud import debugger_v2 @@ -491,7 +511,12 @@ def sample_register_debuggee(): rpc = self._transport._wrapped_methods[self._transport.register_debuggee] # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -520,7 +545,6 @@ def list_active_breakpoints( breakpoints that are completed until the controller removes them from the active list to avoid setting those breakpoints again. - .. code-block:: python from google.cloud import debugger_v2 @@ -585,8 +609,21 @@ def sample_list_active_breakpoints(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_active_breakpoints] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("debuggee_id", request.debuggee_id),) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -611,7 +648,6 @@ def update_active_breakpoint( changes such as canonicalizing a value or snapping the location to the correct line of code. - .. code-block:: python from google.cloud import debugger_v2 @@ -690,8 +726,24 @@ def sample_update_active_breakpoint(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.update_active_breakpoint] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("debuggee_id", request.debuggee_id), + ("breakpoint.id", request.breakpoint_.id), + ) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/debugger_v2/services/controller2/transports/base.py b/google/cloud/debugger_v2/services/controller2/transports/base.py index 9d06849..5cabe0e 100644 --- a/google/cloud/debugger_v2/services/controller2/transports/base.py +++ b/google/cloud/debugger_v2/services/controller2/transports/base.py @@ -83,6 +83,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -124,7 +125,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.register_debuggee: gapic_v1.method.wrap_method( - self.register_debuggee, default_timeout=600.0, client_info=client_info, + self.register_debuggee, + default_timeout=600.0, + client_info=client_info, ), self.list_active_breakpoints: gapic_v1.method.wrap_method( self.list_active_breakpoints, @@ -161,9 +164,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -203,5 +206,9 @@ def update_active_breakpoint( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("Controller2Transport",) diff --git a/google/cloud/debugger_v2/services/controller2/transports/grpc.py b/google/cloud/debugger_v2/services/controller2/transports/grpc.py index e3756bc..07270d6 100644 --- a/google/cloud/debugger_v2/services/controller2/transports/grpc.py +++ b/google/cloud/debugger_v2/services/controller2/transports/grpc.py @@ -245,8 +245,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -370,5 +369,9 @@ def update_active_breakpoint( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("Controller2GrpcTransport",) diff --git a/google/cloud/debugger_v2/services/debugger2/async_client.py b/google/cloud/debugger_v2/services/debugger2/async_client.py index 5e15048..a1fb80f 100644 --- a/google/cloud/debugger_v2/services/debugger2/async_client.py +++ b/google/cloud/debugger_v2/services/debugger2/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -224,9 +224,9 @@ async def set_breakpoint( from google.cloud import debugger_v2 - def sample_set_breakpoint(): + async def sample_set_breakpoint(): # Create a client - client = debugger_v2.Debugger2Client() + client = debugger_v2.Debugger2AsyncClient() # Initialize request argument(s) request = debugger_v2.SetBreakpointRequest( @@ -235,7 +235,7 @@ def sample_set_breakpoint(): ) # Make the request - response = client.set_breakpoint(request=request) + response = await client.set_breakpoint(request=request) # Handle the response print(response) @@ -304,8 +304,21 @@ def sample_set_breakpoint(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("debuggee_id", request.debuggee_id),) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -327,9 +340,9 @@ async def get_breakpoint( from google.cloud import debugger_v2 - def sample_get_breakpoint(): + async def sample_get_breakpoint(): # Create a client - client = debugger_v2.Debugger2Client() + client = debugger_v2.Debugger2AsyncClient() # Initialize request argument(s) request = debugger_v2.GetBreakpointRequest( @@ -339,7 +352,7 @@ def sample_get_breakpoint(): ) # Make the request - response = client.get_breakpoint(request=request) + response = await client.get_breakpoint(request=request) # Handle the response print(response) @@ -421,8 +434,24 @@ def sample_get_breakpoint(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("debuggee_id", request.debuggee_id), + ("breakpoint_id", request.breakpoint_id), + ) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -444,9 +473,9 @@ async def delete_breakpoint( from google.cloud import debugger_v2 - def sample_delete_breakpoint(): + async def sample_delete_breakpoint(): # Create a client - client = debugger_v2.Debugger2Client() + client = debugger_v2.Debugger2AsyncClient() # Initialize request argument(s) request = debugger_v2.DeleteBreakpointRequest( @@ -456,7 +485,7 @@ def sample_delete_breakpoint(): ) # Make the request - client.delete_breakpoint(request=request) + await client.delete_breakpoint(request=request) Args: request (Union[google.cloud.debugger_v2.types.DeleteBreakpointRequest, dict]): @@ -528,9 +557,23 @@ def sample_delete_breakpoint(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("debuggee_id", request.debuggee_id), + ("breakpoint_id", request.breakpoint_id), + ) + ), + ) + # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def list_breakpoints( @@ -549,9 +592,9 @@ async def list_breakpoints( from google.cloud import debugger_v2 - def sample_list_breakpoints(): + async def sample_list_breakpoints(): # Create a client - client = debugger_v2.Debugger2Client() + client = debugger_v2.Debugger2AsyncClient() # Initialize request argument(s) request = debugger_v2.ListBreakpointsRequest( @@ -560,7 +603,7 @@ def sample_list_breakpoints(): ) # Make the request - response = client.list_breakpoints(request=request) + response = await client.list_breakpoints(request=request) # Handle the response print(response) @@ -630,8 +673,21 @@ def sample_list_breakpoints(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("debuggee_id", request.debuggee_id),) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -652,9 +708,9 @@ async def list_debuggees( from google.cloud import debugger_v2 - def sample_list_debuggees(): + async def sample_list_debuggees(): # Create a client - client = debugger_v2.Debugger2Client() + client = debugger_v2.Debugger2AsyncClient() # Initialize request argument(s) request = debugger_v2.ListDebuggeesRequest( @@ -663,7 +719,7 @@ def sample_list_debuggees(): ) # Make the request - response = client.list_debuggees(request=request) + response = await client.list_debuggees(request=request) # Handle the response print(response) @@ -734,7 +790,12 @@ def sample_list_debuggees(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/debugger_v2/services/debugger2/client.py b/google/cloud/debugger_v2/services/debugger2/client.py index 2a73d87..c847870 100644 --- a/google/cloud/debugger_v2/services/debugger2/client.py +++ b/google/cloud/debugger_v2/services/debugger2/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -53,7 +53,10 @@ class Debugger2ClientMeta(type): _transport_registry["grpc"] = Debugger2GrpcTransport _transport_registry["grpc_asyncio"] = Debugger2GrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[Debugger2Transport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[Debugger2Transport]: """Returns an appropriate transport class. Args: @@ -171,7 +174,9 @@ def transport(self) -> Debugger2Transport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -184,9 +189,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -195,9 +204,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -206,9 +219,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -217,10 +234,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -491,8 +512,21 @@ def sample_set_breakpoint(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.set_breakpoint] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("debuggee_id", request.debuggee_id),) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -598,8 +632,24 @@ def sample_get_breakpoint(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.get_breakpoint] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("debuggee_id", request.debuggee_id), + ("breakpoint_id", request.breakpoint_id), + ) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -695,9 +745,23 @@ def sample_delete_breakpoint(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.delete_breakpoint] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("debuggee_id", request.debuggee_id), + ("breakpoint_id", request.breakpoint_id), + ) + ), + ) + # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def list_breakpoints( @@ -787,8 +851,21 @@ def sample_list_breakpoints(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_breakpoints] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("debuggee_id", request.debuggee_id),) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -881,7 +958,12 @@ def sample_list_debuggees(): rpc = self._transport._wrapped_methods[self._transport.list_debuggees] # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/cloud/debugger_v2/services/debugger2/transports/base.py b/google/cloud/debugger_v2/services/debugger2/transports/base.py index c9ce324..d48dfd6 100644 --- a/google/cloud/debugger_v2/services/debugger2/transports/base.py +++ b/google/cloud/debugger_v2/services/debugger2/transports/base.py @@ -84,6 +84,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -125,7 +126,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.set_breakpoint: gapic_v1.method.wrap_method( - self.set_breakpoint, default_timeout=600.0, client_info=client_info, + self.set_breakpoint, + default_timeout=600.0, + client_info=client_info, ), self.get_breakpoint: gapic_v1.method.wrap_method( self.get_breakpoint, @@ -192,9 +195,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -252,5 +255,9 @@ def list_debuggees( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("Debugger2Transport",) diff --git a/google/cloud/debugger_v2/services/debugger2/transports/grpc.py b/google/cloud/debugger_v2/services/debugger2/transports/grpc.py index 9df8b3d..c4f7223 100644 --- a/google/cloud/debugger_v2/services/debugger2/transports/grpc.py +++ b/google/cloud/debugger_v2/services/debugger2/transports/grpc.py @@ -237,8 +237,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -374,5 +373,9 @@ def list_debuggees( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("Debugger2GrpcTransport",) diff --git a/google/cloud/debugger_v2/types/controller.py b/google/cloud/debugger_v2/types/controller.py index 51df565..ebf452f 100644 --- a/google/cloud/debugger_v2/types/controller.py +++ b/google/cloud/debugger_v2/types/controller.py @@ -41,7 +41,11 @@ class RegisterDebuggeeRequest(proto.Message): ``agent_version`` of the debuggee must be set. """ - debuggee = proto.Field(proto.MESSAGE, number=1, message=data.Debuggee,) + debuggee = proto.Field( + proto.MESSAGE, + number=1, + message=data.Debuggee, + ) class RegisterDebuggeeResponse(proto.Message): @@ -57,7 +61,11 @@ class RegisterDebuggeeResponse(proto.Message): ``RegisterDebuggee`` until reenabled. """ - debuggee = proto.Field(proto.MESSAGE, number=1, message=data.Debuggee,) + debuggee = proto.Field( + proto.MESSAGE, + number=1, + message=data.Debuggee, + ) class ListActiveBreakpointsRequest(proto.Message): @@ -83,9 +91,18 @@ class ListActiveBreakpointsRequest(proto.Message): timeout has expired. """ - debuggee_id = proto.Field(proto.STRING, number=1,) - wait_token = proto.Field(proto.STRING, number=2,) - success_on_timeout = proto.Field(proto.BOOL, number=3,) + debuggee_id = proto.Field( + proto.STRING, + number=1, + ) + wait_token = proto.Field( + proto.STRING, + number=2, + ) + success_on_timeout = proto.Field( + proto.BOOL, + number=3, + ) class ListActiveBreakpointsResponse(proto.Message): @@ -106,9 +123,19 @@ class ListActiveBreakpointsResponse(proto.Message): should be ignored. """ - breakpoints = proto.RepeatedField(proto.MESSAGE, number=1, message=data.Breakpoint,) - next_wait_token = proto.Field(proto.STRING, number=2,) - wait_expired = proto.Field(proto.BOOL, number=3,) + breakpoints = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=data.Breakpoint, + ) + next_wait_token = proto.Field( + proto.STRING, + number=2, + ) + wait_expired = proto.Field( + proto.BOOL, + number=3, + ) class UpdateActiveBreakpointRequest(proto.Message): @@ -124,8 +151,15 @@ class UpdateActiveBreakpointRequest(proto.Message): specification fields in the update. """ - debuggee_id = proto.Field(proto.STRING, number=1,) - breakpoint_ = proto.Field(proto.MESSAGE, number=2, message=data.Breakpoint,) + debuggee_id = proto.Field( + proto.STRING, + number=1, + ) + breakpoint_ = proto.Field( + proto.MESSAGE, + number=2, + message=data.Breakpoint, + ) class UpdateActiveBreakpointResponse(proto.Message): diff --git a/google/cloud/debugger_v2/types/data.py b/google/cloud/debugger_v2/types/data.py index adf429b..3d3ecf7 100644 --- a/google/cloud/debugger_v2/types/data.py +++ b/google/cloud/debugger_v2/types/data.py @@ -52,8 +52,14 @@ class FormatMessage(proto.Message): message. """ - format_ = proto.Field(proto.STRING, number=1,) - parameters = proto.RepeatedField(proto.STRING, number=2,) + format_ = proto.Field( + proto.STRING, + number=1, + ) + parameters = proto.RepeatedField( + proto.STRING, + number=2, + ) class StatusMessage(proto.Message): @@ -83,9 +89,20 @@ class Reference(proto.Enum): VARIABLE_NAME = 5 VARIABLE_VALUE = 6 - is_error = proto.Field(proto.BOOL, number=1,) - refers_to = proto.Field(proto.ENUM, number=2, enum=Reference,) - description = proto.Field(proto.MESSAGE, number=3, message="FormatMessage",) + is_error = proto.Field( + proto.BOOL, + number=1, + ) + refers_to = proto.Field( + proto.ENUM, + number=2, + enum=Reference, + ) + description = proto.Field( + proto.MESSAGE, + number=3, + message="FormatMessage", + ) class SourceLocation(proto.Message): @@ -104,9 +121,18 @@ class SourceLocation(proto.Message): on specific columns ignore this field. """ - path = proto.Field(proto.STRING, number=1,) - line = proto.Field(proto.INT32, number=2,) - column = proto.Field(proto.INT32, number=3,) + path = proto.Field( + proto.STRING, + number=1, + ) + line = proto.Field( + proto.INT32, + number=2, + ) + column = proto.Field( + proto.INT32, + number=3, + ) class Variable(proto.Message): @@ -240,14 +266,33 @@ class Variable(proto.Message): - ``Null pointer dereference`` """ - name = proto.Field(proto.STRING, number=1,) - value = proto.Field(proto.STRING, number=2,) - type_ = proto.Field(proto.STRING, number=6,) - members = proto.RepeatedField(proto.MESSAGE, number=3, message="Variable",) + name = proto.Field( + proto.STRING, + number=1, + ) + value = proto.Field( + proto.STRING, + number=2, + ) + type_ = proto.Field( + proto.STRING, + number=6, + ) + members = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="Variable", + ) var_table_index = proto.Field( - proto.MESSAGE, number=4, message=wrappers_pb2.Int32Value, + proto.MESSAGE, + number=4, + message=wrappers_pb2.Int32Value, + ) + status = proto.Field( + proto.MESSAGE, + number=5, + message="StatusMessage", ) - status = proto.Field(proto.MESSAGE, number=5, message="StatusMessage",) class StackFrame(proto.Message): @@ -268,10 +313,25 @@ class StackFrame(proto.Message): for all stack frames. """ - function = proto.Field(proto.STRING, number=1,) - location = proto.Field(proto.MESSAGE, number=2, message="SourceLocation",) - arguments = proto.RepeatedField(proto.MESSAGE, number=3, message="Variable",) - locals_ = proto.RepeatedField(proto.MESSAGE, number=4, message="Variable",) + function = proto.Field( + proto.STRING, + number=1, + ) + location = proto.Field( + proto.MESSAGE, + number=2, + message="SourceLocation", + ) + arguments = proto.RepeatedField( + proto.MESSAGE, + number=3, + message="Variable", + ) + locals_ = proto.RepeatedField( + proto.MESSAGE, + number=4, + message="Variable", + ) class Breakpoint(proto.Message): @@ -367,7 +427,7 @@ class Breakpoint(proto.Message): their name from the referencing variable. The effective variable is a merge of the referencing variable and the referenced variable. - labels (Sequence[google.cloud.debugger_v2.types.Breakpoint.LabelsEntry]): + labels (Mapping[str, str]): A set of custom breakpoint properties, populated by the agent, to be displayed to the user. @@ -387,26 +447,80 @@ class LogLevel(proto.Enum): WARNING = 1 ERROR = 2 - id = proto.Field(proto.STRING, number=1,) - action = proto.Field(proto.ENUM, number=13, enum=Action,) - location = proto.Field(proto.MESSAGE, number=2, message="SourceLocation",) - condition = proto.Field(proto.STRING, number=3,) - expressions = proto.RepeatedField(proto.STRING, number=4,) - log_message_format = proto.Field(proto.STRING, number=14,) - log_level = proto.Field(proto.ENUM, number=15, enum=LogLevel,) - is_final_state = proto.Field(proto.BOOL, number=5,) + id = proto.Field( + proto.STRING, + number=1, + ) + action = proto.Field( + proto.ENUM, + number=13, + enum=Action, + ) + location = proto.Field( + proto.MESSAGE, + number=2, + message="SourceLocation", + ) + condition = proto.Field( + proto.STRING, + number=3, + ) + expressions = proto.RepeatedField( + proto.STRING, + number=4, + ) + log_message_format = proto.Field( + proto.STRING, + number=14, + ) + log_level = proto.Field( + proto.ENUM, + number=15, + enum=LogLevel, + ) + is_final_state = proto.Field( + proto.BOOL, + number=5, + ) create_time = proto.Field( - proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=11, + message=timestamp_pb2.Timestamp, + ) + final_time = proto.Field( + proto.MESSAGE, + number=12, + message=timestamp_pb2.Timestamp, + ) + user_email = proto.Field( + proto.STRING, + number=16, + ) + status = proto.Field( + proto.MESSAGE, + number=10, + message="StatusMessage", + ) + stack_frames = proto.RepeatedField( + proto.MESSAGE, + number=7, + message="StackFrame", ) - final_time = proto.Field(proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp,) - user_email = proto.Field(proto.STRING, number=16,) - status = proto.Field(proto.MESSAGE, number=10, message="StatusMessage",) - stack_frames = proto.RepeatedField(proto.MESSAGE, number=7, message="StackFrame",) evaluated_expressions = proto.RepeatedField( - proto.MESSAGE, number=8, message="Variable", + proto.MESSAGE, + number=8, + message="Variable", + ) + variable_table = proto.RepeatedField( + proto.MESSAGE, + number=9, + message="Variable", + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=17, ) - variable_table = proto.RepeatedField(proto.MESSAGE, number=9, message="Variable",) - labels = proto.MapField(proto.STRING, proto.STRING, number=17,) class Debuggee(proto.Message): @@ -465,27 +579,60 @@ class Debuggee(proto.Message): References to the locations and revisions of the source code used in the deployed application. - labels (Sequence[google.cloud.debugger_v2.types.Debuggee.LabelsEntry]): + labels (Mapping[str, str]): A set of custom debuggee properties, populated by the agent, to be displayed to the user. """ - id = proto.Field(proto.STRING, number=1,) - project = proto.Field(proto.STRING, number=2,) - uniquifier = proto.Field(proto.STRING, number=3,) - description = proto.Field(proto.STRING, number=4,) - is_inactive = proto.Field(proto.BOOL, number=5,) - agent_version = proto.Field(proto.STRING, number=6,) - is_disabled = proto.Field(proto.BOOL, number=7,) - status = proto.Field(proto.MESSAGE, number=8, message="StatusMessage",) + id = proto.Field( + proto.STRING, + number=1, + ) + project = proto.Field( + proto.STRING, + number=2, + ) + uniquifier = proto.Field( + proto.STRING, + number=3, + ) + description = proto.Field( + proto.STRING, + number=4, + ) + is_inactive = proto.Field( + proto.BOOL, + number=5, + ) + agent_version = proto.Field( + proto.STRING, + number=6, + ) + is_disabled = proto.Field( + proto.BOOL, + number=7, + ) + status = proto.Field( + proto.MESSAGE, + number=8, + message="StatusMessage", + ) source_contexts = proto.RepeatedField( - proto.MESSAGE, number=9, message=source_context_pb2.SourceContext, + proto.MESSAGE, + number=9, + message=source_context_pb2.SourceContext, ) ext_source_contexts = proto.RepeatedField( - proto.MESSAGE, number=13, message=source_context_pb2.ExtendedSourceContext, + proto.MESSAGE, + number=13, + message=source_context_pb2.ExtendedSourceContext, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=11, ) - labels = proto.MapField(proto.STRING, proto.STRING, number=11,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/debugger_v2/types/debugger.py b/google/cloud/debugger_v2/types/debugger.py index 0c34f2b..878c1ed 100644 --- a/google/cloud/debugger_v2/types/debugger.py +++ b/google/cloud/debugger_v2/types/debugger.py @@ -49,9 +49,19 @@ class SetBreakpointRequest(proto.Message): ``domain/type/version`` (e.g., ``google.com/intellij/v1``). """ - debuggee_id = proto.Field(proto.STRING, number=1,) - breakpoint_ = proto.Field(proto.MESSAGE, number=2, message=data.Breakpoint,) - client_version = proto.Field(proto.STRING, number=4,) + debuggee_id = proto.Field( + proto.STRING, + number=1, + ) + breakpoint_ = proto.Field( + proto.MESSAGE, + number=2, + message=data.Breakpoint, + ) + client_version = proto.Field( + proto.STRING, + number=4, + ) class SetBreakpointResponse(proto.Message): @@ -63,7 +73,11 @@ class SetBreakpointResponse(proto.Message): set (in addition to the echoed fileds). """ - breakpoint_ = proto.Field(proto.MESSAGE, number=1, message=data.Breakpoint,) + breakpoint_ = proto.Field( + proto.MESSAGE, + number=1, + message=data.Breakpoint, + ) class GetBreakpointRequest(proto.Message): @@ -80,9 +94,18 @@ class GetBreakpointRequest(proto.Message): ``domain/type/version`` (e.g., ``google.com/intellij/v1``). """ - debuggee_id = proto.Field(proto.STRING, number=1,) - breakpoint_id = proto.Field(proto.STRING, number=2,) - client_version = proto.Field(proto.STRING, number=4,) + debuggee_id = proto.Field( + proto.STRING, + number=1, + ) + breakpoint_id = proto.Field( + proto.STRING, + number=2, + ) + client_version = proto.Field( + proto.STRING, + number=4, + ) class GetBreakpointResponse(proto.Message): @@ -94,7 +117,11 @@ class GetBreakpointResponse(proto.Message): ``location`` are guaranteed to be set. """ - breakpoint_ = proto.Field(proto.MESSAGE, number=1, message=data.Breakpoint,) + breakpoint_ = proto.Field( + proto.MESSAGE, + number=1, + message=data.Breakpoint, + ) class DeleteBreakpointRequest(proto.Message): @@ -111,9 +138,18 @@ class DeleteBreakpointRequest(proto.Message): ``domain/type/version`` (e.g., ``google.com/intellij/v1``). """ - debuggee_id = proto.Field(proto.STRING, number=1,) - breakpoint_id = proto.Field(proto.STRING, number=2,) - client_version = proto.Field(proto.STRING, number=3,) + debuggee_id = proto.Field( + proto.STRING, + number=1, + ) + breakpoint_id = proto.Field( + proto.STRING, + number=2, + ) + client_version = proto.Field( + proto.STRING, + number=3, + ) class ListBreakpointsRequest(proto.Message): @@ -160,15 +196,41 @@ class BreakpointActionValue(proto.Message): will pass the filter. """ - value = proto.Field(proto.ENUM, number=1, enum=data.Breakpoint.Action,) - - debuggee_id = proto.Field(proto.STRING, number=1,) - include_all_users = proto.Field(proto.BOOL, number=2,) - include_inactive = proto.Field(proto.BOOL, number=3,) - action = proto.Field(proto.MESSAGE, number=4, message=BreakpointActionValue,) - strip_results = proto.Field(proto.BOOL, number=5,) - wait_token = proto.Field(proto.STRING, number=6,) - client_version = proto.Field(proto.STRING, number=8,) + value = proto.Field( + proto.ENUM, + number=1, + enum=data.Breakpoint.Action, + ) + + debuggee_id = proto.Field( + proto.STRING, + number=1, + ) + include_all_users = proto.Field( + proto.BOOL, + number=2, + ) + include_inactive = proto.Field( + proto.BOOL, + number=3, + ) + action = proto.Field( + proto.MESSAGE, + number=4, + message=BreakpointActionValue, + ) + strip_results = proto.Field( + proto.BOOL, + number=5, + ) + wait_token = proto.Field( + proto.STRING, + number=6, + ) + client_version = proto.Field( + proto.STRING, + number=8, + ) class ListBreakpointsResponse(proto.Message): @@ -187,8 +249,15 @@ class ListBreakpointsResponse(proto.Message): of breakpoints has changes. """ - breakpoints = proto.RepeatedField(proto.MESSAGE, number=1, message=data.Breakpoint,) - next_wait_token = proto.Field(proto.STRING, number=2,) + breakpoints = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=data.Breakpoint, + ) + next_wait_token = proto.Field( + proto.STRING, + number=2, + ) class ListDebuggeesRequest(proto.Message): @@ -207,9 +276,18 @@ class ListDebuggeesRequest(proto.Message): ``domain/type/version`` (e.g., ``google.com/intellij/v1``). """ - project = proto.Field(proto.STRING, number=2,) - include_inactive = proto.Field(proto.BOOL, number=3,) - client_version = proto.Field(proto.STRING, number=4,) + project = proto.Field( + proto.STRING, + number=2, + ) + include_inactive = proto.Field( + proto.BOOL, + number=3, + ) + client_version = proto.Field( + proto.STRING, + number=4, + ) class ListDebuggeesResponse(proto.Message): @@ -223,7 +301,11 @@ class ListDebuggeesResponse(proto.Message): provided by agents and can be displayed to users. """ - debuggees = proto.RepeatedField(proto.MESSAGE, number=1, message=data.Debuggee,) + debuggees = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=data.Debuggee, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c..92da31f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,16 +20,41 @@ import os import pathlib import shutil +import warnings import nox - -BLACK_VERSION = "black==19.10b0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -57,7 +82,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +94,28 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) @@ -78,23 +126,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -118,6 +184,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -140,13 +235,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: diff --git a/owlbot.py b/owlbot.py index 0f3e541..ac60721 100644 --- a/owlbot.py +++ b/owlbot.py @@ -51,6 +51,15 @@ "google.cloud.source_context_v1.types.source_context_pb2" ) + s.replace( + [ + library / f"google/cloud/debugger_{library.name}/services/**/*client.py", + library / f"tests/unit/gapic/debugger_{library.name}/test_controller2.py", + ], + "request\.breakpoint\.", + "request.breakpoint_." + ) + s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst"]) s.remove_staging_dirs() @@ -63,6 +72,8 @@ python.py_samples(skip_readmes=True) s.move(templated_files, excludes=[".coveragerc"]) # the microgenerator has a good coveragerc file +python.configure_previous_major_version_branches() + # ---------------------------------------------------------------------------- # Run blacken session # ---------------------------------------------------------------------------- diff --git a/samples/generated_samples/snippet_metadata_debugger_v2.json b/samples/generated_samples/snippet_metadata_debugger_v2.json index eafbe07..f1dcd45 100644 --- a/samples/generated_samples/snippet_metadata_debugger_v2.json +++ b/samples/generated_samples/snippet_metadata_debugger_v2.json @@ -1,16 +1,61 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.devtools.clouddebugger.v2", + "version": "v2" + } + ], + "language": "PYTHON", + "name": "google-cloud-debugger-client" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.debugger_v2.Controller2AsyncClient", + "shortName": "Controller2AsyncClient" + }, + "fullName": "google.cloud.debugger_v2.Controller2AsyncClient.list_active_breakpoints", "method": { + "fullName": "google.devtools.clouddebugger.v2.Controller2.ListActiveBreakpoints", "service": { + "fullName": "google.devtools.clouddebugger.v2.Controller2", "shortName": "Controller2" }, "shortName": "ListActiveBreakpoints" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.ListActiveBreakpointsRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.ListActiveBreakpointsResponse", + "shortName": "list_active_breakpoints" }, + "description": "Sample for ListActiveBreakpoints", "file": "clouddebugger_v2_generated_controller2_list_active_breakpoints_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Controller2_ListActiveBreakpoints_async", "segments": [ { @@ -43,18 +88,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_controller2_list_active_breakpoints_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.debugger_v2.Controller2Client", + "shortName": "Controller2Client" + }, + "fullName": "google.cloud.debugger_v2.Controller2Client.list_active_breakpoints", "method": { + "fullName": "google.devtools.clouddebugger.v2.Controller2.ListActiveBreakpoints", "service": { + "fullName": "google.devtools.clouddebugger.v2.Controller2", "shortName": "Controller2" }, "shortName": "ListActiveBreakpoints" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.ListActiveBreakpointsRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.ListActiveBreakpointsResponse", + "shortName": "list_active_breakpoints" }, + "description": "Sample for ListActiveBreakpoints", "file": "clouddebugger_v2_generated_controller2_list_active_breakpoints_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Controller2_ListActiveBreakpoints_sync", "segments": [ { @@ -87,19 +168,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_controller2_list_active_breakpoints_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.debugger_v2.Controller2AsyncClient", + "shortName": "Controller2AsyncClient" + }, + "fullName": "google.cloud.debugger_v2.Controller2AsyncClient.register_debuggee", "method": { + "fullName": "google.devtools.clouddebugger.v2.Controller2.RegisterDebuggee", "service": { + "fullName": "google.devtools.clouddebugger.v2.Controller2", "shortName": "Controller2" }, "shortName": "RegisterDebuggee" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.RegisterDebuggeeRequest" + }, + { + "name": "debuggee", + "type": "google.cloud.debugger_v2.types.Debuggee" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.RegisterDebuggeeResponse", + "shortName": "register_debuggee" }, + "description": "Sample for RegisterDebuggee", "file": "clouddebugger_v2_generated_controller2_register_debuggee_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Controller2_RegisterDebuggee_async", "segments": [ { @@ -132,18 +249,54 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_controller2_register_debuggee_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.debugger_v2.Controller2Client", + "shortName": "Controller2Client" + }, + "fullName": "google.cloud.debugger_v2.Controller2Client.register_debuggee", "method": { + "fullName": "google.devtools.clouddebugger.v2.Controller2.RegisterDebuggee", "service": { + "fullName": "google.devtools.clouddebugger.v2.Controller2", "shortName": "Controller2" }, "shortName": "RegisterDebuggee" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.RegisterDebuggeeRequest" + }, + { + "name": "debuggee", + "type": "google.cloud.debugger_v2.types.Debuggee" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.RegisterDebuggeeResponse", + "shortName": "register_debuggee" }, + "description": "Sample for RegisterDebuggee", "file": "clouddebugger_v2_generated_controller2_register_debuggee_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Controller2_RegisterDebuggee_sync", "segments": [ { @@ -176,19 +329,59 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_controller2_register_debuggee_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.debugger_v2.Controller2AsyncClient", + "shortName": "Controller2AsyncClient" + }, + "fullName": "google.cloud.debugger_v2.Controller2AsyncClient.update_active_breakpoint", "method": { + "fullName": "google.devtools.clouddebugger.v2.Controller2.UpdateActiveBreakpoint", "service": { + "fullName": "google.devtools.clouddebugger.v2.Controller2", "shortName": "Controller2" }, "shortName": "UpdateActiveBreakpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.UpdateActiveBreakpointRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "breakpoint_", + "type": "google.cloud.debugger_v2.types.Breakpoint" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.UpdateActiveBreakpointResponse", + "shortName": "update_active_breakpoint" }, + "description": "Sample for UpdateActiveBreakpoint", "file": "clouddebugger_v2_generated_controller2_update_active_breakpoint_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Controller2_UpdateActiveBreakpoint_async", "segments": [ { @@ -221,18 +414,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_controller2_update_active_breakpoint_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.debugger_v2.Controller2Client", + "shortName": "Controller2Client" + }, + "fullName": "google.cloud.debugger_v2.Controller2Client.update_active_breakpoint", "method": { + "fullName": "google.devtools.clouddebugger.v2.Controller2.UpdateActiveBreakpoint", "service": { + "fullName": "google.devtools.clouddebugger.v2.Controller2", "shortName": "Controller2" }, "shortName": "UpdateActiveBreakpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.UpdateActiveBreakpointRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "breakpoint_", + "type": "google.cloud.debugger_v2.types.Breakpoint" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.UpdateActiveBreakpointResponse", + "shortName": "update_active_breakpoint" }, + "description": "Sample for UpdateActiveBreakpoint", "file": "clouddebugger_v2_generated_controller2_update_active_breakpoint_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Controller2_UpdateActiveBreakpoint_sync", "segments": [ { @@ -265,19 +498,62 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_controller2_update_active_breakpoint_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient", + "shortName": "Debugger2AsyncClient" + }, + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient.delete_breakpoint", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.DeleteBreakpoint", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "DeleteBreakpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.DeleteBreakpointRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "breakpoint_id", + "type": "str" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_breakpoint" }, + "description": "Sample for DeleteBreakpoint", "file": "clouddebugger_v2_generated_debugger2_delete_breakpoint_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_DeleteBreakpoint_async", "segments": [ { @@ -308,18 +584,61 @@ "end": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_delete_breakpoint_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2Client", + "shortName": "Debugger2Client" + }, + "fullName": "google.cloud.debugger_v2.Debugger2Client.delete_breakpoint", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.DeleteBreakpoint", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "DeleteBreakpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.DeleteBreakpointRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "breakpoint_id", + "type": "str" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_breakpoint" }, + "description": "Sample for DeleteBreakpoint", "file": "clouddebugger_v2_generated_debugger2_delete_breakpoint_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_DeleteBreakpoint_sync", "segments": [ { @@ -350,19 +669,63 @@ "end": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_delete_breakpoint_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient", + "shortName": "Debugger2AsyncClient" + }, + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient.get_breakpoint", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.GetBreakpoint", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "GetBreakpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.GetBreakpointRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "breakpoint_id", + "type": "str" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.GetBreakpointResponse", + "shortName": "get_breakpoint" }, + "description": "Sample for GetBreakpoint", "file": "clouddebugger_v2_generated_debugger2_get_breakpoint_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_GetBreakpoint_async", "segments": [ { @@ -395,18 +758,62 @@ "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_get_breakpoint_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2Client", + "shortName": "Debugger2Client" + }, + "fullName": "google.cloud.debugger_v2.Debugger2Client.get_breakpoint", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.GetBreakpoint", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "GetBreakpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.GetBreakpointRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "breakpoint_id", + "type": "str" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.GetBreakpointResponse", + "shortName": "get_breakpoint" }, + "description": "Sample for GetBreakpoint", "file": "clouddebugger_v2_generated_debugger2_get_breakpoint_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_GetBreakpoint_sync", "segments": [ { @@ -439,19 +846,59 @@ "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_get_breakpoint_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient", + "shortName": "Debugger2AsyncClient" + }, + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient.list_breakpoints", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.ListBreakpoints", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "ListBreakpoints" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.ListBreakpointsRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.ListBreakpointsResponse", + "shortName": "list_breakpoints" }, + "description": "Sample for ListBreakpoints", "file": "clouddebugger_v2_generated_debugger2_list_breakpoints_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_ListBreakpoints_async", "segments": [ { @@ -484,18 +931,58 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_list_breakpoints_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2Client", + "shortName": "Debugger2Client" + }, + "fullName": "google.cloud.debugger_v2.Debugger2Client.list_breakpoints", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.ListBreakpoints", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "ListBreakpoints" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.ListBreakpointsRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.ListBreakpointsResponse", + "shortName": "list_breakpoints" }, + "description": "Sample for ListBreakpoints", "file": "clouddebugger_v2_generated_debugger2_list_breakpoints_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_ListBreakpoints_sync", "segments": [ { @@ -528,19 +1015,59 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_list_breakpoints_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient", + "shortName": "Debugger2AsyncClient" + }, + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient.list_debuggees", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.ListDebuggees", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "ListDebuggees" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.ListDebuggeesRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.ListDebuggeesResponse", + "shortName": "list_debuggees" }, + "description": "Sample for ListDebuggees", "file": "clouddebugger_v2_generated_debugger2_list_debuggees_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_ListDebuggees_async", "segments": [ { @@ -573,18 +1100,58 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_list_debuggees_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2Client", + "shortName": "Debugger2Client" + }, + "fullName": "google.cloud.debugger_v2.Debugger2Client.list_debuggees", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.ListDebuggees", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "ListDebuggees" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.ListDebuggeesRequest" + }, + { + "name": "project", + "type": "str" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.ListDebuggeesResponse", + "shortName": "list_debuggees" }, + "description": "Sample for ListDebuggees", "file": "clouddebugger_v2_generated_debugger2_list_debuggees_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_ListDebuggees_sync", "segments": [ { @@ -617,19 +1184,63 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_list_debuggees_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient", + "shortName": "Debugger2AsyncClient" + }, + "fullName": "google.cloud.debugger_v2.Debugger2AsyncClient.set_breakpoint", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.SetBreakpoint", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "SetBreakpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.SetBreakpointRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "breakpoint_", + "type": "google.cloud.debugger_v2.types.Breakpoint" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.SetBreakpointResponse", + "shortName": "set_breakpoint" }, + "description": "Sample for SetBreakpoint", "file": "clouddebugger_v2_generated_debugger2_set_breakpoint_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_SetBreakpoint_async", "segments": [ { @@ -662,18 +1273,62 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_set_breakpoint_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.debugger_v2.Debugger2Client", + "shortName": "Debugger2Client" + }, + "fullName": "google.cloud.debugger_v2.Debugger2Client.set_breakpoint", "method": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2.SetBreakpoint", "service": { + "fullName": "google.devtools.clouddebugger.v2.Debugger2", "shortName": "Debugger2" }, "shortName": "SetBreakpoint" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.debugger_v2.types.SetBreakpointRequest" + }, + { + "name": "debuggee_id", + "type": "str" + }, + { + "name": "breakpoint_", + "type": "google.cloud.debugger_v2.types.Breakpoint" + }, + { + "name": "client_version", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.debugger_v2.types.SetBreakpointResponse", + "shortName": "set_breakpoint" }, + "description": "Sample for SetBreakpoint", "file": "clouddebugger_v2_generated_debugger2_set_breakpoint_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "clouddebugger_v2_generated_Debugger2_SetBreakpoint_sync", "segments": [ { @@ -706,7 +1361,8 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "clouddebugger_v2_generated_debugger2_set_breakpoint_sync.py" } ] } diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e..91b5967 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -28,7 +28,10 @@ jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( - os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + os.path.abspath(os.path.join(os.path.dirname(__file__), "templates")) + ), + autoescape=True, +) README_TMPL = jinja_env.get_template('README.tmpl.rst') diff --git a/setup.py b/setup.py index d7dae8a..34b7e05 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ name = "google-cloud-debugger-client" description = "Cloud Debugger API client library" -version = "1.3.1" +version = "1.3.2" release_status = "Development Status :: 5 - Production/Stable" url = "https://github.com/googleapis/python-debugger-client" dependencies = [ @@ -29,8 +29,9 @@ # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", - "proto-plus >= 1.15.0", - "google-cloud-source-context >= 1.0.0", + "proto-plus >= 1.15.0, <2.0.0dev", + "protobuf >= 3.19.0, <4.0.0dev", + "google-cloud-source-context >= 1.0.0, <2.0.0dev", ] package_root = os.path.abspath(os.path.dirname(__file__)) diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 28f0c99..0f4f159 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -7,3 +7,4 @@ google-api-core==1.31.5 proto-plus==1.15.0 google-cloud-source-context==1.0.0 +protobuf==3.19.0 diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index e69de29..0f4f159 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -0,0 +1,10 @@ +# 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 "google-cloud-foo >= 1.14.0, < 2.0.0dev", +# Then this file should have google-cloud-foo==1.14.0 +google-api-core==1.31.5 +proto-plus==1.15.0 +google-cloud-source-context==1.0.0 +protobuf==3.19.0 diff --git a/tests/unit/gapic/debugger_v2/test_controller2.py b/tests/unit/gapic/debugger_v2/test_controller2.py index e589508..769d972 100644 --- a/tests/unit/gapic/debugger_v2/test_controller2.py +++ b/tests/unit/gapic/debugger_v2/test_controller2.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -84,19 +90,25 @@ def test__get_default_mtls_endpoint(): assert Controller2Client._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [Controller2Client, Controller2AsyncClient,]) -def test_controller2_client_from_service_account_info(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (Controller2Client, "grpc"), + (Controller2AsyncClient, "grpc_asyncio"), + ], +) +def test_controller2_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "clouddebugger.googleapis.com:443" + assert client.transport._host == ("clouddebugger.googleapis.com:443") @pytest.mark.parametrize( @@ -124,22 +136,32 @@ def test_controller2_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [Controller2Client, Controller2AsyncClient,]) -def test_controller2_client_from_service_account_file(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (Controller2Client, "grpc"), + (Controller2AsyncClient, "grpc_asyncio"), + ], +) +def test_controller2_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "clouddebugger.googleapis.com:443" + assert client.transport._host == ("clouddebugger.googleapis.com:443") def test_controller2_client_get_transport_class(): @@ -479,7 +501,9 @@ def test_controller2_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -610,10 +634,17 @@ def test_controller2_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [controller.RegisterDebuggeeRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + controller.RegisterDebuggeeRequest, + dict, + ], +) def test_register_debuggee(request_type, transport: str = "grpc"): client = Controller2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -641,7 +672,8 @@ def test_register_debuggee_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = Controller2Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -659,7 +691,8 @@ async def test_register_debuggee_async( transport: str = "grpc_asyncio", request_type=controller.RegisterDebuggeeRequest ): client = Controller2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -691,7 +724,9 @@ async def test_register_debuggee_async_from_dict(): def test_register_debuggee_flattened(): - client = Controller2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -701,7 +736,9 @@ def test_register_debuggee_flattened(): call.return_value = controller.RegisterDebuggeeResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.register_debuggee(debuggee=data.Debuggee(id="id_value"),) + client.register_debuggee( + debuggee=data.Debuggee(id="id_value"), + ) # Establish that the underlying call was made with the expected # request object values. @@ -713,19 +750,24 @@ def test_register_debuggee_flattened(): def test_register_debuggee_flattened_error(): - client = Controller2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.register_debuggee( - controller.RegisterDebuggeeRequest(), debuggee=data.Debuggee(id="id_value"), + controller.RegisterDebuggeeRequest(), + debuggee=data.Debuggee(id="id_value"), ) @pytest.mark.asyncio async def test_register_debuggee_flattened_async(): - client = Controller2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -754,22 +796,30 @@ async def test_register_debuggee_flattened_async(): @pytest.mark.asyncio async def test_register_debuggee_flattened_error_async(): - client = Controller2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.register_debuggee( - controller.RegisterDebuggeeRequest(), debuggee=data.Debuggee(id="id_value"), + controller.RegisterDebuggeeRequest(), + debuggee=data.Debuggee(id="id_value"), ) @pytest.mark.parametrize( - "request_type", [controller.ListActiveBreakpointsRequest, dict,] + "request_type", + [ + controller.ListActiveBreakpointsRequest, + dict, + ], ) def test_list_active_breakpoints(request_type, transport: str = "grpc"): client = Controller2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -782,7 +832,8 @@ def test_list_active_breakpoints(request_type, transport: str = "grpc"): ) as call: # Designate an appropriate return value for the call. call.return_value = controller.ListActiveBreakpointsResponse( - next_wait_token="next_wait_token_value", wait_expired=True, + next_wait_token="next_wait_token_value", + wait_expired=True, ) response = client.list_active_breakpoints(request) @@ -801,7 +852,8 @@ def test_list_active_breakpoints_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = Controller2Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -820,7 +872,8 @@ async def test_list_active_breakpoints_async( request_type=controller.ListActiveBreakpointsRequest, ): client = Controller2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -834,7 +887,8 @@ async def test_list_active_breakpoints_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( controller.ListActiveBreakpointsResponse( - next_wait_token="next_wait_token_value", wait_expired=True, + next_wait_token="next_wait_token_value", + wait_expired=True, ) ) response = await client.list_active_breakpoints(request) @@ -855,8 +909,75 @@ async def test_list_active_breakpoints_async_from_dict(): await test_list_active_breakpoints_async(request_type=dict) +def test_list_active_breakpoints_field_headers(): + client = Controller2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = controller.ListActiveBreakpointsRequest() + + request.debuggee_id = "debuggee_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_active_breakpoints), "__call__" + ) as call: + call.return_value = controller.ListActiveBreakpointsResponse() + client.list_active_breakpoints(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_active_breakpoints_field_headers_async(): + client = Controller2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = controller.ListActiveBreakpointsRequest() + + request.debuggee_id = "debuggee_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_active_breakpoints), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + controller.ListActiveBreakpointsResponse() + ) + await client.list_active_breakpoints(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value", + ) in kw["metadata"] + + def test_list_active_breakpoints_flattened(): - client = Controller2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -866,7 +987,9 @@ def test_list_active_breakpoints_flattened(): call.return_value = controller.ListActiveBreakpointsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_active_breakpoints(debuggee_id="debuggee_id_value",) + client.list_active_breakpoints( + debuggee_id="debuggee_id_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -878,19 +1001,24 @@ def test_list_active_breakpoints_flattened(): def test_list_active_breakpoints_flattened_error(): - client = Controller2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_active_breakpoints( - controller.ListActiveBreakpointsRequest(), debuggee_id="debuggee_id_value", + controller.ListActiveBreakpointsRequest(), + debuggee_id="debuggee_id_value", ) @pytest.mark.asyncio async def test_list_active_breakpoints_flattened_async(): - client = Controller2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -919,22 +1047,30 @@ async def test_list_active_breakpoints_flattened_async(): @pytest.mark.asyncio async def test_list_active_breakpoints_flattened_error_async(): - client = Controller2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_active_breakpoints( - controller.ListActiveBreakpointsRequest(), debuggee_id="debuggee_id_value", + controller.ListActiveBreakpointsRequest(), + debuggee_id="debuggee_id_value", ) @pytest.mark.parametrize( - "request_type", [controller.UpdateActiveBreakpointRequest, dict,] + "request_type", + [ + controller.UpdateActiveBreakpointRequest, + dict, + ], ) def test_update_active_breakpoint(request_type, transport: str = "grpc"): client = Controller2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -962,7 +1098,8 @@ def test_update_active_breakpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = Controller2Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -981,7 +1118,8 @@ async def test_update_active_breakpoint_async( request_type=controller.UpdateActiveBreakpointRequest, ): client = Controller2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1012,8 +1150,77 @@ async def test_update_active_breakpoint_async_from_dict(): await test_update_active_breakpoint_async(request_type=dict) +def test_update_active_breakpoint_field_headers(): + client = Controller2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = controller.UpdateActiveBreakpointRequest() + + request.debuggee_id = "debuggee_id_value" + request.breakpoint_.id = "id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_active_breakpoint), "__call__" + ) as call: + call.return_value = controller.UpdateActiveBreakpointResponse() + client.update_active_breakpoint(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value&breakpoint.id=id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_active_breakpoint_field_headers_async(): + client = Controller2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = controller.UpdateActiveBreakpointRequest() + + request.debuggee_id = "debuggee_id_value" + request.breakpoint_.id = "id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_active_breakpoint), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + controller.UpdateActiveBreakpointResponse() + ) + await client.update_active_breakpoint(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value&breakpoint.id=id_value", + ) in kw["metadata"] + + def test_update_active_breakpoint_flattened(): - client = Controller2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1024,7 +1231,8 @@ def test_update_active_breakpoint_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_active_breakpoint( - debuggee_id="debuggee_id_value", breakpoint_=data.Breakpoint(id="id_value"), + debuggee_id="debuggee_id_value", + breakpoint_=data.Breakpoint(id="id_value"), ) # Establish that the underlying call was made with the expected @@ -1040,7 +1248,9 @@ def test_update_active_breakpoint_flattened(): def test_update_active_breakpoint_flattened_error(): - client = Controller2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1054,7 +1264,9 @@ def test_update_active_breakpoint_flattened_error(): @pytest.mark.asyncio async def test_update_active_breakpoint_flattened_async(): - client = Controller2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1069,7 +1281,8 @@ async def test_update_active_breakpoint_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_active_breakpoint( - debuggee_id="debuggee_id_value", breakpoint_=data.Breakpoint(id="id_value"), + debuggee_id="debuggee_id_value", + breakpoint_=data.Breakpoint(id="id_value"), ) # Establish that the underlying call was made with the expected @@ -1086,7 +1299,9 @@ async def test_update_active_breakpoint_flattened_async(): @pytest.mark.asyncio async def test_update_active_breakpoint_flattened_error_async(): - client = Controller2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Controller2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1105,7 +1320,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = Controller2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1125,7 +1341,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = Controller2Client(client_options=options, transport=transport,) + client = Controller2Client( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1141,7 +1360,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = Controller2Client( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1171,7 +1391,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.Controller2GrpcTransport, transports.Controller2GrpcAsyncIOTransport,], + [ + transports.Controller2GrpcTransport, + transports.Controller2GrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -1181,10 +1404,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = Controller2Client.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = Controller2Client(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.Controller2GrpcTransport,) + client = Controller2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.Controller2GrpcTransport, + ) def test_controller2_base_transport_error(): @@ -1220,6 +1461,14 @@ def test_controller2_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_controller2_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1231,7 +1480,8 @@ def test_controller2_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.Controller2Transport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1272,7 +1522,10 @@ def test_controller2_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.Controller2GrpcTransport, transports.Controller2GrpcAsyncIOTransport,], + [ + transports.Controller2GrpcTransport, + transports.Controller2GrpcAsyncIOTransport, + ], ) def test_controller2_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -1370,24 +1623,40 @@ def test_controller2_grpc_transport_client_cert_source_for_mtls(transport_class) ) -def test_controller2_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_controller2_host_no_port(transport_name): client = Controller2Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="clouddebugger.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "clouddebugger.googleapis.com:443" + assert client.transport._host == ("clouddebugger.googleapis.com:443") -def test_controller2_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_controller2_host_with_port(transport_name): client = Controller2Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="clouddebugger.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "clouddebugger.googleapis.com:8000" + assert client.transport._host == ("clouddebugger.googleapis.com:8000") def test_controller2_grpc_transport_channel(): @@ -1395,7 +1664,8 @@ def test_controller2_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.Controller2GrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1407,7 +1677,8 @@ def test_controller2_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.Controller2GrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1528,7 +1799,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = Controller2Client.common_folder_path(folder) assert expected == actual @@ -1546,7 +1819,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = Controller2Client.common_organization_path(organization) assert expected == actual @@ -1564,7 +1839,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = Controller2Client.common_project_path(project) assert expected == actual @@ -1584,7 +1861,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = Controller2Client.common_location_path(project, location) assert expected == actual @@ -1609,7 +1887,8 @@ def test_client_with_default_client_info(): transports.Controller2Transport, "_prep_wrapped_messages" ) as prep: client = Controller2Client( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1618,7 +1897,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = Controller2Client.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1626,7 +1906,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = Controller2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/debugger_v2/test_debugger2.py b/tests/unit/gapic/debugger_v2/test_debugger2.py index 3f4810c..89d7f02 100644 --- a/tests/unit/gapic/debugger_v2/test_debugger2.py +++ b/tests/unit/gapic/debugger_v2/test_debugger2.py @@ -14,7 +14,13 @@ # limitations under the License. # import os -import mock + +# try/except added for compatibility with python < 3.8 +try: + from unittest import mock + from unittest.mock import AsyncMock +except ImportError: + import mock import grpc from grpc.experimental import aio @@ -81,19 +87,25 @@ def test__get_default_mtls_endpoint(): assert Debugger2Client._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [Debugger2Client, Debugger2AsyncClient,]) -def test_debugger2_client_from_service_account_info(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (Debugger2Client, "grpc"), + (Debugger2AsyncClient, "grpc_asyncio"), + ], +) +def test_debugger2_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "clouddebugger.googleapis.com:443" + assert client.transport._host == ("clouddebugger.googleapis.com:443") @pytest.mark.parametrize( @@ -121,22 +133,32 @@ def test_debugger2_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [Debugger2Client, Debugger2AsyncClient,]) -def test_debugger2_client_from_service_account_file(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (Debugger2Client, "grpc"), + (Debugger2AsyncClient, "grpc_asyncio"), + ], +) +def test_debugger2_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "clouddebugger.googleapis.com:443" + assert client.transport._host == ("clouddebugger.googleapis.com:443") def test_debugger2_client_get_transport_class(): @@ -474,7 +496,9 @@ def test_debugger2_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -605,10 +629,17 @@ def test_debugger2_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [debugger.SetBreakpointRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + debugger.SetBreakpointRequest, + dict, + ], +) def test_set_breakpoint(request_type, transport: str = "grpc"): client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -634,7 +665,8 @@ def test_set_breakpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -650,7 +682,8 @@ async def test_set_breakpoint_async( transport: str = "grpc_asyncio", request_type=debugger.SetBreakpointRequest ): client = Debugger2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -679,8 +712,71 @@ async def test_set_breakpoint_async_from_dict(): await test_set_breakpoint_async(request_type=dict) +def test_set_breakpoint_field_headers(): + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = debugger.SetBreakpointRequest() + + request.debuggee_id = "debuggee_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.set_breakpoint), "__call__") as call: + call.return_value = debugger.SetBreakpointResponse() + client.set_breakpoint(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_set_breakpoint_field_headers_async(): + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = debugger.SetBreakpointRequest() + + request.debuggee_id = "debuggee_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.set_breakpoint), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + debugger.SetBreakpointResponse() + ) + await client.set_breakpoint(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value", + ) in kw["metadata"] + + def test_set_breakpoint_flattened(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_breakpoint), "__call__") as call: @@ -710,7 +806,9 @@ def test_set_breakpoint_flattened(): def test_set_breakpoint_flattened_error(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -725,7 +823,9 @@ def test_set_breakpoint_flattened_error(): @pytest.mark.asyncio async def test_set_breakpoint_flattened_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_breakpoint), "__call__") as call: @@ -760,7 +860,9 @@ async def test_set_breakpoint_flattened_async(): @pytest.mark.asyncio async def test_set_breakpoint_flattened_error_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -773,10 +875,17 @@ async def test_set_breakpoint_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [debugger.GetBreakpointRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + debugger.GetBreakpointRequest, + dict, + ], +) def test_get_breakpoint(request_type, transport: str = "grpc"): client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -802,7 +911,8 @@ def test_get_breakpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -818,7 +928,8 @@ async def test_get_breakpoint_async( transport: str = "grpc_asyncio", request_type=debugger.GetBreakpointRequest ): client = Debugger2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -847,8 +958,73 @@ async def test_get_breakpoint_async_from_dict(): await test_get_breakpoint_async(request_type=dict) +def test_get_breakpoint_field_headers(): + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = debugger.GetBreakpointRequest() + + request.debuggee_id = "debuggee_id_value" + request.breakpoint_id = "breakpoint_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_breakpoint), "__call__") as call: + call.return_value = debugger.GetBreakpointResponse() + client.get_breakpoint(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value&breakpoint_id=breakpoint_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_breakpoint_field_headers_async(): + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = debugger.GetBreakpointRequest() + + request.debuggee_id = "debuggee_id_value" + request.breakpoint_id = "breakpoint_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_breakpoint), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + debugger.GetBreakpointResponse() + ) + await client.get_breakpoint(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value&breakpoint_id=breakpoint_id_value", + ) in kw["metadata"] + + def test_get_breakpoint_flattened(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_breakpoint), "__call__") as call: @@ -878,7 +1054,9 @@ def test_get_breakpoint_flattened(): def test_get_breakpoint_flattened_error(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -893,7 +1071,9 @@ def test_get_breakpoint_flattened_error(): @pytest.mark.asyncio async def test_get_breakpoint_flattened_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_breakpoint), "__call__") as call: @@ -928,7 +1108,9 @@ async def test_get_breakpoint_flattened_async(): @pytest.mark.asyncio async def test_get_breakpoint_flattened_error_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -941,10 +1123,17 @@ async def test_get_breakpoint_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [debugger.DeleteBreakpointRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + debugger.DeleteBreakpointRequest, + dict, + ], +) def test_delete_breakpoint(request_type, transport: str = "grpc"): client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -972,7 +1161,8 @@ def test_delete_breakpoint_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -990,7 +1180,8 @@ async def test_delete_breakpoint_async( transport: str = "grpc_asyncio", request_type=debugger.DeleteBreakpointRequest ): client = Debugger2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1019,8 +1210,75 @@ async def test_delete_breakpoint_async_from_dict(): await test_delete_breakpoint_async(request_type=dict) +def test_delete_breakpoint_field_headers(): + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = debugger.DeleteBreakpointRequest() + + request.debuggee_id = "debuggee_id_value" + request.breakpoint_id = "breakpoint_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_breakpoint), "__call__" + ) as call: + call.return_value = None + client.delete_breakpoint(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value&breakpoint_id=breakpoint_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_breakpoint_field_headers_async(): + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = debugger.DeleteBreakpointRequest() + + request.debuggee_id = "debuggee_id_value" + request.breakpoint_id = "breakpoint_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_breakpoint), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + await client.delete_breakpoint(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value&breakpoint_id=breakpoint_id_value", + ) in kw["metadata"] + + def test_delete_breakpoint_flattened(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1052,7 +1310,9 @@ def test_delete_breakpoint_flattened(): def test_delete_breakpoint_flattened_error(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1067,7 +1327,9 @@ def test_delete_breakpoint_flattened_error(): @pytest.mark.asyncio async def test_delete_breakpoint_flattened_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1102,7 +1364,9 @@ async def test_delete_breakpoint_flattened_async(): @pytest.mark.asyncio async def test_delete_breakpoint_flattened_error_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1115,10 +1379,17 @@ async def test_delete_breakpoint_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [debugger.ListBreakpointsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + debugger.ListBreakpointsRequest, + dict, + ], +) def test_list_breakpoints(request_type, transport: str = "grpc"): client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1147,7 +1418,8 @@ def test_list_breakpoints_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1163,7 +1435,8 @@ async def test_list_breakpoints_async( transport: str = "grpc_asyncio", request_type=debugger.ListBreakpointsRequest ): client = Debugger2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1174,7 +1447,9 @@ async def test_list_breakpoints_async( with mock.patch.object(type(client.transport.list_breakpoints), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - debugger.ListBreakpointsResponse(next_wait_token="next_wait_token_value",) + debugger.ListBreakpointsResponse( + next_wait_token="next_wait_token_value", + ) ) response = await client.list_breakpoints(request) @@ -1193,8 +1468,71 @@ async def test_list_breakpoints_async_from_dict(): await test_list_breakpoints_async(request_type=dict) +def test_list_breakpoints_field_headers(): + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = debugger.ListBreakpointsRequest() + + request.debuggee_id = "debuggee_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_breakpoints), "__call__") as call: + call.return_value = debugger.ListBreakpointsResponse() + client.list_breakpoints(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) == 1 + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_breakpoints_field_headers_async(): + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = debugger.ListBreakpointsRequest() + + request.debuggee_id = "debuggee_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_breakpoints), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + debugger.ListBreakpointsResponse() + ) + await client.list_breakpoints(request) + + # Establish that the underlying gRPC stub method was called. + assert len(call.mock_calls) + _, args, _ = call.mock_calls[0] + assert args[0] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "debuggee_id=debuggee_id_value", + ) in kw["metadata"] + + def test_list_breakpoints_flattened(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_breakpoints), "__call__") as call: @@ -1203,7 +1541,8 @@ def test_list_breakpoints_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_breakpoints( - debuggee_id="debuggee_id_value", client_version="client_version_value", + debuggee_id="debuggee_id_value", + client_version="client_version_value", ) # Establish that the underlying call was made with the expected @@ -1219,7 +1558,9 @@ def test_list_breakpoints_flattened(): def test_list_breakpoints_flattened_error(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1233,7 +1574,9 @@ def test_list_breakpoints_flattened_error(): @pytest.mark.asyncio async def test_list_breakpoints_flattened_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_breakpoints), "__call__") as call: @@ -1246,7 +1589,8 @@ async def test_list_breakpoints_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.list_breakpoints( - debuggee_id="debuggee_id_value", client_version="client_version_value", + debuggee_id="debuggee_id_value", + client_version="client_version_value", ) # Establish that the underlying call was made with the expected @@ -1263,7 +1607,9 @@ async def test_list_breakpoints_flattened_async(): @pytest.mark.asyncio async def test_list_breakpoints_flattened_error_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1275,10 +1621,17 @@ async def test_list_breakpoints_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [debugger.ListDebuggeesRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + debugger.ListDebuggeesRequest, + dict, + ], +) def test_list_debuggees(request_type, transport: str = "grpc"): client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1304,7 +1657,8 @@ def test_list_debuggees_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1320,7 +1674,8 @@ async def test_list_debuggees_async( transport: str = "grpc_asyncio", request_type=debugger.ListDebuggeesRequest ): client = Debugger2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1350,7 +1705,9 @@ async def test_list_debuggees_async_from_dict(): def test_list_debuggees_flattened(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_debuggees), "__call__") as call: @@ -1359,7 +1716,8 @@ def test_list_debuggees_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_debuggees( - project="project_value", client_version="client_version_value", + project="project_value", + client_version="client_version_value", ) # Establish that the underlying call was made with the expected @@ -1375,7 +1733,9 @@ def test_list_debuggees_flattened(): def test_list_debuggees_flattened_error(): - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1389,7 +1749,9 @@ def test_list_debuggees_flattened_error(): @pytest.mark.asyncio async def test_list_debuggees_flattened_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_debuggees), "__call__") as call: @@ -1402,7 +1764,8 @@ async def test_list_debuggees_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.list_debuggees( - project="project_value", client_version="client_version_value", + project="project_value", + client_version="client_version_value", ) # Establish that the underlying call was made with the expected @@ -1419,7 +1782,9 @@ async def test_list_debuggees_flattened_async(): @pytest.mark.asyncio async def test_list_debuggees_flattened_error_async(): - client = Debugger2AsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = Debugger2AsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1438,7 +1803,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1458,7 +1824,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = Debugger2Client(client_options=options, transport=transport,) + client = Debugger2Client( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1474,7 +1843,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = Debugger2Client( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1504,7 +1874,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.Debugger2GrpcTransport, transports.Debugger2GrpcAsyncIOTransport,], + [ + transports.Debugger2GrpcTransport, + transports.Debugger2GrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -1514,10 +1887,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = Debugger2Client.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = Debugger2Client(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.Debugger2GrpcTransport,) + client = Debugger2Client( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.Debugger2GrpcTransport, + ) def test_debugger2_base_transport_error(): @@ -1555,6 +1946,14 @@ def test_debugger2_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_debugger2_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -1566,7 +1965,8 @@ def test_debugger2_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.Debugger2Transport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1607,7 +2007,10 @@ def test_debugger2_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.Debugger2GrpcTransport, transports.Debugger2GrpcAsyncIOTransport,], + [ + transports.Debugger2GrpcTransport, + transports.Debugger2GrpcAsyncIOTransport, + ], ) def test_debugger2_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -1705,24 +2108,40 @@ def test_debugger2_grpc_transport_client_cert_source_for_mtls(transport_class): ) -def test_debugger2_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_debugger2_host_no_port(transport_name): client = Debugger2Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="clouddebugger.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "clouddebugger.googleapis.com:443" + assert client.transport._host == ("clouddebugger.googleapis.com:443") -def test_debugger2_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_debugger2_host_with_port(transport_name): client = Debugger2Client( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="clouddebugger.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "clouddebugger.googleapis.com:8000" + assert client.transport._host == ("clouddebugger.googleapis.com:8000") def test_debugger2_grpc_transport_channel(): @@ -1730,7 +2149,8 @@ def test_debugger2_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.Debugger2GrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1742,7 +2162,8 @@ def test_debugger2_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.Debugger2GrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1863,7 +2284,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = Debugger2Client.common_folder_path(folder) assert expected == actual @@ -1881,7 +2304,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = Debugger2Client.common_organization_path(organization) assert expected == actual @@ -1899,7 +2324,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = Debugger2Client.common_project_path(project) assert expected == actual @@ -1919,7 +2346,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = Debugger2Client.common_location_path(project, location) assert expected == actual @@ -1944,7 +2372,8 @@ def test_client_with_default_client_info(): transports.Debugger2Transport, "_prep_wrapped_messages" ) as prep: client = Debugger2Client( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1953,7 +2382,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = Debugger2Client.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1961,7 +2391,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = Debugger2AsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close"
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: