From b5c022bebd36f82bb538d4d8467f25685f84f8bc Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Thu, 3 Dec 2020 09:04:03 -0800 Subject: [PATCH] feat: add common resource helper methods; expose client transport; add shebang to fixup scripts (#57) This PR was generated using Autosynth. :rainbow: Synth log will be available here: https://source.cloud.google.com/results/invocations/6c49b023-73d4-4d21-9e9f-028a9067e602/targets - [ ] To automatically regenerate this PR, check this box. --- .github/sync-repo-settings.yaml | 14 + CHANGELOG.md | 2 +- docs/secretmanager_v1/types.rst | 1 + docs/secretmanager_v1beta1/types.rst | 1 + .../secret_manager_service/async_client.py | 80 ++- .../services/secret_manager_service/client.py | 110 +++- .../secret_manager_service/transports/base.py | 2 +- .../secret_manager_service/transports/grpc.py | 18 +- .../transports/grpc_asyncio.py | 4 + .../secret_manager_service/async_client.py | 80 ++- .../services/secret_manager_service/client.py | 110 +++- .../secret_manager_service/transports/base.py | 2 +- .../secret_manager_service/transports/grpc.py | 18 +- .../transports/grpc_asyncio.py | 4 + noxfile.py | 2 +- scripts/fixup_secretmanager_v1_keywords.py | 1 + .../fixup_secretmanager_v1beta1_keywords.py | 1 + synth.metadata | 119 +++- .../test_secret_manager_service.py | 592 ++++++++++++------ .../test_secret_manager_service.py | 592 ++++++++++++------ 20 files changed, 1294 insertions(+), 459 deletions(-) create mode 100644 .github/sync-repo-settings.yaml diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml new file mode 100644 index 0000000..51957e6 --- /dev/null +++ b/.github/sync-repo-settings.yaml @@ -0,0 +1,14 @@ + +# https://github.com/googleapis/repo-automation-bots/tree/master/packages/sync-repo-settings +# Rules for master branch protection +branchProtectionRules: +# Identifies the protection rule pattern. Name of the branch to be protected. +# Defaults to `master` +- pattern: master + requiredStatusCheckContexts: + - 'Kokoro' + - 'cla/google' + - 'Samples - Lint' + - 'Samples - Python 3.6' + - 'Samples - Python 3.7' + - 'Samples - Python 3.8' \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d315d1..d32f617 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ ### ⚠ BREAKING CHANGES -* migrate to use microgen (#44) +* migrate to use microgen. See [Migration Guide](https://googleapis.dev/python/secretmanager/latest/UPGRADING.html) (#44) ### Features diff --git a/docs/secretmanager_v1/types.rst b/docs/secretmanager_v1/types.rst index cda1657..580720f 100644 --- a/docs/secretmanager_v1/types.rst +++ b/docs/secretmanager_v1/types.rst @@ -3,3 +3,4 @@ Types for Google Cloud Secretmanager v1 API .. automodule:: google.cloud.secretmanager_v1.types :members: + :show-inheritance: diff --git a/docs/secretmanager_v1beta1/types.rst b/docs/secretmanager_v1beta1/types.rst index a1dcc16..af33251 100644 --- a/docs/secretmanager_v1beta1/types.rst +++ b/docs/secretmanager_v1beta1/types.rst @@ -3,3 +3,4 @@ Types for Google Cloud Secretmanager v1beta1 API .. automodule:: google.cloud.secretmanager_v1beta1.types :members: + :show-inheritance: diff --git a/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py b/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py index 4cfce52..52da1ec 100644 --- a/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py +++ b/google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py @@ -58,10 +58,52 @@ class SecretManagerServiceAsyncClient: secret_path = staticmethod(SecretManagerServiceClient.secret_path) parse_secret_path = staticmethod(SecretManagerServiceClient.parse_secret_path) + secret_version_path = staticmethod(SecretManagerServiceClient.secret_version_path) + parse_secret_version_path = staticmethod( + SecretManagerServiceClient.parse_secret_version_path + ) + + common_billing_account_path = staticmethod( + SecretManagerServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + SecretManagerServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(SecretManagerServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + SecretManagerServiceClient.parse_common_folder_path + ) + + common_organization_path = staticmethod( + SecretManagerServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + SecretManagerServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(SecretManagerServiceClient.common_project_path) + parse_common_project_path = staticmethod( + SecretManagerServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(SecretManagerServiceClient.common_location_path) + parse_common_location_path = staticmethod( + SecretManagerServiceClient.parse_common_location_path + ) from_service_account_file = SecretManagerServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> SecretManagerServiceTransport: + """Return the transport used by the client instance. + + Returns: + SecretManagerServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(SecretManagerServiceClient).get_transport_class, type(SecretManagerServiceClient), @@ -157,7 +199,8 @@ async def list_secrets( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -261,7 +304,8 @@ async def create_secret( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, secret_id, secret]): + has_flattened_params = any([parent, secret_id, secret]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -349,7 +393,8 @@ async def add_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, payload]): + has_flattened_params = any([parent, payload]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -429,7 +474,8 @@ async def get_secret( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -513,7 +559,8 @@ async def update_secret( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([secret, update_mask]): + has_flattened_params = any([secret, update_mask]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -583,7 +630,8 @@ async def delete_secret( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -661,7 +709,8 @@ async def list_secret_versions( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -747,7 +796,8 @@ async def get_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -825,7 +875,8 @@ async def access_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -848,7 +899,7 @@ async def access_secret_version( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.Unknown, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.Unknown, ), ), default_timeout=60.0, @@ -913,7 +964,8 @@ async def disable_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -993,7 +1045,8 @@ async def enable_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1074,7 +1127,8 @@ async def destroy_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." diff --git a/google/cloud/secretmanager_v1/services/secret_manager_service/client.py b/google/cloud/secretmanager_v1/services/secret_manager_service/client.py index 22fcf07..283ca0f 100644 --- a/google/cloud/secretmanager_v1/services/secret_manager_service/client.py +++ b/google/cloud/secretmanager_v1/services/secret_manager_service/client.py @@ -19,10 +19,10 @@ from distutils import util import os import re -from typing import Callable, Dict, Sequence, Tuple, Type, Union +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import client_options as client_options_lib # type: ignore from google.api_core import exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore @@ -144,6 +144,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> SecretManagerServiceTransport: + """Return the transport used by the client instance. + + Returns: + SecretManagerServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def secret_path(project: str, secret: str,) -> str: """Return a fully-qualified secret string.""" @@ -157,12 +166,87 @@ def parse_secret_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/secrets/(?P.+?)$", path) return m.groupdict() if m else {} + @staticmethod + def secret_version_path(project: str, secret: str, secret_version: str,) -> str: + """Return a fully-qualified secret_version string.""" + return "projects/{project}/secrets/{secret}/versions/{secret_version}".format( + project=project, secret=secret, secret_version=secret_version, + ) + + @staticmethod + def parse_secret_version_path(path: str) -> Dict[str, str]: + """Parse a secret_version path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/secrets/(?P.+?)/versions/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def common_billing_account_path(billing_account: str,) -> str: + """Return a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str, str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str,) -> str: + """Return a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder,) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str, str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str,) -> str: + """Return a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization,) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str, str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str,) -> str: + """Return a fully-qualified project string.""" + return "projects/{project}".format(project=project,) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str, str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str,) -> str: + """Return a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str, str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + def __init__( self, *, - credentials: credentials.Credentials = None, - transport: Union[str, SecretManagerServiceTransport] = None, - client_options: ClientOptions = None, + credentials: Optional[credentials.Credentials] = None, + transport: Union[str, SecretManagerServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiate the secret manager service client. @@ -176,8 +260,8 @@ def __init__( transport (Union[str, ~.SecretManagerServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. + client_options (client_options_lib.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT environment variable can also be used to override the endpoint: @@ -192,10 +276,10 @@ def __init__( not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. Raises: @@ -203,9 +287,9 @@ def __init__( creation failed for any reason. """ if isinstance(client_options, dict): - client_options = ClientOptions.from_dict(client_options) + client_options = client_options_lib.from_dict(client_options) if client_options is None: - client_options = ClientOptions.ClientOptions() + client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. use_client_cert = bool( diff --git a/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py b/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py index e065202..6be43f3 100644 --- a/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py +++ b/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py @@ -143,7 +143,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.Unknown, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.Unknown, ), ), default_timeout=60.0, diff --git a/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py b/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py index a92701e..979cf79 100644 --- a/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py +++ b/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py @@ -99,10 +99,10 @@ def __init__( for grpc channel. It is ignored if ``channel`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. Raises: @@ -111,6 +111,8 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._ssl_channel_credentials = ssl_channel_credentials + if channel: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -118,6 +120,7 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel + self._ssl_channel_credentials = None elif api_mtls_endpoint: warnings.warn( "api_mtls_endpoint and client_cert_source are deprecated", @@ -154,6 +157,7 @@ def __init__( scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -231,12 +235,8 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. + """Return the channel designed to connect to this service. """ - # Return the channel from cache. return self._grpc_channel @property diff --git a/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py b/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py index 069345d..1eb2146 100644 --- a/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py +++ b/google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py @@ -156,6 +156,8 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._ssl_channel_credentials = ssl_channel_credentials + if channel: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -163,6 +165,7 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel + self._ssl_channel_credentials = None elif api_mtls_endpoint: warnings.warn( "api_mtls_endpoint and client_cert_source are deprecated", @@ -199,6 +202,7 @@ def __init__( scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py index fb2567e..db3abf9 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py @@ -58,10 +58,52 @@ class SecretManagerServiceAsyncClient: secret_path = staticmethod(SecretManagerServiceClient.secret_path) parse_secret_path = staticmethod(SecretManagerServiceClient.parse_secret_path) + secret_version_path = staticmethod(SecretManagerServiceClient.secret_version_path) + parse_secret_version_path = staticmethod( + SecretManagerServiceClient.parse_secret_version_path + ) + + common_billing_account_path = staticmethod( + SecretManagerServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + SecretManagerServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(SecretManagerServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + SecretManagerServiceClient.parse_common_folder_path + ) + + common_organization_path = staticmethod( + SecretManagerServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + SecretManagerServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(SecretManagerServiceClient.common_project_path) + parse_common_project_path = staticmethod( + SecretManagerServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(SecretManagerServiceClient.common_location_path) + parse_common_location_path = staticmethod( + SecretManagerServiceClient.parse_common_location_path + ) from_service_account_file = SecretManagerServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> SecretManagerServiceTransport: + """Return the transport used by the client instance. + + Returns: + SecretManagerServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(SecretManagerServiceClient).get_transport_class, type(SecretManagerServiceClient), @@ -156,7 +198,8 @@ async def list_secrets( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -260,7 +303,8 @@ async def create_secret( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, secret_id, secret]): + has_flattened_params = any([parent, secret_id, secret]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -348,7 +392,8 @@ async def add_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, payload]): + has_flattened_params = any([parent, payload]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -428,7 +473,8 @@ async def get_secret( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -512,7 +558,8 @@ async def update_secret( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([secret, update_mask]): + has_flattened_params = any([secret, update_mask]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -582,7 +629,8 @@ async def delete_secret( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -660,7 +708,8 @@ async def list_secret_versions( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -746,7 +795,8 @@ async def get_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -824,7 +874,8 @@ async def access_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -847,7 +898,7 @@ async def access_secret_version( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.Unknown, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.Unknown, ), ), default_timeout=60.0, @@ -911,7 +962,8 @@ async def disable_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -990,7 +1042,8 @@ async def enable_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1070,7 +1123,8 @@ async def destroy_secret_version( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py index 0cf0016..0c59d0d 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py @@ -19,10 +19,10 @@ from distutils import util import os import re -from typing import Callable, Dict, Sequence, Tuple, Type, Union +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import client_options as client_options_lib # type: ignore from google.api_core import exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore @@ -144,6 +144,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> SecretManagerServiceTransport: + """Return the transport used by the client instance. + + Returns: + SecretManagerServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def secret_path(project: str, secret: str,) -> str: """Return a fully-qualified secret string.""" @@ -157,12 +166,87 @@ def parse_secret_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/secrets/(?P.+?)$", path) return m.groupdict() if m else {} + @staticmethod + def secret_version_path(project: str, secret: str, secret_version: str,) -> str: + """Return a fully-qualified secret_version string.""" + return "projects/{project}/secrets/{secret}/versions/{secret_version}".format( + project=project, secret=secret, secret_version=secret_version, + ) + + @staticmethod + def parse_secret_version_path(path: str) -> Dict[str, str]: + """Parse a secret_version path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/secrets/(?P.+?)/versions/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def common_billing_account_path(billing_account: str,) -> str: + """Return a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str, str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str,) -> str: + """Return a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder,) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str, str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str,) -> str: + """Return a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization,) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str, str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str,) -> str: + """Return a fully-qualified project string.""" + return "projects/{project}".format(project=project,) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str, str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str,) -> str: + """Return a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str, str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + def __init__( self, *, - credentials: credentials.Credentials = None, - transport: Union[str, SecretManagerServiceTransport] = None, - client_options: ClientOptions = None, + credentials: Optional[credentials.Credentials] = None, + transport: Union[str, SecretManagerServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiate the secret manager service client. @@ -176,8 +260,8 @@ def __init__( transport (Union[str, ~.SecretManagerServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. + client_options (client_options_lib.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT environment variable can also be used to override the endpoint: @@ -192,10 +276,10 @@ def __init__( not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. Raises: @@ -203,9 +287,9 @@ def __init__( creation failed for any reason. """ if isinstance(client_options, dict): - client_options = ClientOptions.from_dict(client_options) + client_options = client_options_lib.from_dict(client_options) if client_options is None: - client_options = ClientOptions.ClientOptions() + client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. use_client_cert = bool( diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/base.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/base.py index c8544df..3666843 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/base.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/base.py @@ -143,7 +143,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.Unknown, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.Unknown, ), ), default_timeout=60.0, diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py index b022fe4..bbcd5ca 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py @@ -99,10 +99,10 @@ def __init__( for grpc channel. It is ignored if ``channel`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. Raises: @@ -111,6 +111,8 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._ssl_channel_credentials = ssl_channel_credentials + if channel: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -118,6 +120,7 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel + self._ssl_channel_credentials = None elif api_mtls_endpoint: warnings.warn( "api_mtls_endpoint and client_cert_source are deprecated", @@ -154,6 +157,7 @@ def __init__( scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -231,12 +235,8 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. + """Return the channel designed to connect to this service. """ - # Return the channel from cache. return self._grpc_channel @property diff --git a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py index 4ce9f59..e25484f 100644 --- a/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py +++ b/google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py @@ -156,6 +156,8 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._ssl_channel_credentials = ssl_channel_credentials + if channel: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -163,6 +165,7 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel + self._ssl_channel_credentials = None elif api_mtls_endpoint: warnings.warn( "api_mtls_endpoint and client_cert_source are deprecated", @@ -199,6 +202,7 @@ def __init__( scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" diff --git a/noxfile.py b/noxfile.py index e906161..8b29ec3 100644 --- a/noxfile.py +++ b/noxfile.py @@ -28,7 +28,7 @@ DEFAULT_PYTHON_VERSION = "3.8" SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] -UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8"] +UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9"] @nox.session(python=DEFAULT_PYTHON_VERSION) diff --git a/scripts/fixup_secretmanager_v1_keywords.py b/scripts/fixup_secretmanager_v1_keywords.py index afad384..2b141b2 100644 --- a/scripts/fixup_secretmanager_v1_keywords.py +++ b/scripts/fixup_secretmanager_v1_keywords.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2020 Google LLC diff --git a/scripts/fixup_secretmanager_v1beta1_keywords.py b/scripts/fixup_secretmanager_v1beta1_keywords.py index afad384..2b141b2 100644 --- a/scripts/fixup_secretmanager_v1beta1_keywords.py +++ b/scripts/fixup_secretmanager_v1beta1_keywords.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2020 Google LLC diff --git a/synth.metadata b/synth.metadata index 55eecb8..1b5c7a0 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,15 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-secret-manager.git", - "sha": "538071bbe633d02303572a56cf5894abff141201" + "sha": "8d02b18a31fa4b878cf9608aed8814d437d753dc" + } + }, + { + "git": { + "name": "googleapis", + "remote": "https://github.com/googleapis/googleapis.git", + "sha": "dabe30b45bc86fdaf4126f26cbcfd73babbfa3fe", + "internalRef": "345194337" } }, { @@ -41,5 +49,114 @@ "generator": "bazel" } } + ], + "generatedFiles": [ + ".flake8", + ".github/CONTRIBUTING.md", + ".github/ISSUE_TEMPLATE/bug_report.md", + ".github/ISSUE_TEMPLATE/feature_request.md", + ".github/ISSUE_TEMPLATE/support_request.md", + ".github/PULL_REQUEST_TEMPLATE.md", + ".github/release-please.yml", + ".github/snippet-bot.yml", + ".gitignore", + ".kokoro/build.sh", + ".kokoro/continuous/common.cfg", + ".kokoro/continuous/continuous.cfg", + ".kokoro/docker/docs/Dockerfile", + ".kokoro/docker/docs/fetch_gpg_keys.sh", + ".kokoro/docs/common.cfg", + ".kokoro/docs/docs-presubmit.cfg", + ".kokoro/docs/docs.cfg", + ".kokoro/presubmit/common.cfg", + ".kokoro/presubmit/presubmit.cfg", + ".kokoro/publish-docs.sh", + ".kokoro/release.sh", + ".kokoro/release/common.cfg", + ".kokoro/release/release.cfg", + ".kokoro/samples/lint/common.cfg", + ".kokoro/samples/lint/continuous.cfg", + ".kokoro/samples/lint/periodic.cfg", + ".kokoro/samples/lint/presubmit.cfg", + ".kokoro/samples/python3.6/common.cfg", + ".kokoro/samples/python3.6/continuous.cfg", + ".kokoro/samples/python3.6/periodic.cfg", + ".kokoro/samples/python3.6/presubmit.cfg", + ".kokoro/samples/python3.7/common.cfg", + ".kokoro/samples/python3.7/continuous.cfg", + ".kokoro/samples/python3.7/periodic.cfg", + ".kokoro/samples/python3.7/presubmit.cfg", + ".kokoro/samples/python3.8/common.cfg", + ".kokoro/samples/python3.8/continuous.cfg", + ".kokoro/samples/python3.8/periodic.cfg", + ".kokoro/samples/python3.8/presubmit.cfg", + ".kokoro/test-samples.sh", + ".kokoro/trampoline.sh", + ".kokoro/trampoline_v2.sh", + ".trampolinerc", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.rst", + "LICENSE", + "MANIFEST.in", + "docs/_static/custom.css", + "docs/_templates/layout.html", + "docs/conf.py", + "docs/multiprocessing.rst", + "docs/secretmanager_v1/services.rst", + "docs/secretmanager_v1/types.rst", + "docs/secretmanager_v1beta1/services.rst", + "docs/secretmanager_v1beta1/types.rst", + "google/cloud/secretmanager/__init__.py", + "google/cloud/secretmanager/py.typed", + "google/cloud/secretmanager_v1/__init__.py", + "google/cloud/secretmanager_v1/py.typed", + "google/cloud/secretmanager_v1/services/__init__.py", + "google/cloud/secretmanager_v1/services/secret_manager_service/__init__.py", + "google/cloud/secretmanager_v1/services/secret_manager_service/async_client.py", + "google/cloud/secretmanager_v1/services/secret_manager_service/client.py", + "google/cloud/secretmanager_v1/services/secret_manager_service/pagers.py", + "google/cloud/secretmanager_v1/services/secret_manager_service/transports/__init__.py", + "google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py", + "google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc.py", + "google/cloud/secretmanager_v1/services/secret_manager_service/transports/grpc_asyncio.py", + "google/cloud/secretmanager_v1/types/__init__.py", + "google/cloud/secretmanager_v1/types/resources.py", + "google/cloud/secretmanager_v1/types/service.py", + "google/cloud/secretmanager_v1beta1/__init__.py", + "google/cloud/secretmanager_v1beta1/py.typed", + "google/cloud/secretmanager_v1beta1/services/__init__.py", + "google/cloud/secretmanager_v1beta1/services/secret_manager_service/__init__.py", + "google/cloud/secretmanager_v1beta1/services/secret_manager_service/async_client.py", + "google/cloud/secretmanager_v1beta1/services/secret_manager_service/client.py", + "google/cloud/secretmanager_v1beta1/services/secret_manager_service/pagers.py", + "google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/__init__.py", + "google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/base.py", + "google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc.py", + "google/cloud/secretmanager_v1beta1/services/secret_manager_service/transports/grpc_asyncio.py", + "google/cloud/secretmanager_v1beta1/types/__init__.py", + "google/cloud/secretmanager_v1beta1/types/resources.py", + "google/cloud/secretmanager_v1beta1/types/service.py", + "mypy.ini", + "noxfile.py", + "renovate.json", + "samples/AUTHORING_GUIDE.md", + "samples/CONTRIBUTING.md", + "samples/snippets/README.rst", + "samples/snippets/noxfile.py", + "scripts/decrypt-secrets.sh", + "scripts/fixup_secretmanager_v1_keywords.py", + "scripts/fixup_secretmanager_v1beta1_keywords.py", + "scripts/readme-gen/readme_gen.py", + "scripts/readme-gen/templates/README.tmpl.rst", + "scripts/readme-gen/templates/auth.tmpl.rst", + "scripts/readme-gen/templates/auth_api_key.tmpl.rst", + "scripts/readme-gen/templates/install_deps.tmpl.rst", + "scripts/readme-gen/templates/install_portaudio.tmpl.rst", + "setup.cfg", + "testing/.gitignore", + "tests/unit/gapic/secretmanager_v1/__init__.py", + "tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py", + "tests/unit/gapic/secretmanager_v1beta1/__init__.py", + "tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py" ] } \ No newline at end of file diff --git a/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py b/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py index 653a7e0..2713693 100644 --- a/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py +++ b/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py @@ -106,12 +106,12 @@ def test_secret_manager_service_client_from_service_account_file(client_class): ) as factory: factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") - assert client._transport._credentials == creds + assert client.transport._credentials == creds client = client_class.from_service_account_json("dummy/file/path.json") - assert client._transport._credentials == creds + assert client.transport._credentials == creds - assert client._transport._host == "secretmanager.googleapis.com:443" + assert client.transport._host == "secretmanager.googleapis.com:443" def test_secret_manager_service_client_get_transport_class(): @@ -481,7 +481,7 @@ def test_list_secrets(transport: str = "grpc", request_type=service.ListSecretsR request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretsResponse( next_page_token="next_page_token_value", total_size=1086, @@ -496,6 +496,7 @@ def test_list_secrets(transport: str = "grpc", request_type=service.ListSecretsR assert args[0] == service.ListSecretsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSecretsPager) assert response.next_page_token == "next_page_token_value" @@ -508,19 +509,19 @@ def test_list_secrets_from_dict(): @pytest.mark.asyncio -async def test_list_secrets_async(transport: str = "grpc_asyncio"): +async def test_list_secrets_async( + transport: str = "grpc_asyncio", request_type=service.ListSecretsRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.ListSecretsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_secrets), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListSecretsResponse( @@ -534,7 +535,7 @@ async def test_list_secrets_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.ListSecretsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListSecretsAsyncPager) @@ -544,6 +545,11 @@ async def test_list_secrets_async(transport: str = "grpc_asyncio"): assert response.total_size == 1086 +@pytest.mark.asyncio +async def test_list_secrets_async_from_dict(): + await test_list_secrets_async(request_type=dict) + + def test_list_secrets_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -553,7 +559,7 @@ def test_list_secrets_field_headers(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: call.return_value = service.ListSecretsResponse() client.list_secrets(request) @@ -580,9 +586,7 @@ async def test_list_secrets_field_headers_async(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_secrets), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListSecretsResponse() ) @@ -603,7 +607,7 @@ def test_list_secrets_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretsResponse() @@ -637,9 +641,7 @@ async def test_list_secrets_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_secrets), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretsResponse() @@ -676,7 +678,7 @@ def test_list_secrets_pager(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListSecretsResponse( @@ -710,7 +712,7 @@ def test_list_secrets_pages(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListSecretsResponse( @@ -739,9 +741,7 @@ async def test_list_secrets_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secrets), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_secrets), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -776,9 +776,7 @@ async def test_list_secrets_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secrets), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_secrets), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -814,7 +812,7 @@ def test_create_secret( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_secret), "__call__") as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret(name="name_value",) @@ -827,6 +825,7 @@ def test_create_secret( assert args[0] == service.CreateSecretRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.Secret) assert response.name == "name_value" @@ -837,19 +836,19 @@ def test_create_secret_from_dict(): @pytest.mark.asyncio -async def test_create_secret_async(transport: str = "grpc_asyncio"): +async def test_create_secret_async( + transport: str = "grpc_asyncio", request_type=service.CreateSecretRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.CreateSecretRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Secret(name="name_value",) @@ -861,7 +860,7 @@ async def test_create_secret_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.CreateSecretRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Secret) @@ -869,6 +868,11 @@ async def test_create_secret_async(transport: str = "grpc_asyncio"): assert response.name == "name_value" +@pytest.mark.asyncio +async def test_create_secret_async_from_dict(): + await test_create_secret_async(request_type=dict) + + def test_create_secret_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -878,7 +882,7 @@ def test_create_secret_field_headers(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_secret), "__call__") as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: call.return_value = resources.Secret() client.create_secret(request) @@ -905,9 +909,7 @@ async def test_create_secret_field_headers_async(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Secret()) await client.create_secret(request) @@ -926,7 +928,7 @@ def test_create_secret_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_secret), "__call__") as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -971,9 +973,7 @@ async def test_create_secret_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1028,7 +1028,7 @@ def test_add_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -1044,6 +1044,7 @@ def test_add_secret_version( assert args[0] == service.AddSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -1056,18 +1057,20 @@ def test_add_secret_version_from_dict(): @pytest.mark.asyncio -async def test_add_secret_version_async(transport: str = "grpc_asyncio"): +async def test_add_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.AddSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.AddSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1082,7 +1085,7 @@ async def test_add_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.AddSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -1092,6 +1095,11 @@ async def test_add_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_add_secret_version_async_from_dict(): + await test_add_secret_version_async(request_type=dict) + + def test_add_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1102,7 +1110,7 @@ def test_add_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -1131,7 +1139,7 @@ async def test_add_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -1154,7 +1162,7 @@ def test_add_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -1196,7 +1204,7 @@ async def test_add_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -1246,7 +1254,7 @@ def test_get_secret(transport: str = "grpc", request_type=service.GetSecretReque request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_secret), "__call__") as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret(name="name_value",) @@ -1259,6 +1267,7 @@ def test_get_secret(transport: str = "grpc", request_type=service.GetSecretReque assert args[0] == service.GetSecretRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.Secret) assert response.name == "name_value" @@ -1269,19 +1278,19 @@ def test_get_secret_from_dict(): @pytest.mark.asyncio -async def test_get_secret_async(transport: str = "grpc_asyncio"): +async def test_get_secret_async( + transport: str = "grpc_asyncio", request_type=service.GetSecretRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.GetSecretRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Secret(name="name_value",) @@ -1293,7 +1302,7 @@ async def test_get_secret_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.GetSecretRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Secret) @@ -1301,6 +1310,11 @@ async def test_get_secret_async(transport: str = "grpc_asyncio"): assert response.name == "name_value" +@pytest.mark.asyncio +async def test_get_secret_async_from_dict(): + await test_get_secret_async(request_type=dict) + + def test_get_secret_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1310,7 +1324,7 @@ def test_get_secret_field_headers(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_secret), "__call__") as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: call.return_value = resources.Secret() client.get_secret(request) @@ -1337,9 +1351,7 @@ async def test_get_secret_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Secret()) await client.get_secret(request) @@ -1358,7 +1370,7 @@ def test_get_secret_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_secret), "__call__") as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1392,9 +1404,7 @@ async def test_get_secret_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1437,7 +1447,7 @@ def test_update_secret( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_secret), "__call__") as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret(name="name_value",) @@ -1450,6 +1460,7 @@ def test_update_secret( assert args[0] == service.UpdateSecretRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.Secret) assert response.name == "name_value" @@ -1460,19 +1471,19 @@ def test_update_secret_from_dict(): @pytest.mark.asyncio -async def test_update_secret_async(transport: str = "grpc_asyncio"): +async def test_update_secret_async( + transport: str = "grpc_asyncio", request_type=service.UpdateSecretRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.UpdateSecretRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Secret(name="name_value",) @@ -1484,7 +1495,7 @@ async def test_update_secret_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.UpdateSecretRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Secret) @@ -1492,6 +1503,11 @@ async def test_update_secret_async(transport: str = "grpc_asyncio"): assert response.name == "name_value" +@pytest.mark.asyncio +async def test_update_secret_async_from_dict(): + await test_update_secret_async(request_type=dict) + + def test_update_secret_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1501,7 +1517,7 @@ def test_update_secret_field_headers(): request.secret.name = "secret.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_secret), "__call__") as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: call.return_value = resources.Secret() client.update_secret(request) @@ -1528,9 +1544,7 @@ async def test_update_secret_field_headers_async(): request.secret.name = "secret.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Secret()) await client.update_secret(request) @@ -1549,7 +1563,7 @@ def test_update_secret_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_secret), "__call__") as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1590,9 +1604,7 @@ async def test_update_secret_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1642,7 +1654,7 @@ def test_delete_secret( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_secret), "__call__") as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1663,19 +1675,19 @@ def test_delete_secret_from_dict(): @pytest.mark.asyncio -async def test_delete_secret_async(transport: str = "grpc_asyncio"): +async def test_delete_secret_async( + transport: str = "grpc_asyncio", request_type=service.DeleteSecretRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.DeleteSecretRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1685,12 +1697,17 @@ async def test_delete_secret_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.DeleteSecretRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_secret_async_from_dict(): + await test_delete_secret_async(request_type=dict) + + def test_delete_secret_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1700,7 +1717,7 @@ def test_delete_secret_field_headers(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_secret), "__call__") as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: call.return_value = None client.delete_secret(request) @@ -1727,9 +1744,7 @@ async def test_delete_secret_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_secret(request) @@ -1748,7 +1763,7 @@ def test_delete_secret_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_secret), "__call__") as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1782,9 +1797,7 @@ async def test_delete_secret_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1828,7 +1841,7 @@ def test_list_secret_versions( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretVersionsResponse( @@ -1844,6 +1857,7 @@ def test_list_secret_versions( assert args[0] == service.ListSecretVersionsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSecretVersionsPager) assert response.next_page_token == "next_page_token_value" @@ -1856,18 +1870,20 @@ def test_list_secret_versions_from_dict(): @pytest.mark.asyncio -async def test_list_secret_versions_async(transport: str = "grpc_asyncio"): +async def test_list_secret_versions_async( + transport: str = "grpc_asyncio", request_type=service.ListSecretVersionsRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.ListSecretVersionsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1882,7 +1898,7 @@ async def test_list_secret_versions_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.ListSecretVersionsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListSecretVersionsAsyncPager) @@ -1892,6 +1908,11 @@ async def test_list_secret_versions_async(transport: str = "grpc_asyncio"): assert response.total_size == 1086 +@pytest.mark.asyncio +async def test_list_secret_versions_async_from_dict(): + await test_list_secret_versions_async(request_type=dict) + + def test_list_secret_versions_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1902,7 +1923,7 @@ def test_list_secret_versions_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: call.return_value = service.ListSecretVersionsResponse() @@ -1931,7 +1952,7 @@ async def test_list_secret_versions_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListSecretVersionsResponse() @@ -1954,7 +1975,7 @@ def test_list_secret_versions_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretVersionsResponse() @@ -1990,7 +2011,7 @@ async def test_list_secret_versions_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretVersionsResponse() @@ -2029,7 +2050,7 @@ def test_list_secret_versions_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2069,7 +2090,7 @@ def test_list_secret_versions_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2103,7 +2124,7 @@ async def test_list_secret_versions_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), + type(client.transport.list_secret_versions), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -2144,7 +2165,7 @@ async def test_list_secret_versions_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), + type(client.transport.list_secret_versions), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -2187,7 +2208,7 @@ def test_get_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -2203,6 +2224,7 @@ def test_get_secret_version( assert args[0] == service.GetSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -2215,18 +2237,20 @@ def test_get_secret_version_from_dict(): @pytest.mark.asyncio -async def test_get_secret_version_async(transport: str = "grpc_asyncio"): +async def test_get_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.GetSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.GetSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2241,7 +2265,7 @@ async def test_get_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.GetSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -2251,6 +2275,11 @@ async def test_get_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_get_secret_version_async_from_dict(): + await test_get_secret_version_async(request_type=dict) + + def test_get_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2261,7 +2290,7 @@ def test_get_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -2290,7 +2319,7 @@ async def test_get_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -2313,7 +2342,7 @@ def test_get_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2349,7 +2378,7 @@ async def test_get_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2396,7 +2425,7 @@ def test_access_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.AccessSecretVersionResponse(name="name_value",) @@ -2410,6 +2439,7 @@ def test_access_secret_version( assert args[0] == service.AccessSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, service.AccessSecretVersionResponse) assert response.name == "name_value" @@ -2420,18 +2450,20 @@ def test_access_secret_version_from_dict(): @pytest.mark.asyncio -async def test_access_secret_version_async(transport: str = "grpc_asyncio"): +async def test_access_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.AccessSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.AccessSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2444,7 +2476,7 @@ async def test_access_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.AccessSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, service.AccessSecretVersionResponse) @@ -2452,6 +2484,11 @@ async def test_access_secret_version_async(transport: str = "grpc_asyncio"): assert response.name == "name_value" +@pytest.mark.asyncio +async def test_access_secret_version_async_from_dict(): + await test_access_secret_version_async(request_type=dict) + + def test_access_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2462,7 +2499,7 @@ def test_access_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: call.return_value = service.AccessSecretVersionResponse() @@ -2491,7 +2528,7 @@ async def test_access_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.AccessSecretVersionResponse() @@ -2514,7 +2551,7 @@ def test_access_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.AccessSecretVersionResponse() @@ -2550,7 +2587,7 @@ async def test_access_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.AccessSecretVersionResponse() @@ -2597,7 +2634,7 @@ def test_disable_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -2613,6 +2650,7 @@ def test_disable_secret_version( assert args[0] == service.DisableSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -2625,18 +2663,20 @@ def test_disable_secret_version_from_dict(): @pytest.mark.asyncio -async def test_disable_secret_version_async(transport: str = "grpc_asyncio"): +async def test_disable_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.DisableSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.DisableSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2651,7 +2691,7 @@ async def test_disable_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.DisableSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -2661,6 +2701,11 @@ async def test_disable_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_disable_secret_version_async_from_dict(): + await test_disable_secret_version_async(request_type=dict) + + def test_disable_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2671,7 +2716,7 @@ def test_disable_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -2700,7 +2745,7 @@ async def test_disable_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -2723,7 +2768,7 @@ def test_disable_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2759,7 +2804,7 @@ async def test_disable_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2806,7 +2851,7 @@ def test_enable_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -2822,6 +2867,7 @@ def test_enable_secret_version( assert args[0] == service.EnableSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -2834,18 +2880,20 @@ def test_enable_secret_version_from_dict(): @pytest.mark.asyncio -async def test_enable_secret_version_async(transport: str = "grpc_asyncio"): +async def test_enable_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.EnableSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.EnableSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2860,7 +2908,7 @@ async def test_enable_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.EnableSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -2870,6 +2918,11 @@ async def test_enable_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_enable_secret_version_async_from_dict(): + await test_enable_secret_version_async(request_type=dict) + + def test_enable_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2880,7 +2933,7 @@ def test_enable_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -2909,7 +2962,7 @@ async def test_enable_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -2932,7 +2985,7 @@ def test_enable_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2968,7 +3021,7 @@ async def test_enable_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -3015,7 +3068,7 @@ def test_destroy_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -3031,6 +3084,7 @@ def test_destroy_secret_version( assert args[0] == service.DestroySecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -3043,18 +3097,20 @@ def test_destroy_secret_version_from_dict(): @pytest.mark.asyncio -async def test_destroy_secret_version_async(transport: str = "grpc_asyncio"): +async def test_destroy_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.DestroySecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.DestroySecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -3069,7 +3125,7 @@ async def test_destroy_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.DestroySecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -3079,6 +3135,11 @@ async def test_destroy_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_destroy_secret_version_async_from_dict(): + await test_destroy_secret_version_async(request_type=dict) + + def test_destroy_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3089,7 +3150,7 @@ def test_destroy_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -3118,7 +3179,7 @@ async def test_destroy_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -3141,7 +3202,7 @@ def test_destroy_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -3177,7 +3238,7 @@ async def test_destroy_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -3223,7 +3284,7 @@ def test_set_iam_policy( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.set_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = policy.Policy(version=774, etag=b"etag_blob",) @@ -3236,6 +3297,7 @@ def test_set_iam_policy( assert args[0] == iam_policy.SetIamPolicyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, policy.Policy) assert response.version == 774 @@ -3248,19 +3310,19 @@ def test_set_iam_policy_from_dict(): @pytest.mark.asyncio -async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): +async def test_set_iam_policy_async( + transport: str = "grpc_asyncio", request_type=iam_policy.SetIamPolicyRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = iam_policy.SetIamPolicyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.set_iam_policy), "__call__" - ) as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( policy.Policy(version=774, etag=b"etag_blob",) @@ -3272,7 +3334,7 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == iam_policy.SetIamPolicyRequest() # Establish that the response is the type that we expect. assert isinstance(response, policy.Policy) @@ -3282,6 +3344,11 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): assert response.etag == b"etag_blob" +@pytest.mark.asyncio +async def test_set_iam_policy_async_from_dict(): + await test_set_iam_policy_async(request_type=dict) + + def test_set_iam_policy_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3291,7 +3358,7 @@ def test_set_iam_policy_field_headers(): request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.set_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: call.return_value = policy.Policy() client.set_iam_policy(request) @@ -3318,9 +3385,7 @@ async def test_set_iam_policy_field_headers_async(): request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.set_iam_policy), "__call__" - ) as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) await client.set_iam_policy(request) @@ -3335,10 +3400,10 @@ async def test_set_iam_policy_field_headers_async(): assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] -def test_set_iam_policy_from_dict(): +def test_set_iam_policy_from_dict_foreign(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.set_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = policy.Policy() @@ -3363,7 +3428,7 @@ def test_get_iam_policy( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = policy.Policy(version=774, etag=b"etag_blob",) @@ -3376,6 +3441,7 @@ def test_get_iam_policy( assert args[0] == iam_policy.GetIamPolicyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, policy.Policy) assert response.version == 774 @@ -3388,19 +3454,19 @@ def test_get_iam_policy_from_dict(): @pytest.mark.asyncio -async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): +async def test_get_iam_policy_async( + transport: str = "grpc_asyncio", request_type=iam_policy.GetIamPolicyRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = iam_policy.GetIamPolicyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_iam_policy), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( policy.Policy(version=774, etag=b"etag_blob",) @@ -3412,7 +3478,7 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == iam_policy.GetIamPolicyRequest() # Establish that the response is the type that we expect. assert isinstance(response, policy.Policy) @@ -3422,6 +3488,11 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): assert response.etag == b"etag_blob" +@pytest.mark.asyncio +async def test_get_iam_policy_async_from_dict(): + await test_get_iam_policy_async(request_type=dict) + + def test_get_iam_policy_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3431,7 +3502,7 @@ def test_get_iam_policy_field_headers(): request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: call.return_value = policy.Policy() client.get_iam_policy(request) @@ -3458,9 +3529,7 @@ async def test_get_iam_policy_field_headers_async(): request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_iam_policy), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) await client.get_iam_policy(request) @@ -3475,10 +3544,10 @@ async def test_get_iam_policy_field_headers_async(): assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] -def test_get_iam_policy_from_dict(): +def test_get_iam_policy_from_dict_foreign(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = policy.Policy() @@ -3504,7 +3573,7 @@ def test_test_iam_permissions( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = iam_policy.TestIamPermissionsResponse( @@ -3520,6 +3589,7 @@ def test_test_iam_permissions( assert args[0] == iam_policy.TestIamPermissionsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, iam_policy.TestIamPermissionsResponse) assert response.permissions == ["permissions_value"] @@ -3530,18 +3600,20 @@ def test_test_iam_permissions_from_dict(): @pytest.mark.asyncio -async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): +async def test_test_iam_permissions_async( + transport: str = "grpc_asyncio", request_type=iam_policy.TestIamPermissionsRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = iam_policy.TestIamPermissionsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -3554,7 +3626,7 @@ async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == iam_policy.TestIamPermissionsRequest() # Establish that the response is the type that we expect. assert isinstance(response, iam_policy.TestIamPermissionsResponse) @@ -3562,6 +3634,11 @@ async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): assert response.permissions == ["permissions_value"] +@pytest.mark.asyncio +async def test_test_iam_permissions_async_from_dict(): + await test_test_iam_permissions_async(request_type=dict) + + def test_test_iam_permissions_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3572,7 +3649,7 @@ def test_test_iam_permissions_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: call.return_value = iam_policy.TestIamPermissionsResponse() @@ -3601,7 +3678,7 @@ async def test_test_iam_permissions_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( iam_policy.TestIamPermissionsResponse() @@ -3619,11 +3696,11 @@ async def test_test_iam_permissions_field_headers_async(): assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] -def test_test_iam_permissions_from_dict(): +def test_test_iam_permissions_from_dict_foreign(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = iam_policy.TestIamPermissionsResponse() @@ -3673,7 +3750,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = SecretManagerServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -3709,7 +3786,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.SecretManagerServiceGrpcTransport,) + assert isinstance(client.transport, transports.SecretManagerServiceGrpcTransport,) def test_secret_manager_service_base_transport_error(): @@ -3817,7 +3894,7 @@ def test_secret_manager_service_host_no_port(): api_endpoint="secretmanager.googleapis.com" ), ) - assert client._transport._host == "secretmanager.googleapis.com:443" + assert client.transport._host == "secretmanager.googleapis.com:443" def test_secret_manager_service_host_with_port(): @@ -3827,7 +3904,7 @@ def test_secret_manager_service_host_with_port(): api_endpoint="secretmanager.googleapis.com:8000" ), ) - assert client._transport._host == "secretmanager.googleapis.com:8000" + assert client.transport._host == "secretmanager.googleapis.com:8000" def test_secret_manager_service_grpc_transport_channel(): @@ -3839,6 +3916,7 @@ def test_secret_manager_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_secret_manager_service_grpc_asyncio_transport_channel(): @@ -3850,6 +3928,7 @@ def test_secret_manager_service_grpc_asyncio_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None @pytest.mark.parametrize( @@ -3897,6 +3976,7 @@ def test_secret_manager_service_transport_channel_mtls_with_client_cert_source( quota_project_id=None, ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -3962,6 +4042,134 @@ def test_parse_secret_path(): assert expected == actual +def test_secret_version_path(): + project = "oyster" + secret = "nudibranch" + secret_version = "cuttlefish" + + expected = "projects/{project}/secrets/{secret}/versions/{secret_version}".format( + project=project, secret=secret, secret_version=secret_version, + ) + actual = SecretManagerServiceClient.secret_version_path( + project, secret, secret_version + ) + assert expected == actual + + +def test_parse_secret_version_path(): + expected = { + "project": "mussel", + "secret": "winkle", + "secret_version": "nautilus", + } + path = SecretManagerServiceClient.secret_version_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_secret_version_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "scallop" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = SecretManagerServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "abalone", + } + path = SecretManagerServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "squid" + + expected = "folders/{folder}".format(folder=folder,) + actual = SecretManagerServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "clam", + } + path = SecretManagerServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "whelk" + + expected = "organizations/{organization}".format(organization=organization,) + actual = SecretManagerServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "octopus", + } + path = SecretManagerServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "oyster" + + expected = "projects/{project}".format(project=project,) + actual = SecretManagerServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nudibranch", + } + path = SecretManagerServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "cuttlefish" + location = "mussel" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = SecretManagerServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "winkle", + "location": "nautilus", + } + path = SecretManagerServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_location_path(path) + assert expected == actual + + def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo() diff --git a/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py b/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py index f8ae64c..b648685 100644 --- a/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py +++ b/tests/unit/gapic/secretmanager_v1beta1/test_secret_manager_service.py @@ -108,12 +108,12 @@ def test_secret_manager_service_client_from_service_account_file(client_class): ) as factory: factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") - assert client._transport._credentials == creds + assert client.transport._credentials == creds client = client_class.from_service_account_json("dummy/file/path.json") - assert client._transport._credentials == creds + assert client.transport._credentials == creds - assert client._transport._host == "secretmanager.googleapis.com:443" + assert client.transport._host == "secretmanager.googleapis.com:443" def test_secret_manager_service_client_get_transport_class(): @@ -483,7 +483,7 @@ def test_list_secrets(transport: str = "grpc", request_type=service.ListSecretsR request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretsResponse( next_page_token="next_page_token_value", total_size=1086, @@ -498,6 +498,7 @@ def test_list_secrets(transport: str = "grpc", request_type=service.ListSecretsR assert args[0] == service.ListSecretsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSecretsPager) assert response.next_page_token == "next_page_token_value" @@ -510,19 +511,19 @@ def test_list_secrets_from_dict(): @pytest.mark.asyncio -async def test_list_secrets_async(transport: str = "grpc_asyncio"): +async def test_list_secrets_async( + transport: str = "grpc_asyncio", request_type=service.ListSecretsRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.ListSecretsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_secrets), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListSecretsResponse( @@ -536,7 +537,7 @@ async def test_list_secrets_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.ListSecretsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListSecretsAsyncPager) @@ -546,6 +547,11 @@ async def test_list_secrets_async(transport: str = "grpc_asyncio"): assert response.total_size == 1086 +@pytest.mark.asyncio +async def test_list_secrets_async_from_dict(): + await test_list_secrets_async(request_type=dict) + + def test_list_secrets_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -555,7 +561,7 @@ def test_list_secrets_field_headers(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: call.return_value = service.ListSecretsResponse() client.list_secrets(request) @@ -582,9 +588,7 @@ async def test_list_secrets_field_headers_async(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_secrets), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListSecretsResponse() ) @@ -605,7 +609,7 @@ def test_list_secrets_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretsResponse() @@ -639,9 +643,7 @@ async def test_list_secrets_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_secrets), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretsResponse() @@ -678,7 +680,7 @@ def test_list_secrets_pager(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListSecretsResponse( @@ -712,7 +714,7 @@ def test_list_secrets_pages(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_secrets), "__call__") as call: + with mock.patch.object(type(client.transport.list_secrets), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( service.ListSecretsResponse( @@ -741,9 +743,7 @@ async def test_list_secrets_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secrets), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_secrets), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -778,9 +778,7 @@ async def test_list_secrets_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secrets), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_secrets), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -816,7 +814,7 @@ def test_create_secret( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_secret), "__call__") as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret(name="name_value",) @@ -829,6 +827,7 @@ def test_create_secret( assert args[0] == service.CreateSecretRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.Secret) assert response.name == "name_value" @@ -839,19 +838,19 @@ def test_create_secret_from_dict(): @pytest.mark.asyncio -async def test_create_secret_async(transport: str = "grpc_asyncio"): +async def test_create_secret_async( + transport: str = "grpc_asyncio", request_type=service.CreateSecretRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.CreateSecretRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Secret(name="name_value",) @@ -863,7 +862,7 @@ async def test_create_secret_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.CreateSecretRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Secret) @@ -871,6 +870,11 @@ async def test_create_secret_async(transport: str = "grpc_asyncio"): assert response.name == "name_value" +@pytest.mark.asyncio +async def test_create_secret_async_from_dict(): + await test_create_secret_async(request_type=dict) + + def test_create_secret_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -880,7 +884,7 @@ def test_create_secret_field_headers(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_secret), "__call__") as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: call.return_value = resources.Secret() client.create_secret(request) @@ -907,9 +911,7 @@ async def test_create_secret_field_headers_async(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Secret()) await client.create_secret(request) @@ -928,7 +930,7 @@ def test_create_secret_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_secret), "__call__") as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -973,9 +975,7 @@ async def test_create_secret_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1030,7 +1030,7 @@ def test_add_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -1046,6 +1046,7 @@ def test_add_secret_version( assert args[0] == service.AddSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -1058,18 +1059,20 @@ def test_add_secret_version_from_dict(): @pytest.mark.asyncio -async def test_add_secret_version_async(transport: str = "grpc_asyncio"): +async def test_add_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.AddSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.AddSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1084,7 +1087,7 @@ async def test_add_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.AddSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -1094,6 +1097,11 @@ async def test_add_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_add_secret_version_async_from_dict(): + await test_add_secret_version_async(request_type=dict) + + def test_add_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1104,7 +1112,7 @@ def test_add_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -1133,7 +1141,7 @@ async def test_add_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -1156,7 +1164,7 @@ def test_add_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -1198,7 +1206,7 @@ async def test_add_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.add_secret_version), "__call__" + type(client.transport.add_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -1248,7 +1256,7 @@ def test_get_secret(transport: str = "grpc", request_type=service.GetSecretReque request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_secret), "__call__") as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret(name="name_value",) @@ -1261,6 +1269,7 @@ def test_get_secret(transport: str = "grpc", request_type=service.GetSecretReque assert args[0] == service.GetSecretRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.Secret) assert response.name == "name_value" @@ -1271,19 +1280,19 @@ def test_get_secret_from_dict(): @pytest.mark.asyncio -async def test_get_secret_async(transport: str = "grpc_asyncio"): +async def test_get_secret_async( + transport: str = "grpc_asyncio", request_type=service.GetSecretRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.GetSecretRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Secret(name="name_value",) @@ -1295,7 +1304,7 @@ async def test_get_secret_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.GetSecretRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Secret) @@ -1303,6 +1312,11 @@ async def test_get_secret_async(transport: str = "grpc_asyncio"): assert response.name == "name_value" +@pytest.mark.asyncio +async def test_get_secret_async_from_dict(): + await test_get_secret_async(request_type=dict) + + def test_get_secret_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1312,7 +1326,7 @@ def test_get_secret_field_headers(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_secret), "__call__") as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: call.return_value = resources.Secret() client.get_secret(request) @@ -1339,9 +1353,7 @@ async def test_get_secret_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Secret()) await client.get_secret(request) @@ -1360,7 +1372,7 @@ def test_get_secret_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_secret), "__call__") as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1394,9 +1406,7 @@ async def test_get_secret_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1439,7 +1449,7 @@ def test_update_secret( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_secret), "__call__") as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret(name="name_value",) @@ -1452,6 +1462,7 @@ def test_update_secret( assert args[0] == service.UpdateSecretRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.Secret) assert response.name == "name_value" @@ -1462,19 +1473,19 @@ def test_update_secret_from_dict(): @pytest.mark.asyncio -async def test_update_secret_async(transport: str = "grpc_asyncio"): +async def test_update_secret_async( + transport: str = "grpc_asyncio", request_type=service.UpdateSecretRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.UpdateSecretRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.Secret(name="name_value",) @@ -1486,7 +1497,7 @@ async def test_update_secret_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.UpdateSecretRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.Secret) @@ -1494,6 +1505,11 @@ async def test_update_secret_async(transport: str = "grpc_asyncio"): assert response.name == "name_value" +@pytest.mark.asyncio +async def test_update_secret_async_from_dict(): + await test_update_secret_async(request_type=dict) + + def test_update_secret_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1503,7 +1519,7 @@ def test_update_secret_field_headers(): request.secret.name = "secret.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_secret), "__call__") as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: call.return_value = resources.Secret() client.update_secret(request) @@ -1530,9 +1546,7 @@ async def test_update_secret_field_headers_async(): request.secret.name = "secret.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(resources.Secret()) await client.update_secret(request) @@ -1551,7 +1565,7 @@ def test_update_secret_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_secret), "__call__") as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1592,9 +1606,7 @@ async def test_update_secret_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = resources.Secret() @@ -1644,7 +1656,7 @@ def test_delete_secret( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_secret), "__call__") as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1665,19 +1677,19 @@ def test_delete_secret_from_dict(): @pytest.mark.asyncio -async def test_delete_secret_async(transport: str = "grpc_asyncio"): +async def test_delete_secret_async( + transport: str = "grpc_asyncio", request_type=service.DeleteSecretRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.DeleteSecretRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1687,12 +1699,17 @@ async def test_delete_secret_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.DeleteSecretRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_secret_async_from_dict(): + await test_delete_secret_async(request_type=dict) + + def test_delete_secret_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1702,7 +1719,7 @@ def test_delete_secret_field_headers(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_secret), "__call__") as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: call.return_value = None client.delete_secret(request) @@ -1729,9 +1746,7 @@ async def test_delete_secret_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_secret(request) @@ -1750,7 +1765,7 @@ def test_delete_secret_flattened(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_secret), "__call__") as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1784,9 +1799,7 @@ async def test_delete_secret_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_secret), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_secret), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1830,7 +1843,7 @@ def test_list_secret_versions( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretVersionsResponse( @@ -1846,6 +1859,7 @@ def test_list_secret_versions( assert args[0] == service.ListSecretVersionsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListSecretVersionsPager) assert response.next_page_token == "next_page_token_value" @@ -1858,18 +1872,20 @@ def test_list_secret_versions_from_dict(): @pytest.mark.asyncio -async def test_list_secret_versions_async(transport: str = "grpc_asyncio"): +async def test_list_secret_versions_async( + transport: str = "grpc_asyncio", request_type=service.ListSecretVersionsRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.ListSecretVersionsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1884,7 +1900,7 @@ async def test_list_secret_versions_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.ListSecretVersionsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListSecretVersionsAsyncPager) @@ -1894,6 +1910,11 @@ async def test_list_secret_versions_async(transport: str = "grpc_asyncio"): assert response.total_size == 1086 +@pytest.mark.asyncio +async def test_list_secret_versions_async_from_dict(): + await test_list_secret_versions_async(request_type=dict) + + def test_list_secret_versions_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1904,7 +1925,7 @@ def test_list_secret_versions_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: call.return_value = service.ListSecretVersionsResponse() @@ -1933,7 +1954,7 @@ async def test_list_secret_versions_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.ListSecretVersionsResponse() @@ -1956,7 +1977,7 @@ def test_list_secret_versions_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretVersionsResponse() @@ -1992,7 +2013,7 @@ async def test_list_secret_versions_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.ListSecretVersionsResponse() @@ -2031,7 +2052,7 @@ def test_list_secret_versions_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2071,7 +2092,7 @@ def test_list_secret_versions_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_secret_versions), "__call__" + type(client.transport.list_secret_versions), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2105,7 +2126,7 @@ async def test_list_secret_versions_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), + type(client.transport.list_secret_versions), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -2146,7 +2167,7 @@ async def test_list_secret_versions_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_secret_versions), + type(client.transport.list_secret_versions), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -2189,7 +2210,7 @@ def test_get_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -2205,6 +2226,7 @@ def test_get_secret_version( assert args[0] == service.GetSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -2217,18 +2239,20 @@ def test_get_secret_version_from_dict(): @pytest.mark.asyncio -async def test_get_secret_version_async(transport: str = "grpc_asyncio"): +async def test_get_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.GetSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.GetSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2243,7 +2267,7 @@ async def test_get_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.GetSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -2253,6 +2277,11 @@ async def test_get_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_get_secret_version_async_from_dict(): + await test_get_secret_version_async(request_type=dict) + + def test_get_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2263,7 +2292,7 @@ def test_get_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -2292,7 +2321,7 @@ async def test_get_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -2315,7 +2344,7 @@ def test_get_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2351,7 +2380,7 @@ async def test_get_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_secret_version), "__call__" + type(client.transport.get_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2398,7 +2427,7 @@ def test_access_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.AccessSecretVersionResponse(name="name_value",) @@ -2412,6 +2441,7 @@ def test_access_secret_version( assert args[0] == service.AccessSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, service.AccessSecretVersionResponse) assert response.name == "name_value" @@ -2422,18 +2452,20 @@ def test_access_secret_version_from_dict(): @pytest.mark.asyncio -async def test_access_secret_version_async(transport: str = "grpc_asyncio"): +async def test_access_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.AccessSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.AccessSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2446,7 +2478,7 @@ async def test_access_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.AccessSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, service.AccessSecretVersionResponse) @@ -2454,6 +2486,11 @@ async def test_access_secret_version_async(transport: str = "grpc_asyncio"): assert response.name == "name_value" +@pytest.mark.asyncio +async def test_access_secret_version_async_from_dict(): + await test_access_secret_version_async(request_type=dict) + + def test_access_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2464,7 +2501,7 @@ def test_access_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: call.return_value = service.AccessSecretVersionResponse() @@ -2493,7 +2530,7 @@ async def test_access_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( service.AccessSecretVersionResponse() @@ -2516,7 +2553,7 @@ def test_access_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.AccessSecretVersionResponse() @@ -2552,7 +2589,7 @@ async def test_access_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.access_secret_version), "__call__" + type(client.transport.access_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = service.AccessSecretVersionResponse() @@ -2599,7 +2636,7 @@ def test_disable_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -2615,6 +2652,7 @@ def test_disable_secret_version( assert args[0] == service.DisableSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -2627,18 +2665,20 @@ def test_disable_secret_version_from_dict(): @pytest.mark.asyncio -async def test_disable_secret_version_async(transport: str = "grpc_asyncio"): +async def test_disable_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.DisableSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.DisableSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2653,7 +2693,7 @@ async def test_disable_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.DisableSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -2663,6 +2703,11 @@ async def test_disable_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_disable_secret_version_async_from_dict(): + await test_disable_secret_version_async(request_type=dict) + + def test_disable_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2673,7 +2718,7 @@ def test_disable_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -2702,7 +2747,7 @@ async def test_disable_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -2725,7 +2770,7 @@ def test_disable_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2761,7 +2806,7 @@ async def test_disable_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.disable_secret_version), "__call__" + type(client.transport.disable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2808,7 +2853,7 @@ def test_enable_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -2824,6 +2869,7 @@ def test_enable_secret_version( assert args[0] == service.EnableSecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -2836,18 +2882,20 @@ def test_enable_secret_version_from_dict(): @pytest.mark.asyncio -async def test_enable_secret_version_async(transport: str = "grpc_asyncio"): +async def test_enable_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.EnableSecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.EnableSecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2862,7 +2910,7 @@ async def test_enable_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.EnableSecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -2872,6 +2920,11 @@ async def test_enable_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_enable_secret_version_async_from_dict(): + await test_enable_secret_version_async(request_type=dict) + + def test_enable_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2882,7 +2935,7 @@ def test_enable_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -2911,7 +2964,7 @@ async def test_enable_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -2934,7 +2987,7 @@ def test_enable_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -2970,7 +3023,7 @@ async def test_enable_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.enable_secret_version), "__call__" + type(client.transport.enable_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -3017,7 +3070,7 @@ def test_destroy_secret_version( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion( @@ -3033,6 +3086,7 @@ def test_destroy_secret_version( assert args[0] == service.DestroySecretVersionRequest() # Establish that the response is the type that we expect. + assert isinstance(response, resources.SecretVersion) assert response.name == "name_value" @@ -3045,18 +3099,20 @@ def test_destroy_secret_version_from_dict(): @pytest.mark.asyncio -async def test_destroy_secret_version_async(transport: str = "grpc_asyncio"): +async def test_destroy_secret_version_async( + transport: str = "grpc_asyncio", request_type=service.DestroySecretVersionRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = service.DestroySecretVersionRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -3071,7 +3127,7 @@ async def test_destroy_secret_version_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == service.DestroySecretVersionRequest() # Establish that the response is the type that we expect. assert isinstance(response, resources.SecretVersion) @@ -3081,6 +3137,11 @@ async def test_destroy_secret_version_async(transport: str = "grpc_asyncio"): assert response.state == resources.SecretVersion.State.ENABLED +@pytest.mark.asyncio +async def test_destroy_secret_version_async_from_dict(): + await test_destroy_secret_version_async(request_type=dict) + + def test_destroy_secret_version_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3091,7 +3152,7 @@ def test_destroy_secret_version_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: call.return_value = resources.SecretVersion() @@ -3120,7 +3181,7 @@ async def test_destroy_secret_version_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( resources.SecretVersion() @@ -3143,7 +3204,7 @@ def test_destroy_secret_version_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -3179,7 +3240,7 @@ async def test_destroy_secret_version_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.destroy_secret_version), "__call__" + type(client.transport.destroy_secret_version), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = resources.SecretVersion() @@ -3225,7 +3286,7 @@ def test_set_iam_policy( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.set_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = policy.Policy(version=774, etag=b"etag_blob",) @@ -3238,6 +3299,7 @@ def test_set_iam_policy( assert args[0] == iam_policy.SetIamPolicyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, policy.Policy) assert response.version == 774 @@ -3250,19 +3312,19 @@ def test_set_iam_policy_from_dict(): @pytest.mark.asyncio -async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): +async def test_set_iam_policy_async( + transport: str = "grpc_asyncio", request_type=iam_policy.SetIamPolicyRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = iam_policy.SetIamPolicyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.set_iam_policy), "__call__" - ) as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( policy.Policy(version=774, etag=b"etag_blob",) @@ -3274,7 +3336,7 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == iam_policy.SetIamPolicyRequest() # Establish that the response is the type that we expect. assert isinstance(response, policy.Policy) @@ -3284,6 +3346,11 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): assert response.etag == b"etag_blob" +@pytest.mark.asyncio +async def test_set_iam_policy_async_from_dict(): + await test_set_iam_policy_async(request_type=dict) + + def test_set_iam_policy_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3293,7 +3360,7 @@ def test_set_iam_policy_field_headers(): request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.set_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: call.return_value = policy.Policy() client.set_iam_policy(request) @@ -3320,9 +3387,7 @@ async def test_set_iam_policy_field_headers_async(): request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.set_iam_policy), "__call__" - ) as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) await client.set_iam_policy(request) @@ -3337,10 +3402,10 @@ async def test_set_iam_policy_field_headers_async(): assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] -def test_set_iam_policy_from_dict(): +def test_set_iam_policy_from_dict_foreign(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.set_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = policy.Policy() @@ -3365,7 +3430,7 @@ def test_get_iam_policy( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = policy.Policy(version=774, etag=b"etag_blob",) @@ -3378,6 +3443,7 @@ def test_get_iam_policy( assert args[0] == iam_policy.GetIamPolicyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, policy.Policy) assert response.version == 774 @@ -3390,19 +3456,19 @@ def test_get_iam_policy_from_dict(): @pytest.mark.asyncio -async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): +async def test_get_iam_policy_async( + transport: str = "grpc_asyncio", request_type=iam_policy.GetIamPolicyRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = iam_policy.GetIamPolicyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_iam_policy), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( policy.Policy(version=774, etag=b"etag_blob",) @@ -3414,7 +3480,7 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == iam_policy.GetIamPolicyRequest() # Establish that the response is the type that we expect. assert isinstance(response, policy.Policy) @@ -3424,6 +3490,11 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): assert response.etag == b"etag_blob" +@pytest.mark.asyncio +async def test_get_iam_policy_async_from_dict(): + await test_get_iam_policy_async(request_type=dict) + + def test_get_iam_policy_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3433,7 +3504,7 @@ def test_get_iam_policy_field_headers(): request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: call.return_value = policy.Policy() client.get_iam_policy(request) @@ -3460,9 +3531,7 @@ async def test_get_iam_policy_field_headers_async(): request.resource = "resource/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_iam_policy), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy.Policy()) await client.get_iam_policy(request) @@ -3477,10 +3546,10 @@ async def test_get_iam_policy_field_headers_async(): assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] -def test_get_iam_policy_from_dict(): +def test_get_iam_policy_from_dict_foreign(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_iam_policy), "__call__") as call: + with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = policy.Policy() @@ -3506,7 +3575,7 @@ def test_test_iam_permissions( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = iam_policy.TestIamPermissionsResponse( @@ -3522,6 +3591,7 @@ def test_test_iam_permissions( assert args[0] == iam_policy.TestIamPermissionsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, iam_policy.TestIamPermissionsResponse) assert response.permissions == ["permissions_value"] @@ -3532,18 +3602,20 @@ def test_test_iam_permissions_from_dict(): @pytest.mark.asyncio -async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): +async def test_test_iam_permissions_async( + transport: str = "grpc_asyncio", request_type=iam_policy.TestIamPermissionsRequest +): client = SecretManagerServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = iam_policy.TestIamPermissionsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -3556,7 +3628,7 @@ async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == iam_policy.TestIamPermissionsRequest() # Establish that the response is the type that we expect. assert isinstance(response, iam_policy.TestIamPermissionsResponse) @@ -3564,6 +3636,11 @@ async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): assert response.permissions == ["permissions_value"] +@pytest.mark.asyncio +async def test_test_iam_permissions_async_from_dict(): + await test_test_iam_permissions_async(request_type=dict) + + def test_test_iam_permissions_field_headers(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3574,7 +3651,7 @@ def test_test_iam_permissions_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: call.return_value = iam_policy.TestIamPermissionsResponse() @@ -3603,7 +3680,7 @@ async def test_test_iam_permissions_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( iam_policy.TestIamPermissionsResponse() @@ -3621,11 +3698,11 @@ async def test_test_iam_permissions_field_headers_async(): assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] -def test_test_iam_permissions_from_dict(): +def test_test_iam_permissions_from_dict_foreign(): client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.test_iam_permissions), "__call__" + type(client.transport.test_iam_permissions), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = iam_policy.TestIamPermissionsResponse() @@ -3675,7 +3752,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = SecretManagerServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -3711,7 +3788,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = SecretManagerServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.SecretManagerServiceGrpcTransport,) + assert isinstance(client.transport, transports.SecretManagerServiceGrpcTransport,) def test_secret_manager_service_base_transport_error(): @@ -3819,7 +3896,7 @@ def test_secret_manager_service_host_no_port(): api_endpoint="secretmanager.googleapis.com" ), ) - assert client._transport._host == "secretmanager.googleapis.com:443" + assert client.transport._host == "secretmanager.googleapis.com:443" def test_secret_manager_service_host_with_port(): @@ -3829,7 +3906,7 @@ def test_secret_manager_service_host_with_port(): api_endpoint="secretmanager.googleapis.com:8000" ), ) - assert client._transport._host == "secretmanager.googleapis.com:8000" + assert client.transport._host == "secretmanager.googleapis.com:8000" def test_secret_manager_service_grpc_transport_channel(): @@ -3841,6 +3918,7 @@ def test_secret_manager_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_secret_manager_service_grpc_asyncio_transport_channel(): @@ -3852,6 +3930,7 @@ def test_secret_manager_service_grpc_asyncio_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None @pytest.mark.parametrize( @@ -3899,6 +3978,7 @@ def test_secret_manager_service_transport_channel_mtls_with_client_cert_source( quota_project_id=None, ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -3964,6 +4044,134 @@ def test_parse_secret_path(): assert expected == actual +def test_secret_version_path(): + project = "oyster" + secret = "nudibranch" + secret_version = "cuttlefish" + + expected = "projects/{project}/secrets/{secret}/versions/{secret_version}".format( + project=project, secret=secret, secret_version=secret_version, + ) + actual = SecretManagerServiceClient.secret_version_path( + project, secret, secret_version + ) + assert expected == actual + + +def test_parse_secret_version_path(): + expected = { + "project": "mussel", + "secret": "winkle", + "secret_version": "nautilus", + } + path = SecretManagerServiceClient.secret_version_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_secret_version_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "scallop" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = SecretManagerServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "abalone", + } + path = SecretManagerServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "squid" + + expected = "folders/{folder}".format(folder=folder,) + actual = SecretManagerServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "clam", + } + path = SecretManagerServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "whelk" + + expected = "organizations/{organization}".format(organization=organization,) + actual = SecretManagerServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "octopus", + } + path = SecretManagerServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "oyster" + + expected = "projects/{project}".format(project=project,) + actual = SecretManagerServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nudibranch", + } + path = SecretManagerServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "cuttlefish" + location = "mussel" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = SecretManagerServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "winkle", + "location": "nautilus", + } + path = SecretManagerServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = SecretManagerServiceClient.parse_common_location_path(path) + assert expected == actual + + def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo()