From fbe4d9b3c1fbd7d2ea684151e804885ce056be9f Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Fri, 2 Oct 2020 17:26:05 +0200 Subject: [PATCH 1/9] chore(deps): update dependency google.cloud.talent to v2 (#39) --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 7c4d2283..41bc2060 100755 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1 +1 @@ -google.cloud.talent==1.0.0 \ No newline at end of file +google.cloud.talent==2.0.0 \ No newline at end of file From 3665b0818471dbad701f0c762654d71316a508d9 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Wed, 23 Dec 2020 12:47:10 -0700 Subject: [PATCH 2/9] chore: require samples checks (#43) --- .github/sync-repo-settings.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 00000000..af599353 --- /dev/null +++ b/.github/sync-repo-settings.yaml @@ -0,0 +1,13 @@ +# 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' From 6f17871a73d2112b5792ad87bf4a2d0e25beb03e Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 23 Dec 2020 14:39:18 -0800 Subject: [PATCH 3/9] feat: add common resource helper methods; expose client transport remove gRPC send/recv limits (#57) --- docs/talent_v4/types.rst | 1 + docs/talent_v4beta1/types.rst | 1 + google/cloud/talent_v4/__init__.py | 4 +- .../services/company_service/async_client.py | 61 ++- .../services/company_service/client.py | 89 +++- .../company_service/transports/__init__.py | 1 - .../company_service/transports/base.py | 6 +- .../company_service/transports/grpc.py | 28 +- .../transports/grpc_asyncio.py | 12 + .../services/completion/async_client.py | 39 +- .../talent_v4/services/completion/client.py | 105 +++- .../completion/transports/__init__.py | 1 - .../services/completion/transports/base.py | 2 +- .../services/completion/transports/grpc.py | 28 +- .../completion/transports/grpc_asyncio.py | 12 + .../services/event_service/async_client.py | 40 +- .../services/event_service/client.py | 89 +++- .../event_service/transports/__init__.py | 1 - .../services/event_service/transports/grpc.py | 28 +- .../event_service/transports/grpc_asyncio.py | 12 + .../services/job_service/async_client.py | 81 ++- .../talent_v4/services/job_service/client.py | 120 ++++- .../job_service/transports/__init__.py | 1 - .../services/job_service/transports/base.py | 6 +- .../services/job_service/transports/grpc.py | 37 +- .../job_service/transports/grpc_asyncio.py | 19 +- .../services/tenant_service/async_client.py | 59 ++- .../services/tenant_service/client.py | 76 ++- .../tenant_service/transports/__init__.py | 1 - .../tenant_service/transports/base.py | 6 +- .../tenant_service/transports/grpc.py | 28 +- .../tenant_service/transports/grpc_asyncio.py | 12 + google/cloud/talent_v4/types/__init__.py | 23 +- .../talent_v4/types/completion_service.py | 2 +- google/cloud/talent_v4/types/job_service.py | 6 +- google/cloud/talent_v4beta1/__init__.py | 4 +- .../application_service/async_client.py | 59 ++- .../services/application_service/client.py | 124 ++++- .../transports/__init__.py | 1 - .../application_service/transports/grpc.py | 28 +- .../transports/grpc_asyncio.py | 12 + .../services/company_service/async_client.py | 53 +- .../services/company_service/client.py | 76 ++- .../company_service/transports/__init__.py | 1 - .../company_service/transports/grpc.py | 28 +- .../transports/grpc_asyncio.py | 12 + .../services/completion/async_client.py | 35 ++ .../services/completion/client.py | 92 +++- .../completion/transports/__init__.py | 1 - .../services/completion/transports/grpc.py | 28 +- .../completion/transports/grpc_asyncio.py | 12 + .../services/event_service/async_client.py | 40 +- .../services/event_service/client.py | 92 +++- .../event_service/transports/__init__.py | 1 - .../services/event_service/transports/grpc.py | 28 +- .../event_service/transports/grpc_asyncio.py | 12 + .../services/job_service/async_client.py | 68 ++- .../services/job_service/client.py | 102 +++- .../job_service/transports/__init__.py | 1 - .../services/job_service/transports/grpc.py | 37 +- .../job_service/transports/grpc_asyncio.py | 19 +- .../services/profile_service/async_client.py | 55 +- .../services/profile_service/client.py | 89 +++- .../profile_service/transports/__init__.py | 1 - .../profile_service/transports/grpc.py | 28 +- .../transports/grpc_asyncio.py | 12 + .../services/tenant_service/async_client.py | 53 +- .../services/tenant_service/client.py | 76 ++- .../tenant_service/transports/__init__.py | 1 - .../tenant_service/transports/grpc.py | 28 +- .../tenant_service/transports/grpc_asyncio.py | 12 + google/cloud/talent_v4beta1/types/__init__.py | 31 +- .../types/completion_service.py | 2 +- google/cloud/talent_v4beta1/types/profile.py | 4 +- noxfile.py | 2 +- scripts/fixup_talent_v4_keywords.py | 1 + scripts/fixup_talent_v4beta1_keywords.py | 1 + synth.metadata | 257 +++++++++- .../gapic/talent_v4/test_company_service.py | 322 ++++++++---- tests/unit/gapic/talent_v4/test_completion.py | 201 +++++++- .../gapic/talent_v4/test_event_service.py | 175 ++++++- .../unit/gapic/talent_v4/test_job_service.py | 482 +++++++++++++----- .../gapic/talent_v4/test_tenant_service.py | 297 +++++++---- .../test_application_service.py | 349 ++++++++++--- .../talent_v4beta1/test_company_service.py | 299 +++++++---- .../gapic/talent_v4beta1/test_completion.py | 178 ++++++- .../talent_v4beta1/test_event_service.py | 177 ++++++- .../gapic/talent_v4beta1/test_job_service.py | 475 +++++++++++------ .../talent_v4beta1/test_profile_service.py | 360 +++++++++---- .../talent_v4beta1/test_tenant_service.py | 297 +++++++---- 90 files changed, 5078 insertions(+), 1190 deletions(-) diff --git a/docs/talent_v4/types.rst b/docs/talent_v4/types.rst index 9b5991f6..559524b9 100644 --- a/docs/talent_v4/types.rst +++ b/docs/talent_v4/types.rst @@ -3,3 +3,4 @@ Types for Google Cloud Talent v4 API .. automodule:: google.cloud.talent_v4.types :members: + :show-inheritance: diff --git a/docs/talent_v4beta1/types.rst b/docs/talent_v4beta1/types.rst index c483abcd..170f4b18 100644 --- a/docs/talent_v4beta1/types.rst +++ b/docs/talent_v4beta1/types.rst @@ -3,3 +3,4 @@ Types for Google Cloud Talent v4beta1 API .. automodule:: google.cloud.talent_v4beta1.types :members: + :show-inheritance: diff --git a/google/cloud/talent_v4/__init__.py b/google/cloud/talent_v4/__init__.py index b193e4de..2f1964fd 100644 --- a/google/cloud/talent_v4/__init__.py +++ b/google/cloud/talent_v4/__init__.py @@ -113,7 +113,6 @@ "DeleteTenantRequest", "DeviceInfo", "EmploymentType", - "EventServiceClient", "GetCompanyRequest", "GetJobRequest", "GetTenantRequest", @@ -144,10 +143,11 @@ "SearchJobsResponse", "SpellingCorrection", "Tenant", + "TenantServiceClient", "TimestampRange", "UpdateCompanyRequest", "UpdateJobRequest", "UpdateTenantRequest", "Visibility", - "TenantServiceClient", + "EventServiceClient", ) diff --git a/google/cloud/talent_v4/services/company_service/async_client.py b/google/cloud/talent_v4/services/company_service/async_client.py index 37769378..dc84e1fd 100644 --- a/google/cloud/talent_v4/services/company_service/async_client.py +++ b/google/cloud/talent_v4/services/company_service/async_client.py @@ -52,10 +52,50 @@ class CompanyServiceAsyncClient: company_path = staticmethod(CompanyServiceClient.company_path) parse_company_path = staticmethod(CompanyServiceClient.parse_company_path) + tenant_path = staticmethod(CompanyServiceClient.tenant_path) + parse_tenant_path = staticmethod(CompanyServiceClient.parse_tenant_path) + + common_billing_account_path = staticmethod( + CompanyServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + CompanyServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(CompanyServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + CompanyServiceClient.parse_common_folder_path + ) + + common_organization_path = staticmethod( + CompanyServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + CompanyServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(CompanyServiceClient.common_project_path) + parse_common_project_path = staticmethod( + CompanyServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(CompanyServiceClient.common_location_path) + parse_common_location_path = staticmethod( + CompanyServiceClient.parse_common_location_path + ) from_service_account_file = CompanyServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> CompanyServiceTransport: + """Return the transport used by the client instance. + + Returns: + CompanyServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(CompanyServiceClient).get_transport_class, type(CompanyServiceClient) ) @@ -159,7 +199,8 @@ async def create_company( # 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, company]): + has_flattened_params = any([parent, company]) + 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." @@ -241,7 +282,8 @@ async def get_company( # 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." @@ -264,7 +306,7 @@ async def get_company( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -341,7 +383,8 @@ async def update_company( # 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([company, update_mask]): + has_flattened_params = any([company, 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." @@ -415,7 +458,8 @@ async def delete_company( # 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." @@ -438,7 +482,7 @@ async def delete_company( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -499,7 +543,8 @@ async def list_companies( # 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." @@ -522,7 +567,7 @@ async def list_companies( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4/services/company_service/client.py b/google/cloud/talent_v4/services/company_service/client.py index 30d6bff0..7b32d9b6 100644 --- a/google/cloud/talent_v4/services/company_service/client.py +++ b/google/cloud/talent_v4/services/company_service/client.py @@ -136,6 +136,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> CompanyServiceTransport: + """Return the transport used by the client instance. + + Returns: + CompanyServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def company_path(project: str, tenant: str, company: str,) -> str: """Return a fully-qualified company string.""" @@ -152,6 +161,78 @@ def parse_company_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def tenant_path(project: str, tenant: str,) -> str: + """Return a fully-qualified tenant string.""" + return "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + + @staticmethod + def parse_tenant_path(path: str) -> Dict[str, str]: + """Parse a tenant path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/tenants/(?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, *, @@ -187,10 +268,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: diff --git a/google/cloud/talent_v4/services/company_service/transports/__init__.py b/google/cloud/talent_v4/services/company_service/transports/__init__.py index ad1eb728..51e34763 100644 --- a/google/cloud/talent_v4/services/company_service/transports/__init__.py +++ b/google/cloud/talent_v4/services/company_service/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = CompanyServiceGrpcTransport _transport_registry["grpc_asyncio"] = CompanyServiceGrpcAsyncIOTransport - __all__ = ( "CompanyServiceTransport", "CompanyServiceGrpcTransport", diff --git a/google/cloud/talent_v4/services/company_service/transports/base.py b/google/cloud/talent_v4/services/company_service/transports/base.py index 849a9354..587ed0c6 100644 --- a/google/cloud/talent_v4/services/company_service/transports/base.py +++ b/google/cloud/talent_v4/services/company_service/transports/base.py @@ -120,7 +120,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -136,7 +136,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4/services/company_service/transports/grpc.py b/google/cloud/talent_v4/services/company_service/transports/grpc.py index 0f89386c..09068973 100644 --- a/google/cloud/talent_v4/services/company_service/transports/grpc.py +++ b/google/cloud/talent_v4/services/company_service/transports/grpc.py @@ -93,10 +93,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: @@ -105,6 +105,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. @@ -112,6 +114,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", @@ -147,7 +150,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -164,6 +172,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -190,7 +202,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -225,12 +237,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/talent_v4/services/company_service/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py index cbe2f0f3..fbf3fa4a 100644 --- a/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py @@ -150,6 +150,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. @@ -157,6 +159,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", @@ -192,7 +195,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -209,6 +217,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4/services/completion/async_client.py b/google/cloud/talent_v4/services/completion/async_client.py index e53fba44..2c91e861 100644 --- a/google/cloud/talent_v4/services/completion/async_client.py +++ b/google/cloud/talent_v4/services/completion/async_client.py @@ -44,9 +44,46 @@ class CompletionAsyncClient: DEFAULT_ENDPOINT = CompletionClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = CompletionClient.DEFAULT_MTLS_ENDPOINT + company_path = staticmethod(CompletionClient.company_path) + parse_company_path = staticmethod(CompletionClient.parse_company_path) + tenant_path = staticmethod(CompletionClient.tenant_path) + parse_tenant_path = staticmethod(CompletionClient.parse_tenant_path) + + common_billing_account_path = staticmethod( + CompletionClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + CompletionClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(CompletionClient.common_folder_path) + parse_common_folder_path = staticmethod(CompletionClient.parse_common_folder_path) + + common_organization_path = staticmethod(CompletionClient.common_organization_path) + parse_common_organization_path = staticmethod( + CompletionClient.parse_common_organization_path + ) + + common_project_path = staticmethod(CompletionClient.common_project_path) + parse_common_project_path = staticmethod(CompletionClient.parse_common_project_path) + + common_location_path = staticmethod(CompletionClient.common_location_path) + parse_common_location_path = staticmethod( + CompletionClient.parse_common_location_path + ) + from_service_account_file = CompletionClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> CompletionTransport: + """Return the transport used by the client instance. + + Returns: + CompletionTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(CompletionClient).get_transport_class, type(CompletionClient) ) @@ -138,7 +175,7 @@ async def complete_query( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4/services/completion/client.py b/google/cloud/talent_v4/services/completion/client.py index af9b83dc..3d3b0589 100644 --- a/google/cloud/talent_v4/services/completion/client.py +++ b/google/cloud/talent_v4/services/completion/client.py @@ -128,6 +128,103 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> CompletionTransport: + """Return the transport used by the client instance. + + Returns: + CompletionTransport: The transport used by the client instance. + """ + return self._transport + + @staticmethod + def company_path(project: str, tenant: str, company: str,) -> str: + """Return a fully-qualified company string.""" + return "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + + @staticmethod + def parse_company_path(path: str) -> Dict[str, str]: + """Parse a company path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/tenants/(?P.+?)/companies/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def tenant_path(project: str, tenant: str,) -> str: + """Return a fully-qualified tenant string.""" + return "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + + @staticmethod + def parse_tenant_path(path: str) -> Dict[str, str]: + """Parse a tenant path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/tenants/(?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, *, @@ -163,10 +260,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: diff --git a/google/cloud/talent_v4/services/completion/transports/__init__.py b/google/cloud/talent_v4/services/completion/transports/__init__.py index 9256febd..df284f3e 100644 --- a/google/cloud/talent_v4/services/completion/transports/__init__.py +++ b/google/cloud/talent_v4/services/completion/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = CompletionGrpcTransport _transport_registry["grpc_asyncio"] = CompletionGrpcAsyncIOTransport - __all__ = ( "CompletionTransport", "CompletionGrpcTransport", diff --git a/google/cloud/talent_v4/services/completion/transports/base.py b/google/cloud/talent_v4/services/completion/transports/base.py index 9f016fcc..efb1e327 100644 --- a/google/cloud/talent_v4/services/completion/transports/base.py +++ b/google/cloud/talent_v4/services/completion/transports/base.py @@ -114,7 +114,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4/services/completion/transports/grpc.py b/google/cloud/talent_v4/services/completion/transports/grpc.py index 68ed6ef3..08fe29d3 100644 --- a/google/cloud/talent_v4/services/completion/transports/grpc.py +++ b/google/cloud/talent_v4/services/completion/transports/grpc.py @@ -89,10 +89,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: @@ -101,6 +101,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. @@ -108,6 +110,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", @@ -143,7 +146,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -160,6 +168,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -186,7 +198,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -221,12 +233,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/talent_v4/services/completion/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py index b24f3e89..d5a0ef57 100644 --- a/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py @@ -146,6 +146,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. @@ -153,6 +155,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", @@ -188,7 +191,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -205,6 +213,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4/services/event_service/async_client.py b/google/cloud/talent_v4/services/event_service/async_client.py index 2178dad2..8a6a6e41 100644 --- a/google/cloud/talent_v4/services/event_service/async_client.py +++ b/google/cloud/talent_v4/services/event_service/async_client.py @@ -45,9 +45,46 @@ class EventServiceAsyncClient: DEFAULT_ENDPOINT = EventServiceClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = EventServiceClient.DEFAULT_MTLS_ENDPOINT + tenant_path = staticmethod(EventServiceClient.tenant_path) + parse_tenant_path = staticmethod(EventServiceClient.parse_tenant_path) + + common_billing_account_path = staticmethod( + EventServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + EventServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(EventServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(EventServiceClient.parse_common_folder_path) + + common_organization_path = staticmethod(EventServiceClient.common_organization_path) + parse_common_organization_path = staticmethod( + EventServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(EventServiceClient.common_project_path) + parse_common_project_path = staticmethod( + EventServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(EventServiceClient.common_location_path) + parse_common_location_path = staticmethod( + EventServiceClient.parse_common_location_path + ) + from_service_account_file = EventServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> EventServiceTransport: + """Return the transport used by the client instance. + + Returns: + EventServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(EventServiceClient).get_transport_class, type(EventServiceClient) ) @@ -162,7 +199,8 @@ async def create_client_event( # 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, client_event]): + has_flattened_params = any([parent, client_event]) + 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/talent_v4/services/event_service/client.py b/google/cloud/talent_v4/services/event_service/client.py index cc9aaed5..06f1fd4f 100644 --- a/google/cloud/talent_v4/services/event_service/client.py +++ b/google/cloud/talent_v4/services/event_service/client.py @@ -129,6 +129,87 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> EventServiceTransport: + """Return the transport used by the client instance. + + Returns: + EventServiceTransport: The transport used by the client instance. + """ + return self._transport + + @staticmethod + def tenant_path(project: str, tenant: str,) -> str: + """Return a fully-qualified tenant string.""" + return "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + + @staticmethod + def parse_tenant_path(path: str) -> Dict[str, str]: + """Parse a tenant path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/tenants/(?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, *, @@ -164,10 +245,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: diff --git a/google/cloud/talent_v4/services/event_service/transports/__init__.py b/google/cloud/talent_v4/services/event_service/transports/__init__.py index 18ca2a9d..c7dabde5 100644 --- a/google/cloud/talent_v4/services/event_service/transports/__init__.py +++ b/google/cloud/talent_v4/services/event_service/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = EventServiceGrpcTransport _transport_registry["grpc_asyncio"] = EventServiceGrpcAsyncIOTransport - __all__ = ( "EventServiceTransport", "EventServiceGrpcTransport", diff --git a/google/cloud/talent_v4/services/event_service/transports/grpc.py b/google/cloud/talent_v4/services/event_service/transports/grpc.py index 77b026c2..c6dfa670 100644 --- a/google/cloud/talent_v4/services/event_service/transports/grpc.py +++ b/google/cloud/talent_v4/services/event_service/transports/grpc.py @@ -90,10 +90,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: @@ -102,6 +102,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. @@ -109,6 +111,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", @@ -144,7 +147,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -161,6 +169,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -187,7 +199,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -222,12 +234,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/talent_v4/services/event_service/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py index e79b22ae..38de85b0 100644 --- a/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py @@ -147,6 +147,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. @@ -154,6 +156,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", @@ -189,7 +192,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -206,6 +214,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4/services/job_service/async_client.py b/google/cloud/talent_v4/services/job_service/async_client.py index d0039885..ec420503 100644 --- a/google/cloud/talent_v4/services/job_service/async_client.py +++ b/google/cloud/talent_v4/services/job_service/async_client.py @@ -54,12 +54,48 @@ class JobServiceAsyncClient: DEFAULT_ENDPOINT = JobServiceClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = JobServiceClient.DEFAULT_MTLS_ENDPOINT + company_path = staticmethod(JobServiceClient.company_path) + parse_company_path = staticmethod(JobServiceClient.parse_company_path) job_path = staticmethod(JobServiceClient.job_path) parse_job_path = staticmethod(JobServiceClient.parse_job_path) + tenant_path = staticmethod(JobServiceClient.tenant_path) + parse_tenant_path = staticmethod(JobServiceClient.parse_tenant_path) + + common_billing_account_path = staticmethod( + JobServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + JobServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(JobServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(JobServiceClient.parse_common_folder_path) + + common_organization_path = staticmethod(JobServiceClient.common_organization_path) + parse_common_organization_path = staticmethod( + JobServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(JobServiceClient.common_project_path) + parse_common_project_path = staticmethod(JobServiceClient.parse_common_project_path) + + common_location_path = staticmethod(JobServiceClient.common_location_path) + parse_common_location_path = staticmethod( + JobServiceClient.parse_common_location_path + ) from_service_account_file = JobServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> JobServiceTransport: + """Return the transport used by the client instance. + + Returns: + JobServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(JobServiceClient).get_transport_class, type(JobServiceClient) ) @@ -162,7 +198,8 @@ async def create_job( # 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, job]): + has_flattened_params = any([parent, job]) + 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." @@ -253,7 +290,8 @@ async def batch_create_jobs( # 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, jobs]): + has_flattened_params = any([parent, jobs]) + 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." @@ -266,8 +304,9 @@ async def batch_create_jobs( if parent is not None: request.parent = parent - if jobs is not None: - request.jobs = jobs + + if jobs: + request.jobs.extend(jobs) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -339,7 +378,8 @@ async def get_job( # 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." @@ -362,7 +402,7 @@ async def get_job( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -437,7 +477,8 @@ async def update_job( # 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([job, update_mask]): + has_flattened_params = any([job, 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." @@ -528,7 +569,8 @@ async def batch_update_jobs( # 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, jobs]): + has_flattened_params = any([parent, jobs]) + 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." @@ -541,8 +583,9 @@ async def batch_update_jobs( if parent is not None: request.parent = parent - if jobs is not None: - request.jobs = jobs + + if jobs: + request.jobs.extend(jobs) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -607,7 +650,8 @@ async def delete_job( # 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." @@ -630,7 +674,7 @@ async def delete_job( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -710,7 +754,8 @@ async def batch_delete_jobs( # 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, names]): + has_flattened_params = any([parent, names]) + 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." @@ -723,8 +768,9 @@ async def batch_delete_jobs( if parent is not None: request.parent = parent - if names is not None: - request.names = names + + if names: + request.names.extend(names) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -823,7 +869,8 @@ async def list_jobs( # 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, filter]): + has_flattened_params = any([parent, filter]) + 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 +895,7 @@ async def list_jobs( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4/services/job_service/client.py b/google/cloud/talent_v4/services/job_service/client.py index 0bb4a4e9..0e8ec2b0 100644 --- a/google/cloud/talent_v4/services/job_service/client.py +++ b/google/cloud/talent_v4/services/job_service/client.py @@ -138,6 +138,31 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> JobServiceTransport: + """Return the transport used by the client instance. + + Returns: + JobServiceTransport: The transport used by the client instance. + """ + return self._transport + + @staticmethod + def company_path(project: str, tenant: str, company: str,) -> str: + """Return a fully-qualified company string.""" + return "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + + @staticmethod + def parse_company_path(path: str) -> Dict[str, str]: + """Parse a company path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/tenants/(?P.+?)/companies/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def job_path(project: str, tenant: str, job: str,) -> str: """Return a fully-qualified job string.""" @@ -154,6 +179,78 @@ def parse_job_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def tenant_path(project: str, tenant: str,) -> str: + """Return a fully-qualified tenant string.""" + return "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + + @staticmethod + def parse_tenant_path(path: str) -> Dict[str, str]: + """Parse a tenant path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/tenants/(?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, *, @@ -189,10 +286,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: @@ -433,8 +530,9 @@ def batch_create_jobs( if parent is not None: request.parent = parent - if jobs is not None: - request.jobs = jobs + + if jobs: + request.jobs.extend(jobs) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -706,8 +804,9 @@ def batch_update_jobs( if parent is not None: request.parent = parent - if jobs is not None: - request.jobs = jobs + + if jobs: + request.jobs.extend(jobs) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -884,8 +983,9 @@ def batch_delete_jobs( if parent is not None: request.parent = parent - if names is not None: - request.names = names + + if names: + request.names.extend(names) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. diff --git a/google/cloud/talent_v4/services/job_service/transports/__init__.py b/google/cloud/talent_v4/services/job_service/transports/__init__.py index ca4d929c..349bfbcd 100644 --- a/google/cloud/talent_v4/services/job_service/transports/__init__.py +++ b/google/cloud/talent_v4/services/job_service/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = JobServiceGrpcTransport _transport_registry["grpc_asyncio"] = JobServiceGrpcAsyncIOTransport - __all__ = ( "JobServiceTransport", "JobServiceGrpcTransport", diff --git a/google/cloud/talent_v4/services/job_service/transports/base.py b/google/cloud/talent_v4/services/job_service/transports/base.py index c5256160..37a4781f 100644 --- a/google/cloud/talent_v4/services/job_service/transports/base.py +++ b/google/cloud/talent_v4/services/job_service/transports/base.py @@ -125,7 +125,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -144,7 +144,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -160,7 +160,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4/services/job_service/transports/grpc.py b/google/cloud/talent_v4/services/job_service/transports/grpc.py index a8a82f6a..9f8ddd1e 100644 --- a/google/cloud/talent_v4/services/job_service/transports/grpc.py +++ b/google/cloud/talent_v4/services/job_service/transports/grpc.py @@ -95,10 +95,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: @@ -107,6 +107,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. @@ -114,6 +116,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", @@ -149,7 +152,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -166,9 +174,14 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] + self._operations_client = None # Run the base constructor. super().__init__( @@ -192,7 +205,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -227,12 +240,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 @@ -243,13 +252,11 @@ def operations_client(self) -> operations_v1.OperationsClient: client. """ # Sanity check: Only create a new client if we do not already have one. - if "operations_client" not in self.__dict__: - self.__dict__["operations_client"] = operations_v1.OperationsClient( - self.grpc_channel - ) + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient(self.grpc_channel) # Return the client from cache. - return self.__dict__["operations_client"] + return self._operations_client @property def create_job(self) -> Callable[[job_service.CreateJobRequest], gct_job.Job]: diff --git a/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py index 90ccdde9..2a50e03c 100644 --- a/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py @@ -152,6 +152,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. @@ -159,6 +161,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", @@ -194,7 +197,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -211,6 +219,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. @@ -224,6 +236,7 @@ def __init__( ) self._stubs = {} + self._operations_client = None @property def grpc_channel(self) -> aio.Channel: @@ -243,13 +256,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: client. """ # Sanity check: Only create a new client if we do not already have one. - if "operations_client" not in self.__dict__: - self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient( + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel ) # Return the client from cache. - return self.__dict__["operations_client"] + return self._operations_client @property def create_job( diff --git a/google/cloud/talent_v4/services/tenant_service/async_client.py b/google/cloud/talent_v4/services/tenant_service/async_client.py index 5b57b42d..07940a99 100644 --- a/google/cloud/talent_v4/services/tenant_service/async_client.py +++ b/google/cloud/talent_v4/services/tenant_service/async_client.py @@ -52,9 +52,47 @@ class TenantServiceAsyncClient: tenant_path = staticmethod(TenantServiceClient.tenant_path) parse_tenant_path = staticmethod(TenantServiceClient.parse_tenant_path) + common_billing_account_path = staticmethod( + TenantServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + TenantServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(TenantServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + TenantServiceClient.parse_common_folder_path + ) + + common_organization_path = staticmethod( + TenantServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + TenantServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(TenantServiceClient.common_project_path) + parse_common_project_path = staticmethod( + TenantServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(TenantServiceClient.common_location_path) + parse_common_location_path = staticmethod( + TenantServiceClient.parse_common_location_path + ) + from_service_account_file = TenantServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> TenantServiceTransport: + """Return the transport used by the client instance. + + Returns: + TenantServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(TenantServiceClient).get_transport_class, type(TenantServiceClient) ) @@ -158,7 +196,8 @@ async def create_tenant( # 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, tenant]): + has_flattened_params = any([parent, tenant]) + 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." @@ -240,7 +279,8 @@ async def get_tenant( # 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." @@ -263,7 +303,7 @@ async def get_tenant( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -341,7 +381,8 @@ async def update_tenant( # 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([tenant, update_mask]): + has_flattened_params = any([tenant, 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." @@ -412,7 +453,8 @@ async def delete_tenant( # 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." @@ -435,7 +477,7 @@ async def delete_tenant( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -495,7 +537,8 @@ async def list_tenants( # 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." @@ -518,7 +561,7 @@ async def list_tenants( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4/services/tenant_service/client.py b/google/cloud/talent_v4/services/tenant_service/client.py index 09b14ba1..7492a9c3 100644 --- a/google/cloud/talent_v4/services/tenant_service/client.py +++ b/google/cloud/talent_v4/services/tenant_service/client.py @@ -133,6 +133,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> TenantServiceTransport: + """Return the transport used by the client instance. + + Returns: + TenantServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def tenant_path(project: str, tenant: str,) -> str: """Return a fully-qualified tenant string.""" @@ -146,6 +155,65 @@ def parse_tenant_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/tenants/(?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, *, @@ -181,10 +249,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: diff --git a/google/cloud/talent_v4/services/tenant_service/transports/__init__.py b/google/cloud/talent_v4/services/tenant_service/transports/__init__.py index 49abfaa7..27334b26 100644 --- a/google/cloud/talent_v4/services/tenant_service/transports/__init__.py +++ b/google/cloud/talent_v4/services/tenant_service/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = TenantServiceGrpcTransport _transport_registry["grpc_asyncio"] = TenantServiceGrpcAsyncIOTransport - __all__ = ( "TenantServiceTransport", "TenantServiceGrpcTransport", diff --git a/google/cloud/talent_v4/services/tenant_service/transports/base.py b/google/cloud/talent_v4/services/tenant_service/transports/base.py index a545754c..dee8e4f0 100644 --- a/google/cloud/talent_v4/services/tenant_service/transports/base.py +++ b/google/cloud/talent_v4/services/tenant_service/transports/base.py @@ -120,7 +120,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -136,7 +136,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4/services/tenant_service/transports/grpc.py b/google/cloud/talent_v4/services/tenant_service/transports/grpc.py index acdf8307..f6ff6185 100644 --- a/google/cloud/talent_v4/services/tenant_service/transports/grpc.py +++ b/google/cloud/talent_v4/services/tenant_service/transports/grpc.py @@ -93,10 +93,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: @@ -105,6 +105,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. @@ -112,6 +114,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", @@ -147,7 +150,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -164,6 +172,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -190,7 +202,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -225,12 +237,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/talent_v4/services/tenant_service/transports/grpc_asyncio.py b/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py index 9624c5b7..dac79077 100644 --- a/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py @@ -150,6 +150,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. @@ -157,6 +159,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", @@ -192,7 +195,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -209,6 +217,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4/types/__init__.py b/google/cloud/talent_v4/types/__init__.py index 7e2f5b87..faf71c78 100644 --- a/google/cloud/talent_v4/types/__init__.py +++ b/google/cloud/talent_v4/types/__init__.py @@ -25,6 +25,16 @@ SpellingCorrection, CompensationInfo, BatchOperationMetadata, + CompanySize, + JobBenefit, + DegreeType, + EmploymentType, + JobLevel, + JobCategory, + PostingRegion, + Visibility, + HtmlSanitization, + CommuteMethod, ) from .company import Company from .company_service import ( @@ -71,6 +81,7 @@ BatchCreateJobsResponse, BatchUpdateJobsResponse, BatchDeleteJobsResponse, + JobView, ) from .tenant import Tenant from .tenant_service import ( @@ -82,7 +93,6 @@ ListTenantsResponse, ) - __all__ = ( "TimestampRange", "Location", @@ -93,6 +103,16 @@ "SpellingCorrection", "CompensationInfo", "BatchOperationMetadata", + "CompanySize", + "JobBenefit", + "DegreeType", + "EmploymentType", + "JobLevel", + "JobCategory", + "PostingRegion", + "Visibility", + "HtmlSanitization", + "CommuteMethod", "Company", "CreateCompanyRequest", "GetCompanyRequest", @@ -127,6 +147,7 @@ "BatchCreateJobsResponse", "BatchUpdateJobsResponse", "BatchDeleteJobsResponse", + "JobView", "Tenant", "CreateTenantRequest", "GetTenantRequest", diff --git a/google/cloud/talent_v4/types/completion_service.py b/google/cloud/talent_v4/types/completion_service.py index 1e25c9a9..ba2529b2 100644 --- a/google/cloud/talent_v4/types/completion_service.py +++ b/google/cloud/talent_v4/types/completion_service.py @@ -121,7 +121,7 @@ class CompletionResult(proto.Message): suggestion = proto.Field(proto.STRING, number=1) type_ = proto.Field( - proto.ENUM, number=2, enum=CompleteQueryRequest.CompletionType, + proto.ENUM, number=2, enum="CompleteQueryRequest.CompletionType", ) image_uri = proto.Field(proto.STRING, number=3) diff --git a/google/cloud/talent_v4/types/job_service.py b/google/cloud/talent_v4/types/job_service.py index 4a1b765a..4b53ed10 100644 --- a/google/cloud/talent_v4/types/job_service.py +++ b/google/cloud/talent_v4/types/job_service.py @@ -883,7 +883,7 @@ class BatchCreateJobsResponse(proto.Message): status is FINISHED, FAILED or CANCELLED. """ - job_results = proto.RepeatedField(proto.MESSAGE, number=1, message=JobResult,) + job_results = proto.RepeatedField(proto.MESSAGE, number=1, message="JobResult",) class BatchUpdateJobsResponse(proto.Message): @@ -900,7 +900,7 @@ class BatchUpdateJobsResponse(proto.Message): status is FINISHED, FAILED or CANCELLED. """ - job_results = proto.RepeatedField(proto.MESSAGE, number=1, message=JobResult,) + job_results = proto.RepeatedField(proto.MESSAGE, number=1, message="JobResult",) class BatchDeleteJobsResponse(proto.Message): @@ -917,7 +917,7 @@ class BatchDeleteJobsResponse(proto.Message): status is FINISHED, FAILED or CANCELLED. """ - job_results = proto.RepeatedField(proto.MESSAGE, number=1, message=JobResult,) + job_results = proto.RepeatedField(proto.MESSAGE, number=1, message="JobResult",) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/talent_v4beta1/__init__.py b/google/cloud/talent_v4beta1/__init__.py index 4743ac58..9494115b 100644 --- a/google/cloud/talent_v4beta1/__init__.py +++ b/google/cloud/talent_v4beta1/__init__.py @@ -143,7 +143,6 @@ "ApplicationDateFilter", "ApplicationJobFilter", "ApplicationOutcomeNotesFilter", - "ApplicationServiceClient", "AvailabilityFilter", "AvailabilitySignal", "AvailabilitySignalType", @@ -244,6 +243,7 @@ "SpellingCorrection", "SummarizedProfile", "Tenant", + "TenantServiceClient", "TimeFilter", "TimestampRange", "UpdateApplicationRequest", @@ -253,5 +253,5 @@ "UpdateTenantRequest", "Visibility", "WorkExperienceFilter", - "TenantServiceClient", + "ApplicationServiceClient", ) diff --git a/google/cloud/talent_v4beta1/services/application_service/async_client.py b/google/cloud/talent_v4beta1/services/application_service/async_client.py index 1dd27354..8236846b 100644 --- a/google/cloud/talent_v4beta1/services/application_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/application_service/async_client.py @@ -56,10 +56,54 @@ class ApplicationServiceAsyncClient: parse_application_path = staticmethod( ApplicationServiceClient.parse_application_path ) + company_path = staticmethod(ApplicationServiceClient.company_path) + parse_company_path = staticmethod(ApplicationServiceClient.parse_company_path) + job_path = staticmethod(ApplicationServiceClient.job_path) + parse_job_path = staticmethod(ApplicationServiceClient.parse_job_path) + profile_path = staticmethod(ApplicationServiceClient.profile_path) + parse_profile_path = staticmethod(ApplicationServiceClient.parse_profile_path) + + common_billing_account_path = staticmethod( + ApplicationServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + ApplicationServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(ApplicationServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + ApplicationServiceClient.parse_common_folder_path + ) + + common_organization_path = staticmethod( + ApplicationServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + ApplicationServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(ApplicationServiceClient.common_project_path) + parse_common_project_path = staticmethod( + ApplicationServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(ApplicationServiceClient.common_location_path) + parse_common_location_path = staticmethod( + ApplicationServiceClient.parse_common_location_path + ) from_service_account_file = ApplicationServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> ApplicationServiceTransport: + """Return the transport used by the client instance. + + Returns: + ApplicationServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(ApplicationServiceClient).get_transport_class, type(ApplicationServiceClient), @@ -161,7 +205,8 @@ async def create_application( # 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, application]): + has_flattened_params = any([parent, application]) + 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." @@ -239,7 +284,8 @@ async def get_application( # 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." @@ -319,7 +365,8 @@ async def update_application( # 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([application]): + has_flattened_params = any([application]) + 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." @@ -390,7 +437,8 @@ async def delete_application( # 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." @@ -475,7 +523,8 @@ async def list_applications( # 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." diff --git a/google/cloud/talent_v4beta1/services/application_service/client.py b/google/cloud/talent_v4beta1/services/application_service/client.py index 451c12bd..b8204de1 100644 --- a/google/cloud/talent_v4beta1/services/application_service/client.py +++ b/google/cloud/talent_v4beta1/services/application_service/client.py @@ -140,6 +140,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> ApplicationServiceTransport: + """Return the transport used by the client instance. + + Returns: + ApplicationServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def application_path( project: str, tenant: str, profile: str, application: str, @@ -158,6 +167,113 @@ def parse_application_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def company_path(project: str, tenant: str, company: str,) -> str: + """Return a fully-qualified company string.""" + return "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + + @staticmethod + def parse_company_path(path: str) -> Dict[str, str]: + """Parse a company path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/tenants/(?P.+?)/companies/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def job_path(project: str, tenant: str, job: str,) -> str: + """Return a fully-qualified job string.""" + return "projects/{project}/tenants/{tenant}/jobs/{job}".format( + project=project, tenant=tenant, job=job, + ) + + @staticmethod + def parse_job_path(path: str) -> Dict[str, str]: + """Parse a job path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/tenants/(?P.+?)/jobs/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + + @staticmethod + def profile_path(project: str, tenant: str, profile: str,) -> str: + """Return a fully-qualified profile string.""" + return "projects/{project}/tenants/{tenant}/profiles/{profile}".format( + project=project, tenant=tenant, profile=profile, + ) + + @staticmethod + def parse_profile_path(path: str) -> Dict[str, str]: + """Parse a profile path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/tenants/(?P.+?)/profiles/(?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, *, @@ -193,10 +309,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: diff --git a/google/cloud/talent_v4beta1/services/application_service/transports/__init__.py b/google/cloud/talent_v4beta1/services/application_service/transports/__init__.py index ef4ac910..b8633539 100644 --- a/google/cloud/talent_v4beta1/services/application_service/transports/__init__.py +++ b/google/cloud/talent_v4beta1/services/application_service/transports/__init__.py @@ -30,7 +30,6 @@ _transport_registry["grpc"] = ApplicationServiceGrpcTransport _transport_registry["grpc_asyncio"] = ApplicationServiceGrpcAsyncIOTransport - __all__ = ( "ApplicationServiceTransport", "ApplicationServiceGrpcTransport", diff --git a/google/cloud/talent_v4beta1/services/application_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/application_service/transports/grpc.py index 44696413..07e17b28 100644 --- a/google/cloud/talent_v4beta1/services/application_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/application_service/transports/grpc.py @@ -93,10 +93,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: @@ -105,6 +105,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. @@ -112,6 +114,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", @@ -147,7 +150,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -164,6 +172,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -190,7 +202,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -225,12 +237,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/talent_v4beta1/services/application_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/application_service/transports/grpc_asyncio.py index 9e466530..0727f683 100644 --- a/google/cloud/talent_v4beta1/services/application_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/application_service/transports/grpc_asyncio.py @@ -150,6 +150,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. @@ -157,6 +159,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", @@ -192,7 +195,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -209,6 +217,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4beta1/services/company_service/async_client.py b/google/cloud/talent_v4beta1/services/company_service/async_client.py index a26d1475..98c39a8e 100644 --- a/google/cloud/talent_v4beta1/services/company_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/company_service/async_client.py @@ -52,9 +52,47 @@ class CompanyServiceAsyncClient: company_path = staticmethod(CompanyServiceClient.company_path) parse_company_path = staticmethod(CompanyServiceClient.parse_company_path) + common_billing_account_path = staticmethod( + CompanyServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + CompanyServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(CompanyServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + CompanyServiceClient.parse_common_folder_path + ) + + common_organization_path = staticmethod( + CompanyServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + CompanyServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(CompanyServiceClient.common_project_path) + parse_common_project_path = staticmethod( + CompanyServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(CompanyServiceClient.common_location_path) + parse_common_location_path = staticmethod( + CompanyServiceClient.parse_common_location_path + ) + from_service_account_file = CompanyServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> CompanyServiceTransport: + """Return the transport used by the client instance. + + Returns: + CompanyServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(CompanyServiceClient).get_transport_class, type(CompanyServiceClient) ) @@ -160,7 +198,8 @@ async def create_company( # 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, company]): + has_flattened_params = any([parent, company]) + 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." @@ -245,7 +284,8 @@ async def get_company( # 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." @@ -329,7 +369,8 @@ async def update_company( # 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([company]): + has_flattened_params = any([company]) + 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." @@ -404,7 +445,8 @@ async def delete_company( # 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." @@ -491,7 +533,8 @@ async def list_companies( # 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." diff --git a/google/cloud/talent_v4beta1/services/company_service/client.py b/google/cloud/talent_v4beta1/services/company_service/client.py index b180385e..e4638852 100644 --- a/google/cloud/talent_v4beta1/services/company_service/client.py +++ b/google/cloud/talent_v4beta1/services/company_service/client.py @@ -135,6 +135,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> CompanyServiceTransport: + """Return the transport used by the client instance. + + Returns: + CompanyServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def company_path(project: str, tenant: str, company: str,) -> str: """Return a fully-qualified company string.""" @@ -151,6 +160,65 @@ def parse_company_path(path: str) -> Dict[str, str]: ) 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, *, @@ -186,10 +254,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: diff --git a/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py b/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py index ad1eb728..51e34763 100644 --- a/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py +++ b/google/cloud/talent_v4beta1/services/company_service/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = CompanyServiceGrpcTransport _transport_registry["grpc_asyncio"] = CompanyServiceGrpcAsyncIOTransport - __all__ = ( "CompanyServiceTransport", "CompanyServiceGrpcTransport", diff --git a/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py index 47b84500..4c833246 100644 --- a/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/company_service/transports/grpc.py @@ -93,10 +93,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: @@ -105,6 +105,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. @@ -112,6 +114,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", @@ -147,7 +150,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -164,6 +172,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -190,7 +202,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -225,12 +237,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/talent_v4beta1/services/company_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py index 9806cd0a..79a1d5fd 100644 --- a/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py @@ -150,6 +150,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. @@ -157,6 +159,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", @@ -192,7 +195,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -209,6 +217,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4beta1/services/completion/async_client.py b/google/cloud/talent_v4beta1/services/completion/async_client.py index 7c46b2c7..40da92eb 100644 --- a/google/cloud/talent_v4beta1/services/completion/async_client.py +++ b/google/cloud/talent_v4beta1/services/completion/async_client.py @@ -44,9 +44,44 @@ class CompletionAsyncClient: DEFAULT_ENDPOINT = CompletionClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = CompletionClient.DEFAULT_MTLS_ENDPOINT + company_path = staticmethod(CompletionClient.company_path) + parse_company_path = staticmethod(CompletionClient.parse_company_path) + + common_billing_account_path = staticmethod( + CompletionClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + CompletionClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(CompletionClient.common_folder_path) + parse_common_folder_path = staticmethod(CompletionClient.parse_common_folder_path) + + common_organization_path = staticmethod(CompletionClient.common_organization_path) + parse_common_organization_path = staticmethod( + CompletionClient.parse_common_organization_path + ) + + common_project_path = staticmethod(CompletionClient.common_project_path) + parse_common_project_path = staticmethod(CompletionClient.parse_common_project_path) + + common_location_path = staticmethod(CompletionClient.common_location_path) + parse_common_location_path = staticmethod( + CompletionClient.parse_common_location_path + ) + from_service_account_file = CompletionClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> CompletionTransport: + """Return the transport used by the client instance. + + Returns: + CompletionTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(CompletionClient).get_transport_class, type(CompletionClient) ) diff --git a/google/cloud/talent_v4beta1/services/completion/client.py b/google/cloud/talent_v4beta1/services/completion/client.py index 21fa1335..f01febaf 100644 --- a/google/cloud/talent_v4beta1/services/completion/client.py +++ b/google/cloud/talent_v4beta1/services/completion/client.py @@ -128,6 +128,90 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> CompletionTransport: + """Return the transport used by the client instance. + + Returns: + CompletionTransport: The transport used by the client instance. + """ + return self._transport + + @staticmethod + def company_path(project: str, tenant: str, company: str,) -> str: + """Return a fully-qualified company string.""" + return "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + + @staticmethod + def parse_company_path(path: str) -> Dict[str, str]: + """Parse a company path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/tenants/(?P.+?)/companies/(?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, *, @@ -163,10 +247,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: diff --git a/google/cloud/talent_v4beta1/services/completion/transports/__init__.py b/google/cloud/talent_v4beta1/services/completion/transports/__init__.py index 9256febd..df284f3e 100644 --- a/google/cloud/talent_v4beta1/services/completion/transports/__init__.py +++ b/google/cloud/talent_v4beta1/services/completion/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = CompletionGrpcTransport _transport_registry["grpc_asyncio"] = CompletionGrpcAsyncIOTransport - __all__ = ( "CompletionTransport", "CompletionGrpcTransport", diff --git a/google/cloud/talent_v4beta1/services/completion/transports/grpc.py b/google/cloud/talent_v4beta1/services/completion/transports/grpc.py index 9661fd31..086da12a 100644 --- a/google/cloud/talent_v4beta1/services/completion/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/completion/transports/grpc.py @@ -89,10 +89,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: @@ -101,6 +101,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. @@ -108,6 +110,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", @@ -143,7 +146,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -160,6 +168,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -186,7 +198,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -221,12 +233,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/talent_v4beta1/services/completion/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py index a47bd5d1..fa49dda0 100644 --- a/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py @@ -146,6 +146,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. @@ -153,6 +155,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", @@ -188,7 +191,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -205,6 +213,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4beta1/services/event_service/async_client.py b/google/cloud/talent_v4beta1/services/event_service/async_client.py index 2404be11..553aed17 100644 --- a/google/cloud/talent_v4beta1/services/event_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/event_service/async_client.py @@ -45,9 +45,46 @@ class EventServiceAsyncClient: DEFAULT_ENDPOINT = EventServiceClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = EventServiceClient.DEFAULT_MTLS_ENDPOINT + company_path = staticmethod(EventServiceClient.company_path) + parse_company_path = staticmethod(EventServiceClient.parse_company_path) + + common_billing_account_path = staticmethod( + EventServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + EventServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(EventServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(EventServiceClient.parse_common_folder_path) + + common_organization_path = staticmethod(EventServiceClient.common_organization_path) + parse_common_organization_path = staticmethod( + EventServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(EventServiceClient.common_project_path) + parse_common_project_path = staticmethod( + EventServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(EventServiceClient.common_location_path) + parse_common_location_path = staticmethod( + EventServiceClient.parse_common_location_path + ) + from_service_account_file = EventServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> EventServiceTransport: + """Return the transport used by the client instance. + + Returns: + EventServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(EventServiceClient).get_transport_class, type(EventServiceClient) ) @@ -164,7 +201,8 @@ async def create_client_event( # 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, client_event]): + has_flattened_params = any([parent, client_event]) + 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/talent_v4beta1/services/event_service/client.py b/google/cloud/talent_v4beta1/services/event_service/client.py index fc49c064..21204729 100644 --- a/google/cloud/talent_v4beta1/services/event_service/client.py +++ b/google/cloud/talent_v4beta1/services/event_service/client.py @@ -129,6 +129,90 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> EventServiceTransport: + """Return the transport used by the client instance. + + Returns: + EventServiceTransport: The transport used by the client instance. + """ + return self._transport + + @staticmethod + def company_path(project: str, tenant: str, company: str,) -> str: + """Return a fully-qualified company string.""" + return "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + + @staticmethod + def parse_company_path(path: str) -> Dict[str, str]: + """Parse a company path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/tenants/(?P.+?)/companies/(?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, *, @@ -164,10 +248,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: diff --git a/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py b/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py index 18ca2a9d..c7dabde5 100644 --- a/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py +++ b/google/cloud/talent_v4beta1/services/event_service/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = EventServiceGrpcTransport _transport_registry["grpc_asyncio"] = EventServiceGrpcAsyncIOTransport - __all__ = ( "EventServiceTransport", "EventServiceGrpcTransport", diff --git a/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py index e870b468..5b8edccd 100644 --- a/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/event_service/transports/grpc.py @@ -90,10 +90,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: @@ -102,6 +102,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. @@ -109,6 +111,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", @@ -144,7 +147,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -161,6 +169,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -187,7 +199,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -222,12 +234,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/talent_v4beta1/services/event_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py index c2400f5d..6a4cbe75 100644 --- a/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py @@ -147,6 +147,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. @@ -154,6 +156,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", @@ -189,7 +192,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -206,6 +214,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4beta1/services/job_service/async_client.py b/google/cloud/talent_v4beta1/services/job_service/async_client.py index ec355cf2..a5ad40c6 100644 --- a/google/cloud/talent_v4beta1/services/job_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/job_service/async_client.py @@ -52,12 +52,46 @@ class JobServiceAsyncClient: DEFAULT_ENDPOINT = JobServiceClient.DEFAULT_ENDPOINT DEFAULT_MTLS_ENDPOINT = JobServiceClient.DEFAULT_MTLS_ENDPOINT + company_path = staticmethod(JobServiceClient.company_path) + parse_company_path = staticmethod(JobServiceClient.parse_company_path) job_path = staticmethod(JobServiceClient.job_path) parse_job_path = staticmethod(JobServiceClient.parse_job_path) + common_billing_account_path = staticmethod( + JobServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + JobServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(JobServiceClient.common_folder_path) + parse_common_folder_path = staticmethod(JobServiceClient.parse_common_folder_path) + + common_organization_path = staticmethod(JobServiceClient.common_organization_path) + parse_common_organization_path = staticmethod( + JobServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(JobServiceClient.common_project_path) + parse_common_project_path = staticmethod(JobServiceClient.parse_common_project_path) + + common_location_path = staticmethod(JobServiceClient.common_location_path) + parse_common_location_path = staticmethod( + JobServiceClient.parse_common_location_path + ) + from_service_account_file = JobServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> JobServiceTransport: + """Return the transport used by the client instance. + + Returns: + JobServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(JobServiceClient).get_transport_class, type(JobServiceClient) ) @@ -163,7 +197,8 @@ async def create_job( # 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, job]): + has_flattened_params = any([parent, job]) + 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." @@ -256,7 +291,8 @@ async def batch_create_jobs( # 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, jobs]): + has_flattened_params = any([parent, jobs]) + 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." @@ -269,8 +305,9 @@ async def batch_create_jobs( if parent is not None: request.parent = parent - if jobs is not None: - request.jobs = jobs + + if jobs: + request.jobs.extend(jobs) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -346,7 +383,8 @@ async def get_job( # 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." @@ -429,7 +467,8 @@ async def update_job( # 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([job]): + has_flattened_params = any([job]) + 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." @@ -520,7 +559,8 @@ async def batch_update_jobs( # 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, jobs]): + has_flattened_params = any([parent, jobs]) + 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." @@ -533,8 +573,9 @@ async def batch_update_jobs( if parent is not None: request.parent = parent - if jobs is not None: - request.jobs = jobs + + if jobs: + request.jobs.extend(jobs) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -602,7 +643,8 @@ async def delete_job( # 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." @@ -697,7 +739,8 @@ async def batch_delete_jobs( # 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, filter]): + has_flattened_params = any([parent, filter]) + 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." @@ -803,7 +846,8 @@ async def list_jobs( # 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, filter]): + has_flattened_params = any([parent, filter]) + 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/talent_v4beta1/services/job_service/client.py b/google/cloud/talent_v4beta1/services/job_service/client.py index bbcd5035..726b75ae 100644 --- a/google/cloud/talent_v4beta1/services/job_service/client.py +++ b/google/cloud/talent_v4beta1/services/job_service/client.py @@ -136,6 +136,31 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> JobServiceTransport: + """Return the transport used by the client instance. + + Returns: + JobServiceTransport: The transport used by the client instance. + """ + return self._transport + + @staticmethod + def company_path(project: str, tenant: str, company: str,) -> str: + """Return a fully-qualified company string.""" + return "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + + @staticmethod + def parse_company_path(path: str) -> Dict[str, str]: + """Parse a company path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/tenants/(?P.+?)/companies/(?P.+?)$", + path, + ) + return m.groupdict() if m else {} + @staticmethod def job_path(project: str, tenant: str, job: str,) -> str: """Return a fully-qualified job string.""" @@ -152,6 +177,65 @@ def parse_job_path(path: str) -> Dict[str, str]: ) 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, *, @@ -187,10 +271,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: @@ -436,8 +520,9 @@ def batch_create_jobs( if parent is not None: request.parent = parent - if jobs is not None: - request.jobs = jobs + + if jobs: + request.jobs.extend(jobs) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -698,8 +783,9 @@ def batch_update_jobs( if parent is not None: request.parent = parent - if jobs is not None: - request.jobs = jobs + + if jobs: + request.jobs.extend(jobs) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. diff --git a/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py b/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py index ca4d929c..349bfbcd 100644 --- a/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py +++ b/google/cloud/talent_v4beta1/services/job_service/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = JobServiceGrpcTransport _transport_registry["grpc_asyncio"] = JobServiceGrpcAsyncIOTransport - __all__ = ( "JobServiceTransport", "JobServiceGrpcTransport", diff --git a/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py index b1113951..c3526f6f 100644 --- a/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/job_service/transports/grpc.py @@ -95,10 +95,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: @@ -107,6 +107,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. @@ -114,6 +116,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", @@ -149,7 +152,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -166,9 +174,14 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] + self._operations_client = None # Run the base constructor. super().__init__( @@ -192,7 +205,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -227,12 +240,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 @@ -243,13 +252,11 @@ def operations_client(self) -> operations_v1.OperationsClient: client. """ # Sanity check: Only create a new client if we do not already have one. - if "operations_client" not in self.__dict__: - self.__dict__["operations_client"] = operations_v1.OperationsClient( - self.grpc_channel - ) + if self._operations_client is None: + self._operations_client = operations_v1.OperationsClient(self.grpc_channel) # Return the client from cache. - return self.__dict__["operations_client"] + return self._operations_client @property def create_job(self) -> Callable[[job_service.CreateJobRequest], gct_job.Job]: diff --git a/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py index 0da963e3..794df7cf 100644 --- a/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py @@ -152,6 +152,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. @@ -159,6 +161,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", @@ -194,7 +197,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -211,6 +219,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. @@ -224,6 +236,7 @@ def __init__( ) self._stubs = {} + self._operations_client = None @property def grpc_channel(self) -> aio.Channel: @@ -243,13 +256,13 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: client. """ # Sanity check: Only create a new client if we do not already have one. - if "operations_client" not in self.__dict__: - self.__dict__["operations_client"] = operations_v1.OperationsAsyncClient( + if self._operations_client is None: + self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel ) # Return the client from cache. - return self.__dict__["operations_client"] + return self._operations_client @property def create_job( diff --git a/google/cloud/talent_v4beta1/services/profile_service/async_client.py b/google/cloud/talent_v4beta1/services/profile_service/async_client.py index 6f039380..914e2bf4 100644 --- a/google/cloud/talent_v4beta1/services/profile_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/profile_service/async_client.py @@ -54,10 +54,50 @@ class ProfileServiceAsyncClient: profile_path = staticmethod(ProfileServiceClient.profile_path) parse_profile_path = staticmethod(ProfileServiceClient.parse_profile_path) + tenant_path = staticmethod(ProfileServiceClient.tenant_path) + parse_tenant_path = staticmethod(ProfileServiceClient.parse_tenant_path) + + common_billing_account_path = staticmethod( + ProfileServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + ProfileServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(ProfileServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + ProfileServiceClient.parse_common_folder_path + ) + + common_organization_path = staticmethod( + ProfileServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + ProfileServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(ProfileServiceClient.common_project_path) + parse_common_project_path = staticmethod( + ProfileServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(ProfileServiceClient.common_location_path) + parse_common_location_path = staticmethod( + ProfileServiceClient.parse_common_location_path + ) from_service_account_file = ProfileServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> ProfileServiceTransport: + """Return the transport used by the client instance. + + Returns: + ProfileServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(ProfileServiceClient).get_transport_class, type(ProfileServiceClient) ) @@ -152,7 +192,8 @@ async def list_profiles( # 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." @@ -248,7 +289,8 @@ async def create_profile( # 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, profile]): + has_flattened_params = any([parent, profile]) + 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." @@ -325,7 +367,8 @@ async def get_profile( # 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." @@ -405,7 +448,8 @@ async def update_profile( # 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([profile]): + has_flattened_params = any([profile]) + 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." @@ -476,7 +520,8 @@ async def delete_profile( # 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/talent_v4beta1/services/profile_service/client.py b/google/cloud/talent_v4beta1/services/profile_service/client.py index 89579796..4cef4bba 100644 --- a/google/cloud/talent_v4beta1/services/profile_service/client.py +++ b/google/cloud/talent_v4beta1/services/profile_service/client.py @@ -138,6 +138,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> ProfileServiceTransport: + """Return the transport used by the client instance. + + Returns: + ProfileServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def profile_path(project: str, tenant: str, profile: str,) -> str: """Return a fully-qualified profile string.""" @@ -154,6 +163,78 @@ def parse_profile_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def tenant_path(project: str, tenant: str,) -> str: + """Return a fully-qualified tenant string.""" + return "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + + @staticmethod + def parse_tenant_path(path: str) -> Dict[str, str]: + """Parse a tenant path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/tenants/(?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, *, @@ -189,10 +270,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: diff --git a/google/cloud/talent_v4beta1/services/profile_service/transports/__init__.py b/google/cloud/talent_v4beta1/services/profile_service/transports/__init__.py index 940a2165..927f6ae0 100644 --- a/google/cloud/talent_v4beta1/services/profile_service/transports/__init__.py +++ b/google/cloud/talent_v4beta1/services/profile_service/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = ProfileServiceGrpcTransport _transport_registry["grpc_asyncio"] = ProfileServiceGrpcAsyncIOTransport - __all__ = ( "ProfileServiceTransport", "ProfileServiceGrpcTransport", diff --git a/google/cloud/talent_v4beta1/services/profile_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/profile_service/transports/grpc.py index 1c4965c0..a0a0da7e 100644 --- a/google/cloud/talent_v4beta1/services/profile_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/profile_service/transports/grpc.py @@ -93,10 +93,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: @@ -105,6 +105,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. @@ -112,6 +114,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", @@ -147,7 +150,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -164,6 +172,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -190,7 +202,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -225,12 +237,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/talent_v4beta1/services/profile_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/profile_service/transports/grpc_asyncio.py index 2a38ebf1..6db1ab4b 100644 --- a/google/cloud/talent_v4beta1/services/profile_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/profile_service/transports/grpc_asyncio.py @@ -150,6 +150,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. @@ -157,6 +159,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", @@ -192,7 +195,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -209,6 +217,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4beta1/services/tenant_service/async_client.py b/google/cloud/talent_v4beta1/services/tenant_service/async_client.py index b0f64fc3..be6fce85 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/async_client.py @@ -51,9 +51,47 @@ class TenantServiceAsyncClient: tenant_path = staticmethod(TenantServiceClient.tenant_path) parse_tenant_path = staticmethod(TenantServiceClient.parse_tenant_path) + common_billing_account_path = staticmethod( + TenantServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + TenantServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(TenantServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + TenantServiceClient.parse_common_folder_path + ) + + common_organization_path = staticmethod( + TenantServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + TenantServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(TenantServiceClient.common_project_path) + parse_common_project_path = staticmethod( + TenantServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(TenantServiceClient.common_location_path) + parse_common_location_path = staticmethod( + TenantServiceClient.parse_common_location_path + ) + from_service_account_file = TenantServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> TenantServiceTransport: + """Return the transport used by the client instance. + + Returns: + TenantServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(TenantServiceClient).get_transport_class, type(TenantServiceClient) ) @@ -157,7 +195,8 @@ async def create_tenant( # 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, tenant]): + has_flattened_params = any([parent, tenant]) + 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." @@ -239,7 +278,8 @@ async def get_tenant( # 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." @@ -324,7 +364,8 @@ async def update_tenant( # 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([tenant]): + has_flattened_params = any([tenant]) + 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." @@ -393,7 +434,8 @@ async def delete_tenant( # 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." @@ -476,7 +518,8 @@ async def list_tenants( # 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." diff --git a/google/cloud/talent_v4beta1/services/tenant_service/client.py b/google/cloud/talent_v4beta1/services/tenant_service/client.py index 401d2057..52898cda 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/client.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/client.py @@ -132,6 +132,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> TenantServiceTransport: + """Return the transport used by the client instance. + + Returns: + TenantServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def tenant_path(project: str, tenant: str,) -> str: """Return a fully-qualified tenant string.""" @@ -145,6 +154,65 @@ def parse_tenant_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/tenants/(?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, *, @@ -180,10 +248,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: diff --git a/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py b/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py index 49abfaa7..27334b26 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py @@ -28,7 +28,6 @@ _transport_registry["grpc"] = TenantServiceGrpcTransport _transport_registry["grpc_asyncio"] = TenantServiceGrpcAsyncIOTransport - __all__ = ( "TenantServiceTransport", "TenantServiceGrpcTransport", diff --git a/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py b/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py index a1a331df..eae306f9 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py @@ -93,10 +93,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: @@ -105,6 +105,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. @@ -112,6 +114,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", @@ -147,7 +150,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -164,6 +172,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) self._stubs = {} # type: Dict[str, Callable] @@ -190,7 +202,7 @@ def create_channel( ) -> grpc.Channel: """Create and return a gRPC channel object. Args: - address (Optionsl[str]): The host for the channel to use. + address (Optional[str]): The host for the channel to use. credentials (Optional[~.Credentials]): The authorization credentials to attach to requests. These credentials identify this application to the service. If @@ -225,12 +237,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/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py b/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py index b87d1e04..cec885b2 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py @@ -150,6 +150,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. @@ -157,6 +159,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", @@ -192,7 +195,12 @@ def __init__( ssl_credentials=ssl_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -209,6 +217,10 @@ def __init__( ssl_credentials=ssl_channel_credentials, scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) # Run the base constructor. diff --git a/google/cloud/talent_v4beta1/types/__init__.py b/google/cloud/talent_v4beta1/types/__init__.py index 34762e83..3d326265 100644 --- a/google/cloud/talent_v4beta1/types/__init__.py +++ b/google/cloud/talent_v4beta1/types/__init__.py @@ -29,6 +29,20 @@ Interview, Rating, BatchOperationMetadata, + CompanySize, + JobBenefit, + DegreeType, + EmploymentType, + JobLevel, + JobCategory, + PostingRegion, + Visibility, + ContactInfoUsage, + HtmlSanitization, + CommuteMethod, + SkillProficiencyLevel, + Outcome, + AvailabilitySignalType, ) from .application import Application from .application_service import ( @@ -95,6 +109,7 @@ BatchCreateJobsRequest, BatchUpdateJobsRequest, JobOperationResult, + JobView, ) from .profile import ( Profile, @@ -134,7 +149,6 @@ ListTenantsResponse, ) - __all__ = ( "TimestampRange", "Location", @@ -149,6 +163,20 @@ "Interview", "Rating", "BatchOperationMetadata", + "CompanySize", + "JobBenefit", + "DegreeType", + "EmploymentType", + "JobLevel", + "JobCategory", + "PostingRegion", + "Visibility", + "ContactInfoUsage", + "HtmlSanitization", + "CommuteMethod", + "SkillProficiencyLevel", + "Outcome", + "AvailabilitySignalType", "Application", "CreateApplicationRequest", "GetApplicationRequest", @@ -201,6 +229,7 @@ "BatchCreateJobsRequest", "BatchUpdateJobsRequest", "JobOperationResult", + "JobView", "Profile", "AvailabilitySignal", "Resume", diff --git a/google/cloud/talent_v4beta1/types/completion_service.py b/google/cloud/talent_v4beta1/types/completion_service.py index 662afd21..69f4882a 100644 --- a/google/cloud/talent_v4beta1/types/completion_service.py +++ b/google/cloud/talent_v4beta1/types/completion_service.py @@ -127,7 +127,7 @@ class CompletionResult(proto.Message): suggestion = proto.Field(proto.STRING, number=1) type_ = proto.Field( - proto.ENUM, number=2, enum=CompleteQueryRequest.CompletionType, + proto.ENUM, number=2, enum="CompleteQueryRequest.CompletionType", ) image_uri = proto.Field(proto.STRING, number=3) diff --git a/google/cloud/talent_v4beta1/types/profile.py b/google/cloud/talent_v4beta1/types/profile.py index 7a63d345..38428498 100644 --- a/google/cloud/talent_v4beta1/types/profile.py +++ b/google/cloud/talent_v4beta1/types/profile.py @@ -729,7 +729,7 @@ class EmploymentRecord(proto.Message): division_name = proto.Field(proto.STRING, number=4) - address = proto.Field(proto.MESSAGE, number=5, message=Address,) + address = proto.Field(proto.MESSAGE, number=5, message="Address",) job_title = proto.Field(proto.STRING, number=6) @@ -802,7 +802,7 @@ class EducationRecord(proto.Message): school_name = proto.Field(proto.STRING, number=4) - address = proto.Field(proto.MESSAGE, number=5, message=Address,) + address = proto.Field(proto.MESSAGE, number=5, message="Address",) degree_description = proto.Field(proto.STRING, number=6, oneof="degree") diff --git a/noxfile.py b/noxfile.py index 0235144d..539aa044 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_talent_v4_keywords.py b/scripts/fixup_talent_v4_keywords.py index 0f86462f..374af579 100644 --- a/scripts/fixup_talent_v4_keywords.py +++ b/scripts/fixup_talent_v4_keywords.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2020 Google LLC diff --git a/scripts/fixup_talent_v4beta1_keywords.py b/scripts/fixup_talent_v4beta1_keywords.py index ad407d40..c4488d02 100644 --- a/scripts/fixup_talent_v4beta1_keywords.py +++ b/scripts/fixup_talent_v4beta1_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 65544c71..a7c427fa 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,16 +3,16 @@ { "git": { "name": ".", - "remote": "git@github.com:googleapis/python-talent", - "sha": "9863142855ba1a3771a8e63c8a2a595f13ed1fe4" + "remote": "https://github.com/googleapis/python-talent.git", + "sha": "fbe4d9b3c1fbd7d2ea684151e804885ce056be9f" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "7e837ae45f7b66519a36fd258fe72f08e71725d4", - "internalRef": "334927472" + "sha": "8a6f4d9acb1620af2156b42b37b54eae257b7cad", + "internalRef": "348696929" } }, { @@ -49,5 +49,254 @@ "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/populate-secrets.sh", + ".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/talent_v4/services.rst", + "docs/talent_v4/types.rst", + "docs/talent_v4beta1/services.rst", + "docs/talent_v4beta1/types.rst", + "google/cloud/talent/__init__.py", + "google/cloud/talent/py.typed", + "google/cloud/talent_v4/__init__.py", + "google/cloud/talent_v4/proto/common.proto", + "google/cloud/talent_v4/proto/company.proto", + "google/cloud/talent_v4/proto/company_service.proto", + "google/cloud/talent_v4/proto/completion_service.proto", + "google/cloud/talent_v4/proto/event.proto", + "google/cloud/talent_v4/proto/event_service.proto", + "google/cloud/talent_v4/proto/filters.proto", + "google/cloud/talent_v4/proto/histogram.proto", + "google/cloud/talent_v4/proto/job.proto", + "google/cloud/talent_v4/proto/job_service.proto", + "google/cloud/talent_v4/proto/tenant.proto", + "google/cloud/talent_v4/proto/tenant_service.proto", + "google/cloud/talent_v4/py.typed", + "google/cloud/talent_v4/services/__init__.py", + "google/cloud/talent_v4/services/company_service/__init__.py", + "google/cloud/talent_v4/services/company_service/async_client.py", + "google/cloud/talent_v4/services/company_service/client.py", + "google/cloud/talent_v4/services/company_service/pagers.py", + "google/cloud/talent_v4/services/company_service/transports/__init__.py", + "google/cloud/talent_v4/services/company_service/transports/base.py", + "google/cloud/talent_v4/services/company_service/transports/grpc.py", + "google/cloud/talent_v4/services/company_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4/services/completion/__init__.py", + "google/cloud/talent_v4/services/completion/async_client.py", + "google/cloud/talent_v4/services/completion/client.py", + "google/cloud/talent_v4/services/completion/transports/__init__.py", + "google/cloud/talent_v4/services/completion/transports/base.py", + "google/cloud/talent_v4/services/completion/transports/grpc.py", + "google/cloud/talent_v4/services/completion/transports/grpc_asyncio.py", + "google/cloud/talent_v4/services/event_service/__init__.py", + "google/cloud/talent_v4/services/event_service/async_client.py", + "google/cloud/talent_v4/services/event_service/client.py", + "google/cloud/talent_v4/services/event_service/transports/__init__.py", + "google/cloud/talent_v4/services/event_service/transports/base.py", + "google/cloud/talent_v4/services/event_service/transports/grpc.py", + "google/cloud/talent_v4/services/event_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4/services/job_service/__init__.py", + "google/cloud/talent_v4/services/job_service/async_client.py", + "google/cloud/talent_v4/services/job_service/client.py", + "google/cloud/talent_v4/services/job_service/pagers.py", + "google/cloud/talent_v4/services/job_service/transports/__init__.py", + "google/cloud/talent_v4/services/job_service/transports/base.py", + "google/cloud/talent_v4/services/job_service/transports/grpc.py", + "google/cloud/talent_v4/services/job_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4/services/tenant_service/__init__.py", + "google/cloud/talent_v4/services/tenant_service/async_client.py", + "google/cloud/talent_v4/services/tenant_service/client.py", + "google/cloud/talent_v4/services/tenant_service/pagers.py", + "google/cloud/talent_v4/services/tenant_service/transports/__init__.py", + "google/cloud/talent_v4/services/tenant_service/transports/base.py", + "google/cloud/talent_v4/services/tenant_service/transports/grpc.py", + "google/cloud/talent_v4/services/tenant_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4/types/__init__.py", + "google/cloud/talent_v4/types/common.py", + "google/cloud/talent_v4/types/company.py", + "google/cloud/talent_v4/types/company_service.py", + "google/cloud/talent_v4/types/completion_service.py", + "google/cloud/talent_v4/types/event.py", + "google/cloud/talent_v4/types/event_service.py", + "google/cloud/talent_v4/types/filters.py", + "google/cloud/talent_v4/types/histogram.py", + "google/cloud/talent_v4/types/job.py", + "google/cloud/talent_v4/types/job_service.py", + "google/cloud/talent_v4/types/tenant.py", + "google/cloud/talent_v4/types/tenant_service.py", + "google/cloud/talent_v4beta1/__init__.py", + "google/cloud/talent_v4beta1/proto/application.proto", + "google/cloud/talent_v4beta1/proto/application_service.proto", + "google/cloud/talent_v4beta1/proto/batch.proto", + "google/cloud/talent_v4beta1/proto/common.proto", + "google/cloud/talent_v4beta1/proto/company.proto", + "google/cloud/talent_v4beta1/proto/company_service.proto", + "google/cloud/talent_v4beta1/proto/completion_service.proto", + "google/cloud/talent_v4beta1/proto/event.proto", + "google/cloud/talent_v4beta1/proto/event_service.proto", + "google/cloud/talent_v4beta1/proto/filters.proto", + "google/cloud/talent_v4beta1/proto/histogram.proto", + "google/cloud/talent_v4beta1/proto/job.proto", + "google/cloud/talent_v4beta1/proto/job_service.proto", + "google/cloud/talent_v4beta1/proto/profile.proto", + "google/cloud/talent_v4beta1/proto/profile_service.proto", + "google/cloud/talent_v4beta1/proto/tenant.proto", + "google/cloud/talent_v4beta1/proto/tenant_service.proto", + "google/cloud/talent_v4beta1/py.typed", + "google/cloud/talent_v4beta1/services/__init__.py", + "google/cloud/talent_v4beta1/services/application_service/__init__.py", + "google/cloud/talent_v4beta1/services/application_service/async_client.py", + "google/cloud/talent_v4beta1/services/application_service/client.py", + "google/cloud/talent_v4beta1/services/application_service/pagers.py", + "google/cloud/talent_v4beta1/services/application_service/transports/__init__.py", + "google/cloud/talent_v4beta1/services/application_service/transports/base.py", + "google/cloud/talent_v4beta1/services/application_service/transports/grpc.py", + "google/cloud/talent_v4beta1/services/application_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4beta1/services/company_service/__init__.py", + "google/cloud/talent_v4beta1/services/company_service/async_client.py", + "google/cloud/talent_v4beta1/services/company_service/client.py", + "google/cloud/talent_v4beta1/services/company_service/pagers.py", + "google/cloud/talent_v4beta1/services/company_service/transports/__init__.py", + "google/cloud/talent_v4beta1/services/company_service/transports/base.py", + "google/cloud/talent_v4beta1/services/company_service/transports/grpc.py", + "google/cloud/talent_v4beta1/services/company_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4beta1/services/completion/__init__.py", + "google/cloud/talent_v4beta1/services/completion/async_client.py", + "google/cloud/talent_v4beta1/services/completion/client.py", + "google/cloud/talent_v4beta1/services/completion/transports/__init__.py", + "google/cloud/talent_v4beta1/services/completion/transports/base.py", + "google/cloud/talent_v4beta1/services/completion/transports/grpc.py", + "google/cloud/talent_v4beta1/services/completion/transports/grpc_asyncio.py", + "google/cloud/talent_v4beta1/services/event_service/__init__.py", + "google/cloud/talent_v4beta1/services/event_service/async_client.py", + "google/cloud/talent_v4beta1/services/event_service/client.py", + "google/cloud/talent_v4beta1/services/event_service/transports/__init__.py", + "google/cloud/talent_v4beta1/services/event_service/transports/base.py", + "google/cloud/talent_v4beta1/services/event_service/transports/grpc.py", + "google/cloud/talent_v4beta1/services/event_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4beta1/services/job_service/__init__.py", + "google/cloud/talent_v4beta1/services/job_service/async_client.py", + "google/cloud/talent_v4beta1/services/job_service/client.py", + "google/cloud/talent_v4beta1/services/job_service/pagers.py", + "google/cloud/talent_v4beta1/services/job_service/transports/__init__.py", + "google/cloud/talent_v4beta1/services/job_service/transports/base.py", + "google/cloud/talent_v4beta1/services/job_service/transports/grpc.py", + "google/cloud/talent_v4beta1/services/job_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4beta1/services/profile_service/__init__.py", + "google/cloud/talent_v4beta1/services/profile_service/async_client.py", + "google/cloud/talent_v4beta1/services/profile_service/client.py", + "google/cloud/talent_v4beta1/services/profile_service/pagers.py", + "google/cloud/talent_v4beta1/services/profile_service/transports/__init__.py", + "google/cloud/talent_v4beta1/services/profile_service/transports/base.py", + "google/cloud/talent_v4beta1/services/profile_service/transports/grpc.py", + "google/cloud/talent_v4beta1/services/profile_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4beta1/services/tenant_service/__init__.py", + "google/cloud/talent_v4beta1/services/tenant_service/async_client.py", + "google/cloud/talent_v4beta1/services/tenant_service/client.py", + "google/cloud/talent_v4beta1/services/tenant_service/pagers.py", + "google/cloud/talent_v4beta1/services/tenant_service/transports/__init__.py", + "google/cloud/talent_v4beta1/services/tenant_service/transports/base.py", + "google/cloud/talent_v4beta1/services/tenant_service/transports/grpc.py", + "google/cloud/talent_v4beta1/services/tenant_service/transports/grpc_asyncio.py", + "google/cloud/talent_v4beta1/types/__init__.py", + "google/cloud/talent_v4beta1/types/application.py", + "google/cloud/talent_v4beta1/types/application_service.py", + "google/cloud/talent_v4beta1/types/batch.py", + "google/cloud/talent_v4beta1/types/common.py", + "google/cloud/talent_v4beta1/types/company.py", + "google/cloud/talent_v4beta1/types/company_service.py", + "google/cloud/talent_v4beta1/types/completion_service.py", + "google/cloud/talent_v4beta1/types/event.py", + "google/cloud/talent_v4beta1/types/event_service.py", + "google/cloud/talent_v4beta1/types/filters.py", + "google/cloud/talent_v4beta1/types/histogram.py", + "google/cloud/talent_v4beta1/types/job.py", + "google/cloud/talent_v4beta1/types/job_service.py", + "google/cloud/talent_v4beta1/types/profile.py", + "google/cloud/talent_v4beta1/types/profile_service.py", + "google/cloud/talent_v4beta1/types/tenant.py", + "google/cloud/talent_v4beta1/types/tenant_service.py", + "mypy.ini", + "noxfile.py", + "renovate.json", + "samples/AUTHORING_GUIDE.md", + "samples/CONTRIBUTING.md", + "samples/snippets/noxfile.py", + "scripts/decrypt-secrets.sh", + "scripts/fixup_talent_v4_keywords.py", + "scripts/fixup_talent_v4beta1_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/talent_v4/__init__.py", + "tests/unit/gapic/talent_v4/test_company_service.py", + "tests/unit/gapic/talent_v4/test_completion.py", + "tests/unit/gapic/talent_v4/test_event_service.py", + "tests/unit/gapic/talent_v4/test_job_service.py", + "tests/unit/gapic/talent_v4/test_tenant_service.py", + "tests/unit/gapic/talent_v4beta1/__init__.py", + "tests/unit/gapic/talent_v4beta1/test_application_service.py", + "tests/unit/gapic/talent_v4beta1/test_company_service.py", + "tests/unit/gapic/talent_v4beta1/test_completion.py", + "tests/unit/gapic/talent_v4beta1/test_event_service.py", + "tests/unit/gapic/talent_v4beta1/test_job_service.py", + "tests/unit/gapic/talent_v4beta1/test_profile_service.py", + "tests/unit/gapic/talent_v4beta1/test_tenant_service.py" ] } \ No newline at end of file diff --git a/tests/unit/gapic/talent_v4/test_company_service.py b/tests/unit/gapic/talent_v4/test_company_service.py index 7bf7ac24..bcb62811 100644 --- a/tests/unit/gapic/talent_v4/test_company_service.py +++ b/tests/unit/gapic/talent_v4/test_company_service.py @@ -43,7 +43,7 @@ from google.oauth2 import service_account from google.protobuf import field_mask_pb2 as field_mask # type: ignore from google.type import latlng_pb2 as latlng # type: ignore -from google.type import postal_address_pb2 as gt_postal_address # type: ignore +from google.type import postal_address_pb2 as postal_address # type: ignore def client_cert_source_callback(): @@ -100,12 +100,12 @@ def test_company_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_company_service_client_get_transport_class(): @@ -455,7 +455,7 @@ def test_create_company( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_company), "__call__") as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company( name="name_value", @@ -483,6 +483,7 @@ def test_create_company( assert args[0] == company_service.CreateCompanyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) assert response.name == "name_value" @@ -517,19 +518,19 @@ def test_create_company_from_dict(): @pytest.mark.asyncio -async def test_create_company_async(transport: str = "grpc_asyncio"): +async def test_create_company_async( + transport: str = "grpc_asyncio", request_type=company_service.CreateCompanyRequest +): client = CompanyServiceAsyncClient( 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 = company_service.CreateCompanyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_company.Company( @@ -556,7 +557,7 @@ async def test_create_company_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.CreateCompanyRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_company.Company) @@ -588,6 +589,11 @@ async def test_create_company_async(transport: str = "grpc_asyncio"): assert response.suspended is True +@pytest.mark.asyncio +async def test_create_company_async_from_dict(): + await test_create_company_async(request_type=dict) + + def test_create_company_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -597,7 +603,7 @@ def test_create_company_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_company), "__call__") as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: call.return_value = gct_company.Company() client.create_company(request) @@ -622,9 +628,7 @@ async def test_create_company_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_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) await client.create_company(request) @@ -643,7 +647,7 @@ def test_create_company_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_company), "__call__") as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company() @@ -681,9 +685,7 @@ async def test_create_company_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company() @@ -730,7 +732,7 @@ def test_get_company( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_company), "__call__") as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company.Company( name="name_value", @@ -758,6 +760,7 @@ def test_get_company( assert args[0] == company_service.GetCompanyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, company.Company) assert response.name == "name_value" @@ -792,19 +795,19 @@ def test_get_company_from_dict(): @pytest.mark.asyncio -async def test_get_company_async(transport: str = "grpc_asyncio"): +async def test_get_company_async( + transport: str = "grpc_asyncio", request_type=company_service.GetCompanyRequest +): client = CompanyServiceAsyncClient( 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 = company_service.GetCompanyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( company.Company( @@ -831,7 +834,7 @@ async def test_get_company_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.GetCompanyRequest() # Establish that the response is the type that we expect. assert isinstance(response, company.Company) @@ -863,6 +866,11 @@ async def test_get_company_async(transport: str = "grpc_asyncio"): assert response.suspended is True +@pytest.mark.asyncio +async def test_get_company_async_from_dict(): + await test_get_company_async(request_type=dict) + + def test_get_company_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -872,7 +880,7 @@ def test_get_company_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_company), "__call__") as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: call.return_value = company.Company() client.get_company(request) @@ -897,9 +905,7 @@ async def test_get_company_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_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) await client.get_company(request) @@ -918,7 +924,7 @@ def test_get_company_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_company), "__call__") as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company.Company() @@ -950,9 +956,7 @@ async def test_get_company_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company.Company() @@ -993,7 +997,7 @@ def test_update_company( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_company), "__call__") as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company( name="name_value", @@ -1021,6 +1025,7 @@ def test_update_company( assert args[0] == company_service.UpdateCompanyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) assert response.name == "name_value" @@ -1055,19 +1060,19 @@ def test_update_company_from_dict(): @pytest.mark.asyncio -async def test_update_company_async(transport: str = "grpc_asyncio"): +async def test_update_company_async( + transport: str = "grpc_asyncio", request_type=company_service.UpdateCompanyRequest +): client = CompanyServiceAsyncClient( 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 = company_service.UpdateCompanyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_company.Company( @@ -1094,7 +1099,7 @@ async def test_update_company_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.UpdateCompanyRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_company.Company) @@ -1126,6 +1131,11 @@ async def test_update_company_async(transport: str = "grpc_asyncio"): assert response.suspended is True +@pytest.mark.asyncio +async def test_update_company_async_from_dict(): + await test_update_company_async(request_type=dict) + + def test_update_company_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1135,7 +1145,7 @@ def test_update_company_field_headers(): request.company.name = "company.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_company), "__call__") as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: call.return_value = gct_company.Company() client.update_company(request) @@ -1162,9 +1172,7 @@ async def test_update_company_field_headers_async(): request.company.name = "company.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) await client.update_company(request) @@ -1185,7 +1193,7 @@ def test_update_company_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_company), "__call__") as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company() @@ -1224,9 +1232,7 @@ async def test_update_company_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company() @@ -1274,7 +1280,7 @@ def test_delete_company( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_company), "__call__") as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1295,19 +1301,19 @@ def test_delete_company_from_dict(): @pytest.mark.asyncio -async def test_delete_company_async(transport: str = "grpc_asyncio"): +async def test_delete_company_async( + transport: str = "grpc_asyncio", request_type=company_service.DeleteCompanyRequest +): client = CompanyServiceAsyncClient( 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 = company_service.DeleteCompanyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1317,12 +1323,17 @@ async def test_delete_company_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.DeleteCompanyRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_company_async_from_dict(): + await test_delete_company_async(request_type=dict) + + def test_delete_company_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1332,7 +1343,7 @@ def test_delete_company_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_company), "__call__") as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: call.return_value = None client.delete_company(request) @@ -1357,9 +1368,7 @@ async def test_delete_company_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_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_company(request) @@ -1378,7 +1387,7 @@ def test_delete_company_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_company), "__call__") as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1410,9 +1419,7 @@ async def test_delete_company_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1453,7 +1460,7 @@ def test_list_companies( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company_service.ListCompaniesResponse( next_page_token="next_page_token_value", @@ -1468,6 +1475,7 @@ def test_list_companies( assert args[0] == company_service.ListCompaniesRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCompaniesPager) assert response.next_page_token == "next_page_token_value" @@ -1478,19 +1486,19 @@ def test_list_companies_from_dict(): @pytest.mark.asyncio -async def test_list_companies_async(transport: str = "grpc_asyncio"): +async def test_list_companies_async( + transport: str = "grpc_asyncio", request_type=company_service.ListCompaniesRequest +): client = CompanyServiceAsyncClient( 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 = company_service.ListCompaniesRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_companies), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( company_service.ListCompaniesResponse( @@ -1504,7 +1512,7 @@ async def test_list_companies_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.ListCompaniesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCompaniesAsyncPager) @@ -1512,6 +1520,11 @@ async def test_list_companies_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_companies_async_from_dict(): + await test_list_companies_async(request_type=dict) + + def test_list_companies_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1521,7 +1534,7 @@ def test_list_companies_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_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: call.return_value = company_service.ListCompaniesResponse() client.list_companies(request) @@ -1546,9 +1559,7 @@ async def test_list_companies_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_companies), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( company_service.ListCompaniesResponse() ) @@ -1569,7 +1580,7 @@ def test_list_companies_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company_service.ListCompaniesResponse() @@ -1601,9 +1612,7 @@ async def test_list_companies_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_companies), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company_service.ListCompaniesResponse() @@ -1638,7 +1647,7 @@ def test_list_companies_pager(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( company_service.ListCompaniesResponse( @@ -1672,7 +1681,7 @@ def test_list_companies_pages(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( company_service.ListCompaniesResponse( @@ -1699,9 +1708,7 @@ async def test_list_companies_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_companies), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_companies), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1734,9 +1741,7 @@ async def test_list_companies_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_companies), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_companies), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1796,7 +1801,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = CompanyServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -1832,7 +1837,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.CompanyServiceGrpcTransport,) + assert isinstance(client.transport, transports.CompanyServiceGrpcTransport,) def test_company_service_base_transport_error(): @@ -1937,7 +1942,7 @@ def test_company_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_company_service_host_with_port(): @@ -1947,7 +1952,7 @@ def test_company_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_company_service_grpc_transport_channel(): @@ -1959,6 +1964,7 @@ def test_company_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_company_service_grpc_asyncio_transport_channel(): @@ -1970,6 +1976,7 @@ def test_company_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( @@ -2018,8 +2025,13 @@ def test_company_service_transport_channel_mtls_with_client_cert_source( ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -2061,6 +2073,10 @@ def test_company_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel @@ -2090,6 +2106,130 @@ def test_parse_company_path(): assert expected == actual +def test_tenant_path(): + project = "cuttlefish" + tenant = "mussel" + + expected = "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + actual = CompanyServiceClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "winkle", + "tenant": "nautilus", + } + path = CompanyServiceClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_tenant_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "scallop" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = CompanyServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "abalone", + } + path = CompanyServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "squid" + + expected = "folders/{folder}".format(folder=folder,) + actual = CompanyServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "clam", + } + path = CompanyServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "whelk" + + expected = "organizations/{organization}".format(organization=organization,) + actual = CompanyServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "octopus", + } + path = CompanyServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "oyster" + + expected = "projects/{project}".format(project=project,) + actual = CompanyServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nudibranch", + } + path = CompanyServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.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 = CompanyServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "winkle", + "location": "nautilus", + } + path = CompanyServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.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/talent_v4/test_completion.py b/tests/unit/gapic/talent_v4/test_completion.py index 390d8e24..cafd4bc5 100644 --- a/tests/unit/gapic/talent_v4/test_completion.py +++ b/tests/unit/gapic/talent_v4/test_completion.py @@ -89,12 +89,12 @@ def test_completion_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_completion_client_get_transport_class(): @@ -438,7 +438,7 @@ def test_complete_query( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.complete_query), "__call__") as call: + with mock.patch.object(type(client.transport.complete_query), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = completion_service.CompleteQueryResponse() @@ -451,6 +451,7 @@ def test_complete_query( assert args[0] == completion_service.CompleteQueryRequest() # Establish that the response is the type that we expect. + assert isinstance(response, completion_service.CompleteQueryResponse) @@ -459,19 +460,20 @@ def test_complete_query_from_dict(): @pytest.mark.asyncio -async def test_complete_query_async(transport: str = "grpc_asyncio"): +async def test_complete_query_async( + transport: str = "grpc_asyncio", + request_type=completion_service.CompleteQueryRequest, +): client = CompletionAsyncClient( 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 = completion_service.CompleteQueryRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.complete_query), "__call__" - ) as call: + with mock.patch.object(type(client.transport.complete_query), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( completion_service.CompleteQueryResponse() @@ -483,12 +485,17 @@ async def test_complete_query_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == completion_service.CompleteQueryRequest() # Establish that the response is the type that we expect. assert isinstance(response, completion_service.CompleteQueryResponse) +@pytest.mark.asyncio +async def test_complete_query_async_from_dict(): + await test_complete_query_async(request_type=dict) + + def test_complete_query_field_headers(): client = CompletionClient(credentials=credentials.AnonymousCredentials(),) @@ -498,7 +505,7 @@ def test_complete_query_field_headers(): request.tenant = "tenant/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.complete_query), "__call__") as call: + with mock.patch.object(type(client.transport.complete_query), "__call__") as call: call.return_value = completion_service.CompleteQueryResponse() client.complete_query(request) @@ -523,9 +530,7 @@ async def test_complete_query_field_headers_async(): request.tenant = "tenant/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.complete_query), "__call__" - ) as call: + with mock.patch.object(type(client.transport.complete_query), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( completion_service.CompleteQueryResponse() ) @@ -578,7 +583,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = CompletionClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -611,7 +616,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = CompletionClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.CompletionGrpcTransport,) + assert isinstance(client.transport, transports.CompletionGrpcTransport,) def test_completion_base_transport_error(): @@ -710,7 +715,7 @@ def test_completion_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_completion_host_with_port(): @@ -720,7 +725,7 @@ def test_completion_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_completion_grpc_transport_channel(): @@ -732,6 +737,7 @@ def test_completion_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_completion_grpc_asyncio_transport_channel(): @@ -743,6 +749,7 @@ def test_completion_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( @@ -786,8 +793,13 @@ def test_completion_transport_channel_mtls_with_client_cert_source(transport_cla ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -826,10 +838,163 @@ def test_completion_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel +def test_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + actual = CompletionClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = CompletionClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_company_path(path) + assert expected == actual + + +def test_tenant_path(): + project = "cuttlefish" + tenant = "mussel" + + expected = "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + actual = CompletionClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "winkle", + "tenant": "nautilus", + } + path = CompletionClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_tenant_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "scallop" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = CompletionClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "abalone", + } + path = CompletionClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "squid" + + expected = "folders/{folder}".format(folder=folder,) + actual = CompletionClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "clam", + } + path = CompletionClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "whelk" + + expected = "organizations/{organization}".format(organization=organization,) + actual = CompletionClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "octopus", + } + path = CompletionClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "oyster" + + expected = "projects/{project}".format(project=project,) + actual = CompletionClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nudibranch", + } + path = CompletionClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.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 = CompletionClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "winkle", + "location": "nautilus", + } + path = CompletionClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.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/talent_v4/test_event_service.py b/tests/unit/gapic/talent_v4/test_event_service.py index dd38cf40..dcf80843 100644 --- a/tests/unit/gapic/talent_v4/test_event_service.py +++ b/tests/unit/gapic/talent_v4/test_event_service.py @@ -90,12 +90,12 @@ def test_event_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_event_service_client_get_transport_class(): @@ -440,7 +440,7 @@ def test_create_client_event( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = event.ClientEvent( @@ -459,6 +459,7 @@ def test_create_client_event( assert args[0] == event_service.CreateClientEventRequest() # Establish that the response is the type that we expect. + assert isinstance(response, event.ClientEvent) assert response.request_id == "request_id_value" @@ -473,18 +474,20 @@ def test_create_client_event_from_dict(): @pytest.mark.asyncio -async def test_create_client_event_async(transport: str = "grpc_asyncio"): +async def test_create_client_event_async( + transport: str = "grpc_asyncio", request_type=event_service.CreateClientEventRequest +): client = EventServiceAsyncClient( 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 = event_service.CreateClientEventRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -501,7 +504,7 @@ async def test_create_client_event_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == event_service.CreateClientEventRequest() # Establish that the response is the type that we expect. assert isinstance(response, event.ClientEvent) @@ -513,6 +516,11 @@ async def test_create_client_event_async(transport: str = "grpc_asyncio"): assert response.event_notes == "event_notes_value" +@pytest.mark.asyncio +async def test_create_client_event_async_from_dict(): + await test_create_client_event_async(request_type=dict) + + def test_create_client_event_field_headers(): client = EventServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -523,7 +531,7 @@ def test_create_client_event_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: call.return_value = event.ClientEvent() @@ -550,7 +558,7 @@ async def test_create_client_event_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) @@ -571,7 +579,7 @@ def test_create_client_event_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = event.ClientEvent() @@ -612,7 +620,7 @@ async def test_create_client_event_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = event.ClientEvent() @@ -685,7 +693,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = EventServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -718,7 +726,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = EventServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.EventServiceGrpcTransport,) + assert isinstance(client.transport, transports.EventServiceGrpcTransport,) def test_event_service_base_transport_error(): @@ -817,7 +825,7 @@ def test_event_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_event_service_host_with_port(): @@ -827,7 +835,7 @@ def test_event_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_event_service_grpc_transport_channel(): @@ -839,6 +847,7 @@ def test_event_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_event_service_grpc_asyncio_transport_channel(): @@ -850,6 +859,7 @@ def test_event_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( @@ -893,8 +903,13 @@ def test_event_service_transport_channel_mtls_with_client_cert_source(transport_ ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -933,10 +948,138 @@ def test_event_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel +def test_tenant_path(): + project = "squid" + tenant = "clam" + + expected = "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + actual = EventServiceClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "whelk", + "tenant": "octopus", + } + path = EventServiceClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_tenant_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "oyster" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = EventServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nudibranch", + } + path = EventServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "cuttlefish" + + expected = "folders/{folder}".format(folder=folder,) + actual = EventServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "mussel", + } + path = EventServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "winkle" + + expected = "organizations/{organization}".format(organization=organization,) + actual = EventServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nautilus", + } + path = EventServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "scallop" + + expected = "projects/{project}".format(project=project,) + actual = EventServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "abalone", + } + path = EventServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "squid" + location = "clam" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = EventServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = EventServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.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/talent_v4/test_job_service.py b/tests/unit/gapic/talent_v4/test_job_service.py index e8bf3b66..208347d4 100644 --- a/tests/unit/gapic/talent_v4/test_job_service.py +++ b/tests/unit/gapic/talent_v4/test_job_service.py @@ -53,7 +53,7 @@ from google.protobuf import wrappers_pb2 as wrappers # type: ignore from google.type import latlng_pb2 as latlng # type: ignore from google.type import money_pb2 as money # type: ignore -from google.type import postal_address_pb2 as gt_postal_address # type: ignore +from google.type import postal_address_pb2 as postal_address # type: ignore from google.type import timeofday_pb2 as timeofday # type: ignore @@ -106,12 +106,12 @@ def test_job_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_job_service_client_get_transport_class(): @@ -453,7 +453,7 @@ def test_create_job(transport: str = "grpc", request_type=job_service.CreateJobR request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_job), "__call__") as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job( name="name_value", @@ -486,6 +486,7 @@ def test_create_job(transport: str = "grpc", request_type=job_service.CreateJobR assert args[0] == job_service.CreateJobRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) assert response.name == "name_value" @@ -532,19 +533,19 @@ def test_create_job_from_dict(): @pytest.mark.asyncio -async def test_create_job_async(transport: str = "grpc_asyncio"): +async def test_create_job_async( + transport: str = "grpc_asyncio", request_type=job_service.CreateJobRequest +): client = JobServiceAsyncClient( 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 = job_service.CreateJobRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_job.Job( @@ -576,7 +577,7 @@ async def test_create_job_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.CreateJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_job.Job) @@ -620,6 +621,11 @@ async def test_create_job_async(transport: str = "grpc_asyncio"): assert response.company_display_name == "company_display_name_value" +@pytest.mark.asyncio +async def test_create_job_async_from_dict(): + await test_create_job_async(request_type=dict) + + def test_create_job_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -629,7 +635,7 @@ def test_create_job_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_job), "__call__") as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: call.return_value = gct_job.Job() client.create_job(request) @@ -654,9 +660,7 @@ async def test_create_job_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_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) await client.create_job(request) @@ -675,7 +679,7 @@ def test_create_job_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_job), "__call__") as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job() @@ -713,9 +717,7 @@ async def test_create_job_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job() @@ -763,7 +765,7 @@ def test_batch_create_jobs( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") @@ -785,18 +787,20 @@ def test_batch_create_jobs_from_dict(): @pytest.mark.asyncio -async def test_batch_create_jobs_async(transport: str = "grpc_asyncio"): +async def test_batch_create_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.BatchCreateJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.BatchCreateJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -809,12 +813,17 @@ async def test_batch_create_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.BatchCreateJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, future.Future) +@pytest.mark.asyncio +async def test_batch_create_jobs_async_from_dict(): + await test_batch_create_jobs_async(request_type=dict) + + def test_batch_create_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -825,7 +834,7 @@ def test_batch_create_jobs_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") @@ -852,7 +861,7 @@ async def test_batch_create_jobs_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") @@ -875,7 +884,7 @@ def test_batch_create_jobs_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -915,7 +924,7 @@ async def test_batch_create_jobs_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -963,7 +972,7 @@ def test_get_job(transport: str = "grpc", request_type=job_service.GetJobRequest request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job.Job( name="name_value", @@ -996,6 +1005,7 @@ def test_get_job(transport: str = "grpc", request_type=job_service.GetJobRequest assert args[0] == job_service.GetJobRequest() # Establish that the response is the type that we expect. + assert isinstance(response, job.Job) assert response.name == "name_value" @@ -1042,17 +1052,19 @@ def test_get_job_from_dict(): @pytest.mark.asyncio -async def test_get_job_async(transport: str = "grpc_asyncio"): +async def test_get_job_async( + transport: str = "grpc_asyncio", request_type=job_service.GetJobRequest +): client = JobServiceAsyncClient( 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 = job_service.GetJobRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._client._transport.get_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job.Job( @@ -1084,7 +1096,7 @@ async def test_get_job_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.GetJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, job.Job) @@ -1128,6 +1140,11 @@ async def test_get_job_async(transport: str = "grpc_asyncio"): assert response.company_display_name == "company_display_name_value" +@pytest.mark.asyncio +async def test_get_job_async_from_dict(): + await test_get_job_async(request_type=dict) + + def test_get_job_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1137,7 +1154,7 @@ def test_get_job_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_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: call.return_value = job.Job() client.get_job(request) @@ -1162,7 +1179,7 @@ async def test_get_job_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_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) await client.get_job(request) @@ -1181,7 +1198,7 @@ def test_get_job_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job.Job() @@ -1213,7 +1230,7 @@ async def test_get_job_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._client._transport.get_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job.Job() @@ -1252,7 +1269,7 @@ def test_update_job(transport: str = "grpc", request_type=job_service.UpdateJobR request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_job), "__call__") as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job( name="name_value", @@ -1285,6 +1302,7 @@ def test_update_job(transport: str = "grpc", request_type=job_service.UpdateJobR assert args[0] == job_service.UpdateJobRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) assert response.name == "name_value" @@ -1331,19 +1349,19 @@ def test_update_job_from_dict(): @pytest.mark.asyncio -async def test_update_job_async(transport: str = "grpc_asyncio"): +async def test_update_job_async( + transport: str = "grpc_asyncio", request_type=job_service.UpdateJobRequest +): client = JobServiceAsyncClient( 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 = job_service.UpdateJobRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_job.Job( @@ -1375,7 +1393,7 @@ async def test_update_job_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.UpdateJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_job.Job) @@ -1419,6 +1437,11 @@ async def test_update_job_async(transport: str = "grpc_asyncio"): assert response.company_display_name == "company_display_name_value" +@pytest.mark.asyncio +async def test_update_job_async_from_dict(): + await test_update_job_async(request_type=dict) + + def test_update_job_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1428,7 +1451,7 @@ def test_update_job_field_headers(): request.job.name = "job.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_job), "__call__") as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: call.return_value = gct_job.Job() client.update_job(request) @@ -1453,9 +1476,7 @@ async def test_update_job_field_headers_async(): request.job.name = "job.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) await client.update_job(request) @@ -1474,7 +1495,7 @@ def test_update_job_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_job), "__call__") as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job() @@ -1513,9 +1534,7 @@ async def test_update_job_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job() @@ -1564,7 +1583,7 @@ def test_batch_update_jobs( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") @@ -1586,18 +1605,20 @@ def test_batch_update_jobs_from_dict(): @pytest.mark.asyncio -async def test_batch_update_jobs_async(transport: str = "grpc_asyncio"): +async def test_batch_update_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.BatchUpdateJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.BatchUpdateJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1610,12 +1631,17 @@ async def test_batch_update_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.BatchUpdateJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, future.Future) +@pytest.mark.asyncio +async def test_batch_update_jobs_async_from_dict(): + await test_batch_update_jobs_async(request_type=dict) + + def test_batch_update_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1626,7 +1652,7 @@ def test_batch_update_jobs_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") @@ -1653,7 +1679,7 @@ async def test_batch_update_jobs_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") @@ -1676,7 +1702,7 @@ def test_batch_update_jobs_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -1716,7 +1742,7 @@ async def test_batch_update_jobs_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -1764,7 +1790,7 @@ def test_delete_job(transport: str = "grpc", request_type=job_service.DeleteJobR request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_job), "__call__") as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1785,19 +1811,19 @@ def test_delete_job_from_dict(): @pytest.mark.asyncio -async def test_delete_job_async(transport: str = "grpc_asyncio"): +async def test_delete_job_async( + transport: str = "grpc_asyncio", request_type=job_service.DeleteJobRequest +): client = JobServiceAsyncClient( 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 = job_service.DeleteJobRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1807,12 +1833,17 @@ async def test_delete_job_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.DeleteJobRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_job_async_from_dict(): + await test_delete_job_async(request_type=dict) + + def test_delete_job_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1822,7 +1853,7 @@ def test_delete_job_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_job), "__call__") as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: call.return_value = None client.delete_job(request) @@ -1847,9 +1878,7 @@ async def test_delete_job_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_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_job(request) @@ -1868,7 +1897,7 @@ def test_delete_job_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_job), "__call__") as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1900,9 +1929,7 @@ async def test_delete_job_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1944,7 +1971,7 @@ def test_batch_delete_jobs( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") @@ -1966,18 +1993,20 @@ def test_batch_delete_jobs_from_dict(): @pytest.mark.asyncio -async def test_batch_delete_jobs_async(transport: str = "grpc_asyncio"): +async def test_batch_delete_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.BatchDeleteJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.BatchDeleteJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1990,12 +2019,17 @@ async def test_batch_delete_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.BatchDeleteJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, future.Future) +@pytest.mark.asyncio +async def test_batch_delete_jobs_async_from_dict(): + await test_batch_delete_jobs_async(request_type=dict) + + def test_batch_delete_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2006,7 +2040,7 @@ def test_batch_delete_jobs_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") @@ -2033,7 +2067,7 @@ async def test_batch_delete_jobs_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") @@ -2056,7 +2090,7 @@ def test_batch_delete_jobs_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -2096,7 +2130,7 @@ async def test_batch_delete_jobs_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -2144,7 +2178,7 @@ def test_list_jobs(transport: str = "grpc", request_type=job_service.ListJobsReq request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListJobsResponse( next_page_token="next_page_token_value", @@ -2159,6 +2193,7 @@ def test_list_jobs(transport: str = "grpc", request_type=job_service.ListJobsReq assert args[0] == job_service.ListJobsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListJobsPager) assert response.next_page_token == "next_page_token_value" @@ -2169,19 +2204,19 @@ def test_list_jobs_from_dict(): @pytest.mark.asyncio -async def test_list_jobs_async(transport: str = "grpc_asyncio"): +async def test_list_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.ListJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.ListJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListJobsResponse(next_page_token="next_page_token_value",) @@ -2193,7 +2228,7 @@ async def test_list_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.ListJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListJobsAsyncPager) @@ -2201,6 +2236,11 @@ async def test_list_jobs_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_jobs_async_from_dict(): + await test_list_jobs_async(request_type=dict) + + def test_list_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2210,7 +2250,7 @@ def test_list_jobs_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_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: call.return_value = job_service.ListJobsResponse() client.list_jobs(request) @@ -2235,9 +2275,7 @@ async def test_list_jobs_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_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListJobsResponse() ) @@ -2258,7 +2296,7 @@ def test_list_jobs_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListJobsResponse() @@ -2294,9 +2332,7 @@ async def test_list_jobs_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListJobsResponse() @@ -2333,7 +2369,7 @@ def test_list_jobs_pager(): client = JobServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( job_service.ListJobsResponse( @@ -2362,7 +2398,7 @@ def test_list_jobs_pages(): client = JobServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( job_service.ListJobsResponse( @@ -2384,9 +2420,7 @@ async def test_list_jobs_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_jobs), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_jobs), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2414,9 +2448,7 @@ async def test_list_jobs_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_jobs), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_jobs), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2447,7 +2479,7 @@ def test_search_jobs( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.search_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.SearchJobsResponse( next_page_token="next_page_token_value", @@ -2464,6 +2496,9 @@ def test_search_jobs( assert args[0] == job_service.SearchJobsRequest() # Establish that the response is the type that we expect. + + assert response.raw_page is response + assert isinstance(response, job_service.SearchJobsResponse) assert response.next_page_token == "next_page_token_value" @@ -2478,19 +2513,19 @@ def test_search_jobs_from_dict(): @pytest.mark.asyncio -async def test_search_jobs_async(transport: str = "grpc_asyncio"): +async def test_search_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.SearchJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.SearchJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.search_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.SearchJobsResponse( @@ -2506,7 +2541,7 @@ async def test_search_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.SearchJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, job_service.SearchJobsResponse) @@ -2518,6 +2553,11 @@ async def test_search_jobs_async(transport: str = "grpc_asyncio"): assert response.broadened_query_jobs_count == 2766 +@pytest.mark.asyncio +async def test_search_jobs_async_from_dict(): + await test_search_jobs_async(request_type=dict) + + def test_search_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2527,7 +2567,7 @@ def test_search_jobs_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.search_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: call.return_value = job_service.SearchJobsResponse() client.search_jobs(request) @@ -2552,9 +2592,7 @@ async def test_search_jobs_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.search_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.SearchJobsResponse() ) @@ -2584,7 +2622,7 @@ def test_search_jobs_for_alert( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = job_service.SearchJobsResponse( @@ -2602,6 +2640,9 @@ def test_search_jobs_for_alert( assert args[0] == job_service.SearchJobsRequest() # Establish that the response is the type that we expect. + + assert response.raw_page is response + assert isinstance(response, job_service.SearchJobsResponse) assert response.next_page_token == "next_page_token_value" @@ -2616,18 +2657,20 @@ def test_search_jobs_for_alert_from_dict(): @pytest.mark.asyncio -async def test_search_jobs_for_alert_async(transport: str = "grpc_asyncio"): +async def test_search_jobs_for_alert_async( + transport: str = "grpc_asyncio", request_type=job_service.SearchJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.SearchJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2644,7 +2687,7 @@ async def test_search_jobs_for_alert_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.SearchJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, job_service.SearchJobsResponse) @@ -2656,6 +2699,11 @@ async def test_search_jobs_for_alert_async(transport: str = "grpc_asyncio"): assert response.broadened_query_jobs_count == 2766 +@pytest.mark.asyncio +async def test_search_jobs_for_alert_async_from_dict(): + await test_search_jobs_for_alert_async(request_type=dict) + + def test_search_jobs_for_alert_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2666,7 +2714,7 @@ def test_search_jobs_for_alert_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: call.return_value = job_service.SearchJobsResponse() @@ -2693,7 +2741,7 @@ async def test_search_jobs_for_alert_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.SearchJobsResponse() @@ -2747,7 +2795,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = JobServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -2780,7 +2828,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.JobServiceGrpcTransport,) + assert isinstance(client.transport, transports.JobServiceGrpcTransport,) def test_job_service_base_transport_error(): @@ -2895,7 +2943,7 @@ def test_job_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_job_service_host_with_port(): @@ -2905,7 +2953,7 @@ def test_job_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_job_service_grpc_transport_channel(): @@ -2917,6 +2965,7 @@ def test_job_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_job_service_grpc_asyncio_transport_channel(): @@ -2928,6 +2977,7 @@ def test_job_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( @@ -2971,8 +3021,13 @@ def test_job_service_transport_channel_mtls_with_client_cert_source(transport_cl ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -3011,6 +3066,10 @@ def test_job_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel @@ -3019,7 +3078,7 @@ def test_job_service_grpc_lro_client(): client = JobServiceClient( credentials=credentials.AnonymousCredentials(), transport="grpc", ) - transport = client._transport + transport = client.transport # Ensure that we have a api-core operations client. assert isinstance(transport.operations_client, operations_v1.OperationsClient,) @@ -3032,7 +3091,7 @@ def test_job_service_grpc_lro_async_client(): client = JobServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", ) - transport = client._client._transport + transport = client.transport # Ensure that we have a api-core operations client. assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) @@ -3041,10 +3100,35 @@ def test_job_service_grpc_lro_async_client(): assert transport.operations_client is transport.operations_client -def test_job_path(): +def test_company_path(): project = "squid" tenant = "clam" - job = "whelk" + company = "whelk" + + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + actual = JobServiceClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = JobServiceClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_company_path(path) + assert expected == actual + + +def test_job_path(): + project = "cuttlefish" + tenant = "mussel" + job = "winkle" expected = "projects/{project}/tenants/{tenant}/jobs/{job}".format( project=project, tenant=tenant, job=job, @@ -3055,9 +3139,9 @@ def test_job_path(): def test_parse_job_path(): expected = { - "project": "octopus", - "tenant": "oyster", - "job": "nudibranch", + "project": "nautilus", + "tenant": "scallop", + "job": "abalone", } path = JobServiceClient.job_path(**expected) @@ -3066,6 +3150,130 @@ def test_parse_job_path(): assert expected == actual +def test_tenant_path(): + project = "squid" + tenant = "clam" + + expected = "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + actual = JobServiceClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "whelk", + "tenant": "octopus", + } + path = JobServiceClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_tenant_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "oyster" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = JobServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nudibranch", + } + path = JobServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "cuttlefish" + + expected = "folders/{folder}".format(folder=folder,) + actual = JobServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "mussel", + } + path = JobServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "winkle" + + expected = "organizations/{organization}".format(organization=organization,) + actual = JobServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nautilus", + } + path = JobServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "scallop" + + expected = "projects/{project}".format(project=project,) + actual = JobServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "abalone", + } + path = JobServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "squid" + location = "clam" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = JobServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = JobServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.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/talent_v4/test_tenant_service.py b/tests/unit/gapic/talent_v4/test_tenant_service.py index 7e7b35b1..32438832 100644 --- a/tests/unit/gapic/talent_v4/test_tenant_service.py +++ b/tests/unit/gapic/talent_v4/test_tenant_service.py @@ -97,12 +97,12 @@ def test_tenant_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_tenant_service_client_get_transport_class(): @@ -452,7 +452,7 @@ def test_create_tenant( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant( name="name_value", external_id="external_id_value", @@ -467,6 +467,7 @@ def test_create_tenant( assert args[0] == tenant_service.CreateTenantRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) assert response.name == "name_value" @@ -479,19 +480,19 @@ def test_create_tenant_from_dict(): @pytest.mark.asyncio -async def test_create_tenant_async(transport: str = "grpc_asyncio"): +async def test_create_tenant_async( + transport: str = "grpc_asyncio", request_type=tenant_service.CreateTenantRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.CreateTenantRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_tenant.Tenant(name="name_value", external_id="external_id_value",) @@ -503,7 +504,7 @@ async def test_create_tenant_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.CreateTenantRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_tenant.Tenant) @@ -513,6 +514,11 @@ async def test_create_tenant_async(transport: str = "grpc_asyncio"): assert response.external_id == "external_id_value" +@pytest.mark.asyncio +async def test_create_tenant_async_from_dict(): + await test_create_tenant_async(request_type=dict) + + def test_create_tenant_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -522,7 +528,7 @@ def test_create_tenant_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_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: call.return_value = gct_tenant.Tenant() client.create_tenant(request) @@ -547,9 +553,7 @@ async def test_create_tenant_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_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) await client.create_tenant(request) @@ -568,7 +572,7 @@ def test_create_tenant_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant() @@ -606,9 +610,7 @@ async def test_create_tenant_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant() @@ -655,7 +657,7 @@ def test_get_tenant( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant.Tenant( name="name_value", external_id="external_id_value", @@ -670,6 +672,7 @@ def test_get_tenant( assert args[0] == tenant_service.GetTenantRequest() # Establish that the response is the type that we expect. + assert isinstance(response, tenant.Tenant) assert response.name == "name_value" @@ -682,19 +685,19 @@ def test_get_tenant_from_dict(): @pytest.mark.asyncio -async def test_get_tenant_async(transport: str = "grpc_asyncio"): +async def test_get_tenant_async( + transport: str = "grpc_asyncio", request_type=tenant_service.GetTenantRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.GetTenantRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tenant.Tenant(name="name_value", external_id="external_id_value",) @@ -706,7 +709,7 @@ async def test_get_tenant_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.GetTenantRequest() # Establish that the response is the type that we expect. assert isinstance(response, tenant.Tenant) @@ -716,6 +719,11 @@ async def test_get_tenant_async(transport: str = "grpc_asyncio"): assert response.external_id == "external_id_value" +@pytest.mark.asyncio +async def test_get_tenant_async_from_dict(): + await test_get_tenant_async(request_type=dict) + + def test_get_tenant_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -725,7 +733,7 @@ def test_get_tenant_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_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: call.return_value = tenant.Tenant() client.get_tenant(request) @@ -750,9 +758,7 @@ async def test_get_tenant_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_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) await client.get_tenant(request) @@ -771,7 +777,7 @@ def test_get_tenant_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant.Tenant() @@ -803,9 +809,7 @@ async def test_get_tenant_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant.Tenant() @@ -846,7 +850,7 @@ def test_update_tenant( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant( name="name_value", external_id="external_id_value", @@ -861,6 +865,7 @@ def test_update_tenant( assert args[0] == tenant_service.UpdateTenantRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) assert response.name == "name_value" @@ -873,19 +878,19 @@ def test_update_tenant_from_dict(): @pytest.mark.asyncio -async def test_update_tenant_async(transport: str = "grpc_asyncio"): +async def test_update_tenant_async( + transport: str = "grpc_asyncio", request_type=tenant_service.UpdateTenantRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.UpdateTenantRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_tenant.Tenant(name="name_value", external_id="external_id_value",) @@ -897,7 +902,7 @@ async def test_update_tenant_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.UpdateTenantRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_tenant.Tenant) @@ -907,6 +912,11 @@ async def test_update_tenant_async(transport: str = "grpc_asyncio"): assert response.external_id == "external_id_value" +@pytest.mark.asyncio +async def test_update_tenant_async_from_dict(): + await test_update_tenant_async(request_type=dict) + + def test_update_tenant_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -916,7 +926,7 @@ def test_update_tenant_field_headers(): request.tenant.name = "tenant.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: call.return_value = gct_tenant.Tenant() client.update_tenant(request) @@ -941,9 +951,7 @@ async def test_update_tenant_field_headers_async(): request.tenant.name = "tenant.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) await client.update_tenant(request) @@ -962,7 +970,7 @@ def test_update_tenant_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant() @@ -1001,9 +1009,7 @@ async def test_update_tenant_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant() @@ -1051,7 +1057,7 @@ def test_delete_tenant( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1072,19 +1078,19 @@ def test_delete_tenant_from_dict(): @pytest.mark.asyncio -async def test_delete_tenant_async(transport: str = "grpc_asyncio"): +async def test_delete_tenant_async( + transport: str = "grpc_asyncio", request_type=tenant_service.DeleteTenantRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.DeleteTenantRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1094,12 +1100,17 @@ async def test_delete_tenant_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.DeleteTenantRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_tenant_async_from_dict(): + await test_delete_tenant_async(request_type=dict) + + def test_delete_tenant_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1109,7 +1120,7 @@ def test_delete_tenant_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_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: call.return_value = None client.delete_tenant(request) @@ -1134,9 +1145,7 @@ async def test_delete_tenant_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_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_tenant(request) @@ -1155,7 +1164,7 @@ def test_delete_tenant_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1187,9 +1196,7 @@ async def test_delete_tenant_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1230,7 +1237,7 @@ def test_list_tenants( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant_service.ListTenantsResponse( next_page_token="next_page_token_value", @@ -1245,6 +1252,7 @@ def test_list_tenants( assert args[0] == tenant_service.ListTenantsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTenantsPager) assert response.next_page_token == "next_page_token_value" @@ -1255,19 +1263,19 @@ def test_list_tenants_from_dict(): @pytest.mark.asyncio -async def test_list_tenants_async(transport: str = "grpc_asyncio"): +async def test_list_tenants_async( + transport: str = "grpc_asyncio", request_type=tenant_service.ListTenantsRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.ListTenantsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_tenants), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tenant_service.ListTenantsResponse(next_page_token="next_page_token_value",) @@ -1279,7 +1287,7 @@ async def test_list_tenants_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.ListTenantsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTenantsAsyncPager) @@ -1287,6 +1295,11 @@ async def test_list_tenants_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_tenants_async_from_dict(): + await test_list_tenants_async(request_type=dict) + + def test_list_tenants_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1296,7 +1309,7 @@ def test_list_tenants_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_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: call.return_value = tenant_service.ListTenantsResponse() client.list_tenants(request) @@ -1321,9 +1334,7 @@ async def test_list_tenants_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_tenants), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tenant_service.ListTenantsResponse() ) @@ -1344,7 +1355,7 @@ def test_list_tenants_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant_service.ListTenantsResponse() @@ -1376,9 +1387,7 @@ async def test_list_tenants_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_tenants), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant_service.ListTenantsResponse() @@ -1413,7 +1422,7 @@ def test_list_tenants_pager(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( tenant_service.ListTenantsResponse( @@ -1447,7 +1456,7 @@ def test_list_tenants_pages(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( tenant_service.ListTenantsResponse( @@ -1474,9 +1483,7 @@ async def test_list_tenants_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_tenants), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_tenants), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1509,9 +1516,7 @@ async def test_list_tenants_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_tenants), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_tenants), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1571,7 +1576,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = TenantServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -1607,7 +1612,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.TenantServiceGrpcTransport,) + assert isinstance(client.transport, transports.TenantServiceGrpcTransport,) def test_tenant_service_base_transport_error(): @@ -1712,7 +1717,7 @@ def test_tenant_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_tenant_service_host_with_port(): @@ -1722,7 +1727,7 @@ def test_tenant_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_tenant_service_grpc_transport_channel(): @@ -1734,6 +1739,7 @@ def test_tenant_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_tenant_service_grpc_asyncio_transport_channel(): @@ -1745,6 +1751,7 @@ def test_tenant_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( @@ -1791,8 +1798,13 @@ def test_tenant_service_transport_channel_mtls_with_client_cert_source(transport ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -1834,6 +1846,10 @@ def test_tenant_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel @@ -1861,6 +1877,107 @@ def test_parse_tenant_path(): assert expected == actual +def test_common_billing_account_path(): + billing_account = "oyster" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = TenantServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nudibranch", + } + path = TenantServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "cuttlefish" + + expected = "folders/{folder}".format(folder=folder,) + actual = TenantServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "mussel", + } + path = TenantServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "winkle" + + expected = "organizations/{organization}".format(organization=organization,) + actual = TenantServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nautilus", + } + path = TenantServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "scallop" + + expected = "projects/{project}".format(project=project,) + actual = TenantServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "abalone", + } + path = TenantServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "squid" + location = "clam" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = TenantServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = TenantServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.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/talent_v4beta1/test_application_service.py b/tests/unit/gapic/talent_v4beta1/test_application_service.py index 904d4543..9504a896 100644 --- a/tests/unit/gapic/talent_v4beta1/test_application_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_application_service.py @@ -106,12 +106,12 @@ def test_application_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_application_service_client_get_transport_class(): @@ -472,7 +472,7 @@ def test_create_application( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_application), "__call__" + type(client.transport.create_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gct_application.Application( @@ -497,6 +497,7 @@ def test_create_application( assert args[0] == application_service.CreateApplicationRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_application.Application) assert response.name == "name_value" @@ -525,18 +526,21 @@ def test_create_application_from_dict(): @pytest.mark.asyncio -async def test_create_application_async(transport: str = "grpc_asyncio"): +async def test_create_application_async( + transport: str = "grpc_asyncio", + request_type=application_service.CreateApplicationRequest, +): client = ApplicationServiceAsyncClient( 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 = application_service.CreateApplicationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_application), "__call__" + type(client.transport.create_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -560,7 +564,7 @@ async def test_create_application_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == application_service.CreateApplicationRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_application.Application) @@ -586,6 +590,11 @@ async def test_create_application_async(transport: str = "grpc_asyncio"): assert response.job_title_snippet == "job_title_snippet_value" +@pytest.mark.asyncio +async def test_create_application_async_from_dict(): + await test_create_application_async(request_type=dict) + + def test_create_application_field_headers(): client = ApplicationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -596,7 +605,7 @@ def test_create_application_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_application), "__call__" + type(client.transport.create_application), "__call__" ) as call: call.return_value = gct_application.Application() @@ -625,7 +634,7 @@ async def test_create_application_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_application), "__call__" + type(client.transport.create_application), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_application.Application() @@ -648,7 +657,7 @@ def test_create_application_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_application), "__call__" + type(client.transport.create_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gct_application.Application() @@ -691,7 +700,7 @@ async def test_create_application_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_application), "__call__" + type(client.transport.create_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gct_application.Application() @@ -744,7 +753,7 @@ def test_get_application( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_application), "__call__") as call: + with mock.patch.object(type(client.transport.get_application), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = application.Application( name="name_value", @@ -768,6 +777,7 @@ def test_get_application( assert args[0] == application_service.GetApplicationRequest() # Establish that the response is the type that we expect. + assert isinstance(response, application.Application) assert response.name == "name_value" @@ -796,19 +806,20 @@ def test_get_application_from_dict(): @pytest.mark.asyncio -async def test_get_application_async(transport: str = "grpc_asyncio"): +async def test_get_application_async( + transport: str = "grpc_asyncio", + request_type=application_service.GetApplicationRequest, +): client = ApplicationServiceAsyncClient( 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 = application_service.GetApplicationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_application), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_application), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( application.Application( @@ -831,7 +842,7 @@ async def test_get_application_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == application_service.GetApplicationRequest() # Establish that the response is the type that we expect. assert isinstance(response, application.Application) @@ -857,6 +868,11 @@ async def test_get_application_async(transport: str = "grpc_asyncio"): assert response.job_title_snippet == "job_title_snippet_value" +@pytest.mark.asyncio +async def test_get_application_async_from_dict(): + await test_get_application_async(request_type=dict) + + def test_get_application_field_headers(): client = ApplicationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -866,7 +882,7 @@ def test_get_application_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_application), "__call__") as call: + with mock.patch.object(type(client.transport.get_application), "__call__") as call: call.return_value = application.Application() client.get_application(request) @@ -893,9 +909,7 @@ async def test_get_application_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_application), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_application), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( application.Application() ) @@ -916,7 +930,7 @@ def test_get_application_flattened(): client = ApplicationServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_application), "__call__") as call: + with mock.patch.object(type(client.transport.get_application), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = application.Application() @@ -950,9 +964,7 @@ async def test_get_application_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_application), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_application), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = application.Application() @@ -998,7 +1010,7 @@ def test_update_application( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_application), "__call__" + type(client.transport.update_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gct_application.Application( @@ -1023,6 +1035,7 @@ def test_update_application( assert args[0] == application_service.UpdateApplicationRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_application.Application) assert response.name == "name_value" @@ -1051,18 +1064,21 @@ def test_update_application_from_dict(): @pytest.mark.asyncio -async def test_update_application_async(transport: str = "grpc_asyncio"): +async def test_update_application_async( + transport: str = "grpc_asyncio", + request_type=application_service.UpdateApplicationRequest, +): client = ApplicationServiceAsyncClient( 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 = application_service.UpdateApplicationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_application), "__call__" + type(client.transport.update_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1086,7 +1102,7 @@ async def test_update_application_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == application_service.UpdateApplicationRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_application.Application) @@ -1112,6 +1128,11 @@ async def test_update_application_async(transport: str = "grpc_asyncio"): assert response.job_title_snippet == "job_title_snippet_value" +@pytest.mark.asyncio +async def test_update_application_async_from_dict(): + await test_update_application_async(request_type=dict) + + def test_update_application_field_headers(): client = ApplicationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1122,7 +1143,7 @@ def test_update_application_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_application), "__call__" + type(client.transport.update_application), "__call__" ) as call: call.return_value = gct_application.Application() @@ -1153,7 +1174,7 @@ async def test_update_application_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_application), "__call__" + type(client.transport.update_application), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_application.Application() @@ -1178,7 +1199,7 @@ def test_update_application_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_application), "__call__" + type(client.transport.update_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gct_application.Application() @@ -1217,7 +1238,7 @@ async def test_update_application_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_application), "__call__" + type(client.transport.update_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gct_application.Application() @@ -1267,7 +1288,7 @@ def test_delete_application( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_application), "__call__" + type(client.transport.delete_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1289,18 +1310,21 @@ def test_delete_application_from_dict(): @pytest.mark.asyncio -async def test_delete_application_async(transport: str = "grpc_asyncio"): +async def test_delete_application_async( + transport: str = "grpc_asyncio", + request_type=application_service.DeleteApplicationRequest, +): client = ApplicationServiceAsyncClient( 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 = application_service.DeleteApplicationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_application), "__call__" + type(client.transport.delete_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1311,12 +1335,17 @@ async def test_delete_application_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == application_service.DeleteApplicationRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_application_async_from_dict(): + await test_delete_application_async(request_type=dict) + + def test_delete_application_field_headers(): client = ApplicationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1327,7 +1356,7 @@ def test_delete_application_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_application), "__call__" + type(client.transport.delete_application), "__call__" ) as call: call.return_value = None @@ -1356,7 +1385,7 @@ async def test_delete_application_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_application), "__call__" + type(client.transport.delete_application), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1377,7 +1406,7 @@ def test_delete_application_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_application), "__call__" + type(client.transport.delete_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1413,7 +1442,7 @@ async def test_delete_application_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_application), "__call__" + type(client.transport.delete_application), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1458,7 +1487,7 @@ def test_list_applications( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_applications), "__call__" + type(client.transport.list_applications), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = application_service.ListApplicationsResponse( @@ -1474,6 +1503,7 @@ def test_list_applications( assert args[0] == application_service.ListApplicationsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListApplicationsPager) assert response.next_page_token == "next_page_token_value" @@ -1484,18 +1514,21 @@ def test_list_applications_from_dict(): @pytest.mark.asyncio -async def test_list_applications_async(transport: str = "grpc_asyncio"): +async def test_list_applications_async( + transport: str = "grpc_asyncio", + request_type=application_service.ListApplicationsRequest, +): client = ApplicationServiceAsyncClient( 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 = application_service.ListApplicationsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_applications), "__call__" + type(client.transport.list_applications), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1510,7 +1543,7 @@ async def test_list_applications_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == application_service.ListApplicationsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListApplicationsAsyncPager) @@ -1518,6 +1551,11 @@ async def test_list_applications_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_applications_async_from_dict(): + await test_list_applications_async(request_type=dict) + + def test_list_applications_field_headers(): client = ApplicationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1528,7 +1566,7 @@ def test_list_applications_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_applications), "__call__" + type(client.transport.list_applications), "__call__" ) as call: call.return_value = application_service.ListApplicationsResponse() @@ -1557,7 +1595,7 @@ async def test_list_applications_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_applications), "__call__" + type(client.transport.list_applications), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( application_service.ListApplicationsResponse() @@ -1580,7 +1618,7 @@ def test_list_applications_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_applications), "__call__" + type(client.transport.list_applications), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = application_service.ListApplicationsResponse() @@ -1616,7 +1654,7 @@ async def test_list_applications_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_applications), "__call__" + type(client.transport.list_applications), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = application_service.ListApplicationsResponse() @@ -1655,7 +1693,7 @@ def test_list_applications_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_applications), "__call__" + type(client.transport.list_applications), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1697,7 +1735,7 @@ def test_list_applications_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_applications), "__call__" + type(client.transport.list_applications), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1733,7 +1771,7 @@ async def test_list_applications_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_applications), + type(client.transport.list_applications), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -1776,7 +1814,7 @@ async def test_list_applications_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_applications), + type(client.transport.list_applications), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -1844,7 +1882,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = ApplicationServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -1880,7 +1918,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = ApplicationServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.ApplicationServiceGrpcTransport,) + assert isinstance(client.transport, transports.ApplicationServiceGrpcTransport,) def test_application_service_base_transport_error(): @@ -1985,7 +2023,7 @@ def test_application_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_application_service_host_with_port(): @@ -1995,7 +2033,7 @@ def test_application_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_application_service_grpc_transport_channel(): @@ -2007,6 +2045,7 @@ def test_application_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_application_service_grpc_asyncio_transport_channel(): @@ -2018,6 +2057,7 @@ def test_application_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( @@ -2066,8 +2106,13 @@ def test_application_service_transport_channel_mtls_with_client_cert_source( ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -2109,6 +2154,10 @@ def test_application_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel @@ -2142,6 +2191,182 @@ def test_parse_application_path(): assert expected == actual +def test_company_path(): + project = "winkle" + tenant = "nautilus" + company = "scallop" + + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + actual = ApplicationServiceClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "abalone", + "tenant": "squid", + "company": "clam", + } + path = ApplicationServiceClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = ApplicationServiceClient.parse_company_path(path) + assert expected == actual + + +def test_job_path(): + project = "whelk" + tenant = "octopus" + job = "oyster" + + expected = "projects/{project}/tenants/{tenant}/jobs/{job}".format( + project=project, tenant=tenant, job=job, + ) + actual = ApplicationServiceClient.job_path(project, tenant, job) + assert expected == actual + + +def test_parse_job_path(): + expected = { + "project": "nudibranch", + "tenant": "cuttlefish", + "job": "mussel", + } + path = ApplicationServiceClient.job_path(**expected) + + # Check that the path construction is reversible. + actual = ApplicationServiceClient.parse_job_path(path) + assert expected == actual + + +def test_profile_path(): + project = "winkle" + tenant = "nautilus" + profile = "scallop" + + expected = "projects/{project}/tenants/{tenant}/profiles/{profile}".format( + project=project, tenant=tenant, profile=profile, + ) + actual = ApplicationServiceClient.profile_path(project, tenant, profile) + assert expected == actual + + +def test_parse_profile_path(): + expected = { + "project": "abalone", + "tenant": "squid", + "profile": "clam", + } + path = ApplicationServiceClient.profile_path(**expected) + + # Check that the path construction is reversible. + actual = ApplicationServiceClient.parse_profile_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "whelk" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = ApplicationServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "octopus", + } + path = ApplicationServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = ApplicationServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "oyster" + + expected = "folders/{folder}".format(folder=folder,) + actual = ApplicationServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nudibranch", + } + path = ApplicationServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = ApplicationServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "cuttlefish" + + expected = "organizations/{organization}".format(organization=organization,) + actual = ApplicationServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "mussel", + } + path = ApplicationServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = ApplicationServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "winkle" + + expected = "projects/{project}".format(project=project,) + actual = ApplicationServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nautilus", + } + path = ApplicationServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = ApplicationServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "scallop" + location = "abalone" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = ApplicationServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "squid", + "location": "clam", + } + path = ApplicationServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = ApplicationServiceClient.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/talent_v4beta1/test_company_service.py b/tests/unit/gapic/talent_v4beta1/test_company_service.py index 317b328f..603a1904 100644 --- a/tests/unit/gapic/talent_v4beta1/test_company_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_company_service.py @@ -45,7 +45,7 @@ from google.oauth2 import service_account from google.protobuf import field_mask_pb2 as field_mask # type: ignore from google.type import latlng_pb2 as latlng # type: ignore -from google.type import postal_address_pb2 as gt_postal_address # type: ignore +from google.type import postal_address_pb2 as postal_address # type: ignore def client_cert_source_callback(): @@ -102,12 +102,12 @@ def test_company_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_company_service_client_get_transport_class(): @@ -457,7 +457,7 @@ def test_create_company( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_company), "__call__") as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company( name="name_value", @@ -485,6 +485,7 @@ def test_create_company( assert args[0] == company_service.CreateCompanyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) assert response.name == "name_value" @@ -519,19 +520,19 @@ def test_create_company_from_dict(): @pytest.mark.asyncio -async def test_create_company_async(transport: str = "grpc_asyncio"): +async def test_create_company_async( + transport: str = "grpc_asyncio", request_type=company_service.CreateCompanyRequest +): client = CompanyServiceAsyncClient( 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 = company_service.CreateCompanyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_company.Company( @@ -558,7 +559,7 @@ async def test_create_company_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.CreateCompanyRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_company.Company) @@ -590,6 +591,11 @@ async def test_create_company_async(transport: str = "grpc_asyncio"): assert response.suspended is True +@pytest.mark.asyncio +async def test_create_company_async_from_dict(): + await test_create_company_async(request_type=dict) + + def test_create_company_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -599,7 +605,7 @@ def test_create_company_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_company), "__call__") as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: call.return_value = gct_company.Company() client.create_company(request) @@ -624,9 +630,7 @@ async def test_create_company_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_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) await client.create_company(request) @@ -645,7 +649,7 @@ def test_create_company_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_company), "__call__") as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company() @@ -683,9 +687,7 @@ async def test_create_company_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company() @@ -732,7 +734,7 @@ def test_get_company( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_company), "__call__") as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company.Company( name="name_value", @@ -760,6 +762,7 @@ def test_get_company( assert args[0] == company_service.GetCompanyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, company.Company) assert response.name == "name_value" @@ -794,19 +797,19 @@ def test_get_company_from_dict(): @pytest.mark.asyncio -async def test_get_company_async(transport: str = "grpc_asyncio"): +async def test_get_company_async( + transport: str = "grpc_asyncio", request_type=company_service.GetCompanyRequest +): client = CompanyServiceAsyncClient( 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 = company_service.GetCompanyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( company.Company( @@ -833,7 +836,7 @@ async def test_get_company_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.GetCompanyRequest() # Establish that the response is the type that we expect. assert isinstance(response, company.Company) @@ -865,6 +868,11 @@ async def test_get_company_async(transport: str = "grpc_asyncio"): assert response.suspended is True +@pytest.mark.asyncio +async def test_get_company_async_from_dict(): + await test_get_company_async(request_type=dict) + + def test_get_company_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -874,7 +882,7 @@ def test_get_company_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_company), "__call__") as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: call.return_value = company.Company() client.get_company(request) @@ -899,9 +907,7 @@ async def test_get_company_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_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(company.Company()) await client.get_company(request) @@ -920,7 +926,7 @@ def test_get_company_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_company), "__call__") as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company.Company() @@ -952,9 +958,7 @@ async def test_get_company_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company.Company() @@ -995,7 +999,7 @@ def test_update_company( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_company), "__call__") as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company( name="name_value", @@ -1023,6 +1027,7 @@ def test_update_company( assert args[0] == company_service.UpdateCompanyRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_company.Company) assert response.name == "name_value" @@ -1057,19 +1062,19 @@ def test_update_company_from_dict(): @pytest.mark.asyncio -async def test_update_company_async(transport: str = "grpc_asyncio"): +async def test_update_company_async( + transport: str = "grpc_asyncio", request_type=company_service.UpdateCompanyRequest +): client = CompanyServiceAsyncClient( 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 = company_service.UpdateCompanyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_company.Company( @@ -1096,7 +1101,7 @@ async def test_update_company_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.UpdateCompanyRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_company.Company) @@ -1128,6 +1133,11 @@ async def test_update_company_async(transport: str = "grpc_asyncio"): assert response.suspended is True +@pytest.mark.asyncio +async def test_update_company_async_from_dict(): + await test_update_company_async(request_type=dict) + + def test_update_company_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1137,7 +1147,7 @@ def test_update_company_field_headers(): request.company.name = "company.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_company), "__call__") as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: call.return_value = gct_company.Company() client.update_company(request) @@ -1164,9 +1174,7 @@ async def test_update_company_field_headers_async(): request.company.name = "company.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_company.Company()) await client.update_company(request) @@ -1187,7 +1195,7 @@ def test_update_company_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_company), "__call__") as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company() @@ -1220,9 +1228,7 @@ async def test_update_company_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_company.Company() @@ -1266,7 +1272,7 @@ def test_delete_company( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_company), "__call__") as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1287,19 +1293,19 @@ def test_delete_company_from_dict(): @pytest.mark.asyncio -async def test_delete_company_async(transport: str = "grpc_asyncio"): +async def test_delete_company_async( + transport: str = "grpc_asyncio", request_type=company_service.DeleteCompanyRequest +): client = CompanyServiceAsyncClient( 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 = company_service.DeleteCompanyRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1309,12 +1315,17 @@ async def test_delete_company_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.DeleteCompanyRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_company_async_from_dict(): + await test_delete_company_async(request_type=dict) + + def test_delete_company_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1324,7 +1335,7 @@ def test_delete_company_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_company), "__call__") as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: call.return_value = None client.delete_company(request) @@ -1349,9 +1360,7 @@ async def test_delete_company_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_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_company(request) @@ -1370,7 +1379,7 @@ def test_delete_company_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_company), "__call__") as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1402,9 +1411,7 @@ async def test_delete_company_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_company), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_company), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1445,7 +1452,7 @@ def test_list_companies( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company_service.ListCompaniesResponse( next_page_token="next_page_token_value", @@ -1460,6 +1467,7 @@ def test_list_companies( assert args[0] == company_service.ListCompaniesRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCompaniesPager) assert response.next_page_token == "next_page_token_value" @@ -1470,19 +1478,19 @@ def test_list_companies_from_dict(): @pytest.mark.asyncio -async def test_list_companies_async(transport: str = "grpc_asyncio"): +async def test_list_companies_async( + transport: str = "grpc_asyncio", request_type=company_service.ListCompaniesRequest +): client = CompanyServiceAsyncClient( 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 = company_service.ListCompaniesRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_companies), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( company_service.ListCompaniesResponse( @@ -1496,7 +1504,7 @@ async def test_list_companies_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == company_service.ListCompaniesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCompaniesAsyncPager) @@ -1504,6 +1512,11 @@ async def test_list_companies_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_companies_async_from_dict(): + await test_list_companies_async(request_type=dict) + + def test_list_companies_field_headers(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1513,7 +1526,7 @@ def test_list_companies_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_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: call.return_value = company_service.ListCompaniesResponse() client.list_companies(request) @@ -1538,9 +1551,7 @@ async def test_list_companies_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_companies), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( company_service.ListCompaniesResponse() ) @@ -1561,7 +1572,7 @@ def test_list_companies_flattened(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company_service.ListCompaniesResponse() @@ -1593,9 +1604,7 @@ async def test_list_companies_flattened_async(): client = CompanyServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_companies), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = company_service.ListCompaniesResponse() @@ -1630,7 +1639,7 @@ def test_list_companies_pager(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( company_service.ListCompaniesResponse( @@ -1664,7 +1673,7 @@ def test_list_companies_pages(): client = CompanyServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_companies), "__call__") as call: + with mock.patch.object(type(client.transport.list_companies), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( company_service.ListCompaniesResponse( @@ -1691,9 +1700,7 @@ async def test_list_companies_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_companies), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_companies), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1726,9 +1733,7 @@ async def test_list_companies_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_companies), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_companies), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1788,7 +1793,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = CompanyServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -1824,7 +1829,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = CompanyServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.CompanyServiceGrpcTransport,) + assert isinstance(client.transport, transports.CompanyServiceGrpcTransport,) def test_company_service_base_transport_error(): @@ -1929,7 +1934,7 @@ def test_company_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_company_service_host_with_port(): @@ -1939,7 +1944,7 @@ def test_company_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_company_service_grpc_transport_channel(): @@ -1951,6 +1956,7 @@ def test_company_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_company_service_grpc_asyncio_transport_channel(): @@ -1962,6 +1968,7 @@ def test_company_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( @@ -2010,8 +2017,13 @@ def test_company_service_transport_channel_mtls_with_client_cert_source( ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -2053,6 +2065,10 @@ def test_company_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel @@ -2082,6 +2098,107 @@ def test_parse_company_path(): assert expected == actual +def test_common_billing_account_path(): + billing_account = "cuttlefish" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = CompanyServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = CompanyServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "winkle" + + expected = "folders/{folder}".format(folder=folder,) + actual = CompanyServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = CompanyServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "scallop" + + expected = "organizations/{organization}".format(organization=organization,) + actual = CompanyServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = CompanyServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "squid" + + expected = "projects/{project}".format(project=project,) + actual = CompanyServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = CompanyServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "whelk" + location = "octopus" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = CompanyServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = CompanyServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CompanyServiceClient.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/talent_v4beta1/test_completion.py b/tests/unit/gapic/talent_v4beta1/test_completion.py index eda690c7..b03a7da9 100644 --- a/tests/unit/gapic/talent_v4beta1/test_completion.py +++ b/tests/unit/gapic/talent_v4beta1/test_completion.py @@ -89,12 +89,12 @@ def test_completion_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_completion_client_get_transport_class(): @@ -438,7 +438,7 @@ def test_complete_query( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.complete_query), "__call__") as call: + with mock.patch.object(type(client.transport.complete_query), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = completion_service.CompleteQueryResponse() @@ -451,6 +451,7 @@ def test_complete_query( assert args[0] == completion_service.CompleteQueryRequest() # Establish that the response is the type that we expect. + assert isinstance(response, completion_service.CompleteQueryResponse) @@ -459,19 +460,20 @@ def test_complete_query_from_dict(): @pytest.mark.asyncio -async def test_complete_query_async(transport: str = "grpc_asyncio"): +async def test_complete_query_async( + transport: str = "grpc_asyncio", + request_type=completion_service.CompleteQueryRequest, +): client = CompletionAsyncClient( 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 = completion_service.CompleteQueryRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.complete_query), "__call__" - ) as call: + with mock.patch.object(type(client.transport.complete_query), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( completion_service.CompleteQueryResponse() @@ -483,12 +485,17 @@ async def test_complete_query_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == completion_service.CompleteQueryRequest() # Establish that the response is the type that we expect. assert isinstance(response, completion_service.CompleteQueryResponse) +@pytest.mark.asyncio +async def test_complete_query_async_from_dict(): + await test_complete_query_async(request_type=dict) + + def test_complete_query_field_headers(): client = CompletionClient(credentials=credentials.AnonymousCredentials(),) @@ -498,7 +505,7 @@ def test_complete_query_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.complete_query), "__call__") as call: + with mock.patch.object(type(client.transport.complete_query), "__call__") as call: call.return_value = completion_service.CompleteQueryResponse() client.complete_query(request) @@ -523,9 +530,7 @@ async def test_complete_query_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.complete_query), "__call__" - ) as call: + with mock.patch.object(type(client.transport.complete_query), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( completion_service.CompleteQueryResponse() ) @@ -578,7 +583,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = CompletionClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -611,7 +616,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = CompletionClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.CompletionGrpcTransport,) + assert isinstance(client.transport, transports.CompletionGrpcTransport,) def test_completion_base_transport_error(): @@ -710,7 +715,7 @@ def test_completion_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_completion_host_with_port(): @@ -720,7 +725,7 @@ def test_completion_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_completion_grpc_transport_channel(): @@ -732,6 +737,7 @@ def test_completion_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_completion_grpc_asyncio_transport_channel(): @@ -743,6 +749,7 @@ def test_completion_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( @@ -786,8 +793,13 @@ def test_completion_transport_channel_mtls_with_client_cert_source(transport_cla ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -826,10 +838,140 @@ def test_completion_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel +def test_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + actual = CompletionClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = CompletionClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_company_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = CompletionClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = CompletionClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "winkle" + + expected = "folders/{folder}".format(folder=folder,) + actual = CompletionClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = CompletionClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "scallop" + + expected = "organizations/{organization}".format(organization=organization,) + actual = CompletionClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = CompletionClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "squid" + + expected = "projects/{project}".format(project=project,) + actual = CompletionClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = CompletionClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "whelk" + location = "octopus" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = CompletionClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = CompletionClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = CompletionClient.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/talent_v4beta1/test_event_service.py b/tests/unit/gapic/talent_v4beta1/test_event_service.py index fb617f2d..a5f2b7c0 100644 --- a/tests/unit/gapic/talent_v4beta1/test_event_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_event_service.py @@ -90,12 +90,12 @@ def test_event_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_event_service_client_get_transport_class(): @@ -440,7 +440,7 @@ def test_create_client_event( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = event.ClientEvent( @@ -459,6 +459,7 @@ def test_create_client_event( assert args[0] == event_service.CreateClientEventRequest() # Establish that the response is the type that we expect. + assert isinstance(response, event.ClientEvent) assert response.request_id == "request_id_value" @@ -473,18 +474,20 @@ def test_create_client_event_from_dict(): @pytest.mark.asyncio -async def test_create_client_event_async(transport: str = "grpc_asyncio"): +async def test_create_client_event_async( + transport: str = "grpc_asyncio", request_type=event_service.CreateClientEventRequest +): client = EventServiceAsyncClient( 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 = event_service.CreateClientEventRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -501,7 +504,7 @@ async def test_create_client_event_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == event_service.CreateClientEventRequest() # Establish that the response is the type that we expect. assert isinstance(response, event.ClientEvent) @@ -513,6 +516,11 @@ async def test_create_client_event_async(transport: str = "grpc_asyncio"): assert response.event_notes == "event_notes_value" +@pytest.mark.asyncio +async def test_create_client_event_async_from_dict(): + await test_create_client_event_async(request_type=dict) + + def test_create_client_event_field_headers(): client = EventServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -523,7 +531,7 @@ def test_create_client_event_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: call.return_value = event.ClientEvent() @@ -550,7 +558,7 @@ async def test_create_client_event_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(event.ClientEvent()) @@ -571,7 +579,7 @@ def test_create_client_event_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = event.ClientEvent() @@ -612,7 +620,7 @@ async def test_create_client_event_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_client_event), "__call__" + type(client.transport.create_client_event), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = event.ClientEvent() @@ -685,7 +693,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = EventServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -718,7 +726,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = EventServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.EventServiceGrpcTransport,) + assert isinstance(client.transport, transports.EventServiceGrpcTransport,) def test_event_service_base_transport_error(): @@ -817,7 +825,7 @@ def test_event_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_event_service_host_with_port(): @@ -827,7 +835,7 @@ def test_event_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_event_service_grpc_transport_channel(): @@ -839,6 +847,7 @@ def test_event_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_event_service_grpc_asyncio_transport_channel(): @@ -850,6 +859,7 @@ def test_event_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( @@ -893,8 +903,13 @@ def test_event_service_transport_channel_mtls_with_client_cert_source(transport_ ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -933,10 +948,140 @@ def test_event_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel +def test_company_path(): + project = "squid" + tenant = "clam" + company = "whelk" + + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + actual = EventServiceClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = EventServiceClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_company_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "cuttlefish" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = EventServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "mussel", + } + path = EventServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "winkle" + + expected = "folders/{folder}".format(folder=folder,) + actual = EventServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "nautilus", + } + path = EventServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "scallop" + + expected = "organizations/{organization}".format(organization=organization,) + actual = EventServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "abalone", + } + path = EventServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "squid" + + expected = "projects/{project}".format(project=project,) + actual = EventServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "clam", + } + path = EventServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "whelk" + location = "octopus" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = EventServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "oyster", + "location": "nudibranch", + } + path = EventServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = EventServiceClient.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/talent_v4beta1/test_job_service.py b/tests/unit/gapic/talent_v4beta1/test_job_service.py index 9dae40d1..43896c99 100644 --- a/tests/unit/gapic/talent_v4beta1/test_job_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_job_service.py @@ -53,7 +53,7 @@ from google.protobuf import wrappers_pb2 as wrappers # type: ignore from google.type import latlng_pb2 as latlng # type: ignore from google.type import money_pb2 as money # type: ignore -from google.type import postal_address_pb2 as gt_postal_address # type: ignore +from google.type import postal_address_pb2 as postal_address # type: ignore from google.type import timeofday_pb2 as timeofday # type: ignore @@ -106,12 +106,12 @@ def test_job_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_job_service_client_get_transport_class(): @@ -453,7 +453,7 @@ def test_create_job(transport: str = "grpc", request_type=job_service.CreateJobR request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_job), "__call__") as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job( name="name_value", @@ -486,6 +486,7 @@ def test_create_job(transport: str = "grpc", request_type=job_service.CreateJobR assert args[0] == job_service.CreateJobRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) assert response.name == "name_value" @@ -532,19 +533,19 @@ def test_create_job_from_dict(): @pytest.mark.asyncio -async def test_create_job_async(transport: str = "grpc_asyncio"): +async def test_create_job_async( + transport: str = "grpc_asyncio", request_type=job_service.CreateJobRequest +): client = JobServiceAsyncClient( 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 = job_service.CreateJobRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_job.Job( @@ -576,7 +577,7 @@ async def test_create_job_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.CreateJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_job.Job) @@ -620,6 +621,11 @@ async def test_create_job_async(transport: str = "grpc_asyncio"): assert response.company_display_name == "company_display_name_value" +@pytest.mark.asyncio +async def test_create_job_async_from_dict(): + await test_create_job_async(request_type=dict) + + def test_create_job_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -629,7 +635,7 @@ def test_create_job_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_job), "__call__") as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: call.return_value = gct_job.Job() client.create_job(request) @@ -654,9 +660,7 @@ async def test_create_job_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_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) await client.create_job(request) @@ -675,7 +679,7 @@ def test_create_job_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_job), "__call__") as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job() @@ -713,9 +717,7 @@ async def test_create_job_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job() @@ -763,7 +765,7 @@ def test_batch_create_jobs( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") @@ -785,18 +787,20 @@ def test_batch_create_jobs_from_dict(): @pytest.mark.asyncio -async def test_batch_create_jobs_async(transport: str = "grpc_asyncio"): +async def test_batch_create_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.BatchCreateJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.BatchCreateJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -809,12 +813,17 @@ async def test_batch_create_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.BatchCreateJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, future.Future) +@pytest.mark.asyncio +async def test_batch_create_jobs_async_from_dict(): + await test_batch_create_jobs_async(request_type=dict) + + def test_batch_create_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -825,7 +834,7 @@ def test_batch_create_jobs_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") @@ -852,7 +861,7 @@ async def test_batch_create_jobs_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") @@ -875,7 +884,7 @@ def test_batch_create_jobs_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -915,7 +924,7 @@ async def test_batch_create_jobs_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_create_jobs), "__call__" + type(client.transport.batch_create_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -963,7 +972,7 @@ def test_get_job(transport: str = "grpc", request_type=job_service.GetJobRequest request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job.Job( name="name_value", @@ -996,6 +1005,7 @@ def test_get_job(transport: str = "grpc", request_type=job_service.GetJobRequest assert args[0] == job_service.GetJobRequest() # Establish that the response is the type that we expect. + assert isinstance(response, job.Job) assert response.name == "name_value" @@ -1042,17 +1052,19 @@ def test_get_job_from_dict(): @pytest.mark.asyncio -async def test_get_job_async(transport: str = "grpc_asyncio"): +async def test_get_job_async( + transport: str = "grpc_asyncio", request_type=job_service.GetJobRequest +): client = JobServiceAsyncClient( 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 = job_service.GetJobRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._client._transport.get_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job.Job( @@ -1084,7 +1096,7 @@ async def test_get_job_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.GetJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, job.Job) @@ -1128,6 +1140,11 @@ async def test_get_job_async(transport: str = "grpc_asyncio"): assert response.company_display_name == "company_display_name_value" +@pytest.mark.asyncio +async def test_get_job_async_from_dict(): + await test_get_job_async(request_type=dict) + + def test_get_job_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1137,7 +1154,7 @@ def test_get_job_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_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: call.return_value = job.Job() client.get_job(request) @@ -1162,7 +1179,7 @@ async def test_get_job_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_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(job.Job()) await client.get_job(request) @@ -1181,7 +1198,7 @@ def test_get_job_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job.Job() @@ -1213,7 +1230,7 @@ async def test_get_job_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._client._transport.get_job), "__call__") as call: + with mock.patch.object(type(client.transport.get_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job.Job() @@ -1252,7 +1269,7 @@ def test_update_job(transport: str = "grpc", request_type=job_service.UpdateJobR request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_job), "__call__") as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job( name="name_value", @@ -1285,6 +1302,7 @@ def test_update_job(transport: str = "grpc", request_type=job_service.UpdateJobR assert args[0] == job_service.UpdateJobRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_job.Job) assert response.name == "name_value" @@ -1331,19 +1349,19 @@ def test_update_job_from_dict(): @pytest.mark.asyncio -async def test_update_job_async(transport: str = "grpc_asyncio"): +async def test_update_job_async( + transport: str = "grpc_asyncio", request_type=job_service.UpdateJobRequest +): client = JobServiceAsyncClient( 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 = job_service.UpdateJobRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_job.Job( @@ -1375,7 +1393,7 @@ async def test_update_job_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.UpdateJobRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_job.Job) @@ -1419,6 +1437,11 @@ async def test_update_job_async(transport: str = "grpc_asyncio"): assert response.company_display_name == "company_display_name_value" +@pytest.mark.asyncio +async def test_update_job_async_from_dict(): + await test_update_job_async(request_type=dict) + + def test_update_job_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1428,7 +1451,7 @@ def test_update_job_field_headers(): request.job.name = "job.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_job), "__call__") as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: call.return_value = gct_job.Job() client.update_job(request) @@ -1453,9 +1476,7 @@ async def test_update_job_field_headers_async(): request.job.name = "job.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_job.Job()) await client.update_job(request) @@ -1474,7 +1495,7 @@ def test_update_job_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_job), "__call__") as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job() @@ -1506,9 +1527,7 @@ async def test_update_job_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_job.Job() @@ -1550,7 +1569,7 @@ def test_batch_update_jobs( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") @@ -1572,18 +1591,20 @@ def test_batch_update_jobs_from_dict(): @pytest.mark.asyncio -async def test_batch_update_jobs_async(transport: str = "grpc_asyncio"): +async def test_batch_update_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.BatchUpdateJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.BatchUpdateJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1596,12 +1617,17 @@ async def test_batch_update_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.BatchUpdateJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, future.Future) +@pytest.mark.asyncio +async def test_batch_update_jobs_async_from_dict(): + await test_batch_update_jobs_async(request_type=dict) + + def test_batch_update_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1612,7 +1638,7 @@ def test_batch_update_jobs_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: call.return_value = operations_pb2.Operation(name="operations/op") @@ -1639,7 +1665,7 @@ async def test_batch_update_jobs_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/op") @@ -1662,7 +1688,7 @@ def test_batch_update_jobs_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -1702,7 +1728,7 @@ async def test_batch_update_jobs_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_update_jobs), "__call__" + type(client.transport.batch_update_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") @@ -1750,7 +1776,7 @@ def test_delete_job(transport: str = "grpc", request_type=job_service.DeleteJobR request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_job), "__call__") as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1771,19 +1797,19 @@ def test_delete_job_from_dict(): @pytest.mark.asyncio -async def test_delete_job_async(transport: str = "grpc_asyncio"): +async def test_delete_job_async( + transport: str = "grpc_asyncio", request_type=job_service.DeleteJobRequest +): client = JobServiceAsyncClient( 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 = job_service.DeleteJobRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1793,12 +1819,17 @@ async def test_delete_job_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.DeleteJobRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_job_async_from_dict(): + await test_delete_job_async(request_type=dict) + + def test_delete_job_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1808,7 +1839,7 @@ def test_delete_job_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_job), "__call__") as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: call.return_value = None client.delete_job(request) @@ -1833,9 +1864,7 @@ async def test_delete_job_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_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_job(request) @@ -1854,7 +1883,7 @@ def test_delete_job_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_job), "__call__") as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1886,9 +1915,7 @@ async def test_delete_job_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_job), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_job), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1930,7 +1957,7 @@ def test_batch_delete_jobs( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1952,18 +1979,20 @@ def test_batch_delete_jobs_from_dict(): @pytest.mark.asyncio -async def test_batch_delete_jobs_async(transport: str = "grpc_asyncio"): +async def test_batch_delete_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.BatchDeleteJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.BatchDeleteJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1974,12 +2003,17 @@ async def test_batch_delete_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.BatchDeleteJobsRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_batch_delete_jobs_async_from_dict(): + await test_batch_delete_jobs_async(request_type=dict) + + def test_batch_delete_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1990,7 +2024,7 @@ def test_batch_delete_jobs_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: call.return_value = None @@ -2017,7 +2051,7 @@ async def test_batch_delete_jobs_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -2038,7 +2072,7 @@ def test_batch_delete_jobs_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -2078,7 +2112,7 @@ async def test_batch_delete_jobs_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.batch_delete_jobs), "__call__" + type(client.transport.batch_delete_jobs), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -2124,7 +2158,7 @@ def test_list_jobs(transport: str = "grpc", request_type=job_service.ListJobsReq request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListJobsResponse( next_page_token="next_page_token_value", @@ -2139,6 +2173,7 @@ def test_list_jobs(transport: str = "grpc", request_type=job_service.ListJobsReq assert args[0] == job_service.ListJobsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListJobsPager) assert response.next_page_token == "next_page_token_value" @@ -2149,19 +2184,19 @@ def test_list_jobs_from_dict(): @pytest.mark.asyncio -async def test_list_jobs_async(transport: str = "grpc_asyncio"): +async def test_list_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.ListJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.ListJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListJobsResponse(next_page_token="next_page_token_value",) @@ -2173,7 +2208,7 @@ async def test_list_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.ListJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListJobsAsyncPager) @@ -2181,6 +2216,11 @@ async def test_list_jobs_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_jobs_async_from_dict(): + await test_list_jobs_async(request_type=dict) + + def test_list_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2190,7 +2230,7 @@ def test_list_jobs_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_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: call.return_value = job_service.ListJobsResponse() client.list_jobs(request) @@ -2215,9 +2255,7 @@ async def test_list_jobs_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_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.ListJobsResponse() ) @@ -2238,7 +2276,7 @@ def test_list_jobs_flattened(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListJobsResponse() @@ -2274,9 +2312,7 @@ async def test_list_jobs_flattened_async(): client = JobServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.ListJobsResponse() @@ -2313,7 +2349,7 @@ def test_list_jobs_pager(): client = JobServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( job_service.ListJobsResponse( @@ -2342,7 +2378,7 @@ def test_list_jobs_pages(): client = JobServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.list_jobs), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( job_service.ListJobsResponse( @@ -2364,9 +2400,7 @@ async def test_list_jobs_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_jobs), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_jobs), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2394,9 +2428,7 @@ async def test_list_jobs_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_jobs), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_jobs), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2427,7 +2459,7 @@ def test_search_jobs( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.search_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = job_service.SearchJobsResponse( next_page_token="next_page_token_value", @@ -2445,6 +2477,7 @@ def test_search_jobs( assert args[0] == job_service.SearchJobsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchJobsPager) assert response.next_page_token == "next_page_token_value" @@ -2461,19 +2494,19 @@ def test_search_jobs_from_dict(): @pytest.mark.asyncio -async def test_search_jobs_async(transport: str = "grpc_asyncio"): +async def test_search_jobs_async( + transport: str = "grpc_asyncio", request_type=job_service.SearchJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.SearchJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.search_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.SearchJobsResponse( @@ -2490,7 +2523,7 @@ async def test_search_jobs_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.SearchJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.SearchJobsAsyncPager) @@ -2504,6 +2537,11 @@ async def test_search_jobs_async(transport: str = "grpc_asyncio"): assert response.broadened_query_jobs_count == 2766 +@pytest.mark.asyncio +async def test_search_jobs_async_from_dict(): + await test_search_jobs_async(request_type=dict) + + def test_search_jobs_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2513,7 +2551,7 @@ def test_search_jobs_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.search_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: call.return_value = job_service.SearchJobsResponse() client.search_jobs(request) @@ -2538,9 +2576,7 @@ async def test_search_jobs_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.search_jobs), "__call__" - ) as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.SearchJobsResponse() ) @@ -2561,7 +2597,7 @@ def test_search_jobs_pager(): client = JobServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.search_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( job_service.SearchJobsResponse( @@ -2605,7 +2641,7 @@ def test_search_jobs_pages(): client = JobServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.search_jobs), "__call__") as call: + with mock.patch.object(type(client.transport.search_jobs), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( job_service.SearchJobsResponse( @@ -2640,9 +2676,7 @@ async def test_search_jobs_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_jobs), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.search_jobs), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2685,9 +2719,7 @@ async def test_search_jobs_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_jobs), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.search_jobs), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2732,7 +2764,7 @@ def test_search_jobs_for_alert( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = job_service.SearchJobsResponse( @@ -2751,6 +2783,7 @@ def test_search_jobs_for_alert( assert args[0] == job_service.SearchJobsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchJobsForAlertPager) assert response.next_page_token == "next_page_token_value" @@ -2767,18 +2800,20 @@ def test_search_jobs_for_alert_from_dict(): @pytest.mark.asyncio -async def test_search_jobs_for_alert_async(transport: str = "grpc_asyncio"): +async def test_search_jobs_for_alert_async( + transport: str = "grpc_asyncio", request_type=job_service.SearchJobsRequest +): client = JobServiceAsyncClient( 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 = job_service.SearchJobsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2796,7 +2831,7 @@ async def test_search_jobs_for_alert_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == job_service.SearchJobsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.SearchJobsForAlertAsyncPager) @@ -2810,6 +2845,11 @@ async def test_search_jobs_for_alert_async(transport: str = "grpc_asyncio"): assert response.broadened_query_jobs_count == 2766 +@pytest.mark.asyncio +async def test_search_jobs_for_alert_async_from_dict(): + await test_search_jobs_for_alert_async(request_type=dict) + + def test_search_jobs_for_alert_field_headers(): client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2820,7 +2860,7 @@ def test_search_jobs_for_alert_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: call.return_value = job_service.SearchJobsResponse() @@ -2847,7 +2887,7 @@ async def test_search_jobs_for_alert_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( job_service.SearchJobsResponse() @@ -2870,7 +2910,7 @@ def test_search_jobs_for_alert_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2916,7 +2956,7 @@ def test_search_jobs_for_alert_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_jobs_for_alert), "__call__" + type(client.transport.search_jobs_for_alert), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2952,7 +2992,7 @@ async def test_search_jobs_for_alert_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_jobs_for_alert), + type(client.transport.search_jobs_for_alert), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -2997,7 +3037,7 @@ async def test_search_jobs_for_alert_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_jobs_for_alert), + type(client.transport.search_jobs_for_alert), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -3067,7 +3107,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = JobServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -3100,7 +3140,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = JobServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.JobServiceGrpcTransport,) + assert isinstance(client.transport, transports.JobServiceGrpcTransport,) def test_job_service_base_transport_error(): @@ -3215,7 +3255,7 @@ def test_job_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_job_service_host_with_port(): @@ -3225,7 +3265,7 @@ def test_job_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_job_service_grpc_transport_channel(): @@ -3237,6 +3277,7 @@ def test_job_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_job_service_grpc_asyncio_transport_channel(): @@ -3248,6 +3289,7 @@ def test_job_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( @@ -3291,8 +3333,13 @@ def test_job_service_transport_channel_mtls_with_client_cert_source(transport_cl ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -3331,6 +3378,10 @@ def test_job_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel @@ -3339,7 +3390,7 @@ def test_job_service_grpc_lro_client(): client = JobServiceClient( credentials=credentials.AnonymousCredentials(), transport="grpc", ) - transport = client._transport + transport = client.transport # Ensure that we have a api-core operations client. assert isinstance(transport.operations_client, operations_v1.OperationsClient,) @@ -3352,7 +3403,7 @@ def test_job_service_grpc_lro_async_client(): client = JobServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", ) - transport = client._client._transport + transport = client.transport # Ensure that we have a api-core operations client. assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) @@ -3361,10 +3412,35 @@ def test_job_service_grpc_lro_async_client(): assert transport.operations_client is transport.operations_client -def test_job_path(): +def test_company_path(): project = "squid" tenant = "clam" - job = "whelk" + company = "whelk" + + expected = "projects/{project}/tenants/{tenant}/companies/{company}".format( + project=project, tenant=tenant, company=company, + ) + actual = JobServiceClient.company_path(project, tenant, company) + assert expected == actual + + +def test_parse_company_path(): + expected = { + "project": "octopus", + "tenant": "oyster", + "company": "nudibranch", + } + path = JobServiceClient.company_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_company_path(path) + assert expected == actual + + +def test_job_path(): + project = "cuttlefish" + tenant = "mussel" + job = "winkle" expected = "projects/{project}/tenants/{tenant}/jobs/{job}".format( project=project, tenant=tenant, job=job, @@ -3375,9 +3451,9 @@ def test_job_path(): def test_parse_job_path(): expected = { - "project": "octopus", - "tenant": "oyster", - "job": "nudibranch", + "project": "nautilus", + "tenant": "scallop", + "job": "abalone", } path = JobServiceClient.job_path(**expected) @@ -3386,6 +3462,107 @@ def test_parse_job_path(): assert expected == actual +def test_common_billing_account_path(): + billing_account = "squid" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = JobServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "clam", + } + path = JobServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "whelk" + + expected = "folders/{folder}".format(folder=folder,) + actual = JobServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "octopus", + } + path = JobServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "oyster" + + expected = "organizations/{organization}".format(organization=organization,) + actual = JobServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nudibranch", + } + path = JobServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "cuttlefish" + + expected = "projects/{project}".format(project=project,) + actual = JobServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "mussel", + } + path = JobServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "winkle" + location = "nautilus" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = JobServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "scallop", + "location": "abalone", + } + path = JobServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = JobServiceClient.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/talent_v4beta1/test_profile_service.py b/tests/unit/gapic/talent_v4beta1/test_profile_service.py index 53e3dbba..136e0be1 100644 --- a/tests/unit/gapic/talent_v4beta1/test_profile_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_profile_service.py @@ -51,7 +51,7 @@ from google.protobuf import wrappers_pb2 as wrappers # type: ignore from google.type import date_pb2 as date # type: ignore from google.type import latlng_pb2 as latlng # type: ignore -from google.type import postal_address_pb2 as gt_postal_address # type: ignore +from google.type import postal_address_pb2 as postal_address # type: ignore def client_cert_source_callback(): @@ -108,12 +108,12 @@ def test_profile_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_profile_service_client_get_transport_class(): @@ -463,7 +463,7 @@ def test_list_profiles( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_profiles), "__call__") as call: + with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = profile_service.ListProfilesResponse( next_page_token="next_page_token_value", @@ -478,6 +478,7 @@ def test_list_profiles( assert args[0] == profile_service.ListProfilesRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListProfilesPager) assert response.next_page_token == "next_page_token_value" @@ -488,19 +489,19 @@ def test_list_profiles_from_dict(): @pytest.mark.asyncio -async def test_list_profiles_async(transport: str = "grpc_asyncio"): +async def test_list_profiles_async( + transport: str = "grpc_asyncio", request_type=profile_service.ListProfilesRequest +): client = ProfileServiceAsyncClient( 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 = profile_service.ListProfilesRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_profiles), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( profile_service.ListProfilesResponse( @@ -514,7 +515,7 @@ async def test_list_profiles_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == profile_service.ListProfilesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListProfilesAsyncPager) @@ -522,6 +523,11 @@ async def test_list_profiles_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_profiles_async_from_dict(): + await test_list_profiles_async(request_type=dict) + + def test_list_profiles_field_headers(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -531,7 +537,7 @@ def test_list_profiles_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_profiles), "__call__") as call: + with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: call.return_value = profile_service.ListProfilesResponse() client.list_profiles(request) @@ -556,9 +562,7 @@ async def test_list_profiles_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_profiles), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( profile_service.ListProfilesResponse() ) @@ -579,7 +583,7 @@ def test_list_profiles_flattened(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_profiles), "__call__") as call: + with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = profile_service.ListProfilesResponse() @@ -611,9 +615,7 @@ async def test_list_profiles_flattened_async(): client = ProfileServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_profiles), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = profile_service.ListProfilesResponse() @@ -648,7 +650,7 @@ def test_list_profiles_pager(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_profiles), "__call__") as call: + with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( profile_service.ListProfilesResponse( @@ -682,7 +684,7 @@ def test_list_profiles_pages(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_profiles), "__call__") as call: + with mock.patch.object(type(client.transport.list_profiles), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( profile_service.ListProfilesResponse( @@ -709,9 +711,7 @@ async def test_list_profiles_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_profiles), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_profiles), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -744,9 +744,7 @@ async def test_list_profiles_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_profiles), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_profiles), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -782,7 +780,7 @@ def test_create_profile( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_profile), "__call__") as call: + with mock.patch.object(type(client.transport.create_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_profile.Profile( name="name_value", @@ -805,6 +803,7 @@ def test_create_profile( assert args[0] == profile_service.CreateProfileRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_profile.Profile) assert response.name == "name_value" @@ -831,19 +830,19 @@ def test_create_profile_from_dict(): @pytest.mark.asyncio -async def test_create_profile_async(transport: str = "grpc_asyncio"): +async def test_create_profile_async( + transport: str = "grpc_asyncio", request_type=profile_service.CreateProfileRequest +): client = ProfileServiceAsyncClient( 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 = profile_service.CreateProfileRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_profile.Profile( @@ -865,7 +864,7 @@ async def test_create_profile_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == profile_service.CreateProfileRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_profile.Profile) @@ -889,6 +888,11 @@ async def test_create_profile_async(transport: str = "grpc_asyncio"): assert response.keyword_snippet == "keyword_snippet_value" +@pytest.mark.asyncio +async def test_create_profile_async_from_dict(): + await test_create_profile_async(request_type=dict) + + def test_create_profile_field_headers(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -898,7 +902,7 @@ def test_create_profile_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_profile), "__call__") as call: + with mock.patch.object(type(client.transport.create_profile), "__call__") as call: call.return_value = gct_profile.Profile() client.create_profile(request) @@ -923,9 +927,7 @@ async def test_create_profile_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_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_profile), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_profile.Profile()) await client.create_profile(request) @@ -944,7 +946,7 @@ def test_create_profile_flattened(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_profile), "__call__") as call: + with mock.patch.object(type(client.transport.create_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_profile.Profile() @@ -982,9 +984,7 @@ async def test_create_profile_flattened_async(): client = ProfileServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_profile.Profile() @@ -1031,7 +1031,7 @@ def test_get_profile( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_profile), "__call__") as call: + with mock.patch.object(type(client.transport.get_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = profile.Profile( name="name_value", @@ -1054,6 +1054,7 @@ def test_get_profile( assert args[0] == profile_service.GetProfileRequest() # Establish that the response is the type that we expect. + assert isinstance(response, profile.Profile) assert response.name == "name_value" @@ -1080,19 +1081,19 @@ def test_get_profile_from_dict(): @pytest.mark.asyncio -async def test_get_profile_async(transport: str = "grpc_asyncio"): +async def test_get_profile_async( + transport: str = "grpc_asyncio", request_type=profile_service.GetProfileRequest +): client = ProfileServiceAsyncClient( 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 = profile_service.GetProfileRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( profile.Profile( @@ -1114,7 +1115,7 @@ async def test_get_profile_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == profile_service.GetProfileRequest() # Establish that the response is the type that we expect. assert isinstance(response, profile.Profile) @@ -1138,6 +1139,11 @@ async def test_get_profile_async(transport: str = "grpc_asyncio"): assert response.keyword_snippet == "keyword_snippet_value" +@pytest.mark.asyncio +async def test_get_profile_async_from_dict(): + await test_get_profile_async(request_type=dict) + + def test_get_profile_field_headers(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1147,7 +1153,7 @@ def test_get_profile_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_profile), "__call__") as call: + with mock.patch.object(type(client.transport.get_profile), "__call__") as call: call.return_value = profile.Profile() client.get_profile(request) @@ -1172,9 +1178,7 @@ async def test_get_profile_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_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_profile), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(profile.Profile()) await client.get_profile(request) @@ -1193,7 +1197,7 @@ def test_get_profile_flattened(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_profile), "__call__") as call: + with mock.patch.object(type(client.transport.get_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = profile.Profile() @@ -1225,9 +1229,7 @@ async def test_get_profile_flattened_async(): client = ProfileServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = profile.Profile() @@ -1268,7 +1270,7 @@ def test_update_profile( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_profile), "__call__") as call: + with mock.patch.object(type(client.transport.update_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_profile.Profile( name="name_value", @@ -1291,6 +1293,7 @@ def test_update_profile( assert args[0] == profile_service.UpdateProfileRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_profile.Profile) assert response.name == "name_value" @@ -1317,19 +1320,19 @@ def test_update_profile_from_dict(): @pytest.mark.asyncio -async def test_update_profile_async(transport: str = "grpc_asyncio"): +async def test_update_profile_async( + transport: str = "grpc_asyncio", request_type=profile_service.UpdateProfileRequest +): client = ProfileServiceAsyncClient( 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 = profile_service.UpdateProfileRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_profile.Profile( @@ -1351,7 +1354,7 @@ async def test_update_profile_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == profile_service.UpdateProfileRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_profile.Profile) @@ -1375,6 +1378,11 @@ async def test_update_profile_async(transport: str = "grpc_asyncio"): assert response.keyword_snippet == "keyword_snippet_value" +@pytest.mark.asyncio +async def test_update_profile_async_from_dict(): + await test_update_profile_async(request_type=dict) + + def test_update_profile_field_headers(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1384,7 +1392,7 @@ def test_update_profile_field_headers(): request.profile.name = "profile.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_profile), "__call__") as call: + with mock.patch.object(type(client.transport.update_profile), "__call__") as call: call.return_value = gct_profile.Profile() client.update_profile(request) @@ -1411,9 +1419,7 @@ async def test_update_profile_field_headers_async(): request.profile.name = "profile.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_profile), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_profile.Profile()) await client.update_profile(request) @@ -1434,7 +1440,7 @@ def test_update_profile_flattened(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_profile), "__call__") as call: + with mock.patch.object(type(client.transport.update_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_profile.Profile() @@ -1467,9 +1473,7 @@ async def test_update_profile_flattened_async(): client = ProfileServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_profile.Profile() @@ -1513,7 +1517,7 @@ def test_delete_profile( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_profile), "__call__") as call: + with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1534,19 +1538,19 @@ def test_delete_profile_from_dict(): @pytest.mark.asyncio -async def test_delete_profile_async(transport: str = "grpc_asyncio"): +async def test_delete_profile_async( + transport: str = "grpc_asyncio", request_type=profile_service.DeleteProfileRequest +): client = ProfileServiceAsyncClient( 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 = profile_service.DeleteProfileRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1556,12 +1560,17 @@ async def test_delete_profile_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == profile_service.DeleteProfileRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_profile_async_from_dict(): + await test_delete_profile_async(request_type=dict) + + def test_delete_profile_field_headers(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1571,7 +1580,7 @@ def test_delete_profile_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_profile), "__call__") as call: + with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: call.return_value = None client.delete_profile(request) @@ -1596,9 +1605,7 @@ async def test_delete_profile_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_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_profile(request) @@ -1617,7 +1624,7 @@ def test_delete_profile_flattened(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_profile), "__call__") as call: + with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1649,9 +1656,7 @@ async def test_delete_profile_flattened_async(): client = ProfileServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_profile), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_profile), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1692,7 +1697,7 @@ def test_search_profiles( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.search_profiles), "__call__") as call: + with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = profile_service.SearchProfilesResponse( estimated_total_size=2141, @@ -1709,6 +1714,7 @@ def test_search_profiles( assert args[0] == profile_service.SearchProfilesRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchProfilesPager) assert response.estimated_total_size == 2141 @@ -1723,19 +1729,19 @@ def test_search_profiles_from_dict(): @pytest.mark.asyncio -async def test_search_profiles_async(transport: str = "grpc_asyncio"): +async def test_search_profiles_async( + transport: str = "grpc_asyncio", request_type=profile_service.SearchProfilesRequest +): client = ProfileServiceAsyncClient( 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 = profile_service.SearchProfilesRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.search_profiles), "__call__" - ) as call: + with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( profile_service.SearchProfilesResponse( @@ -1751,7 +1757,7 @@ async def test_search_profiles_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == profile_service.SearchProfilesRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.SearchProfilesAsyncPager) @@ -1763,6 +1769,11 @@ async def test_search_profiles_async(transport: str = "grpc_asyncio"): assert response.result_set_id == "result_set_id_value" +@pytest.mark.asyncio +async def test_search_profiles_async_from_dict(): + await test_search_profiles_async(request_type=dict) + + def test_search_profiles_field_headers(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1772,7 +1783,7 @@ def test_search_profiles_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.search_profiles), "__call__") as call: + with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: call.return_value = profile_service.SearchProfilesResponse() client.search_profiles(request) @@ -1797,9 +1808,7 @@ async def test_search_profiles_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.search_profiles), "__call__" - ) as call: + with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( profile_service.SearchProfilesResponse() ) @@ -1820,7 +1829,7 @@ def test_search_profiles_pager(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.search_profiles), "__call__") as call: + with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( profile_service.SearchProfilesResponse( @@ -1864,7 +1873,7 @@ def test_search_profiles_pages(): client = ProfileServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.search_profiles), "__call__") as call: + with mock.patch.object(type(client.transport.search_profiles), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( profile_service.SearchProfilesResponse( @@ -1901,9 +1910,7 @@ async def test_search_profiles_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_profiles), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.search_profiles), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1946,9 +1953,7 @@ async def test_search_profiles_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_profiles), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.search_profiles), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2018,7 +2023,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = ProfileServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -2054,7 +2059,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = ProfileServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.ProfileServiceGrpcTransport,) + assert isinstance(client.transport, transports.ProfileServiceGrpcTransport,) def test_profile_service_base_transport_error(): @@ -2160,7 +2165,7 @@ def test_profile_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_profile_service_host_with_port(): @@ -2170,7 +2175,7 @@ def test_profile_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_profile_service_grpc_transport_channel(): @@ -2182,6 +2187,7 @@ def test_profile_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_profile_service_grpc_asyncio_transport_channel(): @@ -2193,6 +2199,7 @@ def test_profile_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( @@ -2241,8 +2248,13 @@ def test_profile_service_transport_channel_mtls_with_client_cert_source( ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -2284,6 +2296,10 @@ def test_profile_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel @@ -2313,6 +2329,130 @@ def test_parse_profile_path(): assert expected == actual +def test_tenant_path(): + project = "cuttlefish" + tenant = "mussel" + + expected = "projects/{project}/tenants/{tenant}".format( + project=project, tenant=tenant, + ) + actual = ProfileServiceClient.tenant_path(project, tenant) + assert expected == actual + + +def test_parse_tenant_path(): + expected = { + "project": "winkle", + "tenant": "nautilus", + } + path = ProfileServiceClient.tenant_path(**expected) + + # Check that the path construction is reversible. + actual = ProfileServiceClient.parse_tenant_path(path) + assert expected == actual + + +def test_common_billing_account_path(): + billing_account = "scallop" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = ProfileServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "abalone", + } + path = ProfileServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = ProfileServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "squid" + + expected = "folders/{folder}".format(folder=folder,) + actual = ProfileServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "clam", + } + path = ProfileServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = ProfileServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "whelk" + + expected = "organizations/{organization}".format(organization=organization,) + actual = ProfileServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "octopus", + } + path = ProfileServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = ProfileServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "oyster" + + expected = "projects/{project}".format(project=project,) + actual = ProfileServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "nudibranch", + } + path = ProfileServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = ProfileServiceClient.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 = ProfileServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "winkle", + "location": "nautilus", + } + path = ProfileServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = ProfileServiceClient.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/talent_v4beta1/test_tenant_service.py b/tests/unit/gapic/talent_v4beta1/test_tenant_service.py index ecf6be6c..62a13dd4 100644 --- a/tests/unit/gapic/talent_v4beta1/test_tenant_service.py +++ b/tests/unit/gapic/talent_v4beta1/test_tenant_service.py @@ -97,12 +97,12 @@ def test_tenant_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 == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_tenant_service_client_get_transport_class(): @@ -452,7 +452,7 @@ def test_create_tenant( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant( name="name_value", @@ -472,6 +472,7 @@ def test_create_tenant( assert args[0] == tenant_service.CreateTenantRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) assert response.name == "name_value" @@ -490,19 +491,19 @@ def test_create_tenant_from_dict(): @pytest.mark.asyncio -async def test_create_tenant_async(transport: str = "grpc_asyncio"): +async def test_create_tenant_async( + transport: str = "grpc_asyncio", request_type=tenant_service.CreateTenantRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.CreateTenantRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_tenant.Tenant( @@ -521,7 +522,7 @@ async def test_create_tenant_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.CreateTenantRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_tenant.Tenant) @@ -537,6 +538,11 @@ async def test_create_tenant_async(transport: str = "grpc_asyncio"): ] +@pytest.mark.asyncio +async def test_create_tenant_async_from_dict(): + await test_create_tenant_async(request_type=dict) + + def test_create_tenant_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -546,7 +552,7 @@ def test_create_tenant_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_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: call.return_value = gct_tenant.Tenant() client.create_tenant(request) @@ -571,9 +577,7 @@ async def test_create_tenant_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_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) await client.create_tenant(request) @@ -592,7 +596,7 @@ def test_create_tenant_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.create_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant() @@ -630,9 +634,7 @@ async def test_create_tenant_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.create_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.create_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant() @@ -679,7 +681,7 @@ def test_get_tenant( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant.Tenant( name="name_value", @@ -699,6 +701,7 @@ def test_get_tenant( assert args[0] == tenant_service.GetTenantRequest() # Establish that the response is the type that we expect. + assert isinstance(response, tenant.Tenant) assert response.name == "name_value" @@ -717,19 +720,19 @@ def test_get_tenant_from_dict(): @pytest.mark.asyncio -async def test_get_tenant_async(transport: str = "grpc_asyncio"): +async def test_get_tenant_async( + transport: str = "grpc_asyncio", request_type=tenant_service.GetTenantRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.GetTenantRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tenant.Tenant( @@ -748,7 +751,7 @@ async def test_get_tenant_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.GetTenantRequest() # Establish that the response is the type that we expect. assert isinstance(response, tenant.Tenant) @@ -764,6 +767,11 @@ async def test_get_tenant_async(transport: str = "grpc_asyncio"): ] +@pytest.mark.asyncio +async def test_get_tenant_async_from_dict(): + await test_get_tenant_async(request_type=dict) + + def test_get_tenant_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -773,7 +781,7 @@ def test_get_tenant_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_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: call.return_value = tenant.Tenant() client.get_tenant(request) @@ -798,9 +806,7 @@ async def test_get_tenant_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_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(tenant.Tenant()) await client.get_tenant(request) @@ -819,7 +825,7 @@ def test_get_tenant_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant.Tenant() @@ -851,9 +857,7 @@ async def test_get_tenant_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant.Tenant() @@ -894,7 +898,7 @@ def test_update_tenant( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant( name="name_value", @@ -914,6 +918,7 @@ def test_update_tenant( assert args[0] == tenant_service.UpdateTenantRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gct_tenant.Tenant) assert response.name == "name_value" @@ -932,19 +937,19 @@ def test_update_tenant_from_dict(): @pytest.mark.asyncio -async def test_update_tenant_async(transport: str = "grpc_asyncio"): +async def test_update_tenant_async( + transport: str = "grpc_asyncio", request_type=tenant_service.UpdateTenantRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.UpdateTenantRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gct_tenant.Tenant( @@ -963,7 +968,7 @@ async def test_update_tenant_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.UpdateTenantRequest() # Establish that the response is the type that we expect. assert isinstance(response, gct_tenant.Tenant) @@ -979,6 +984,11 @@ async def test_update_tenant_async(transport: str = "grpc_asyncio"): ] +@pytest.mark.asyncio +async def test_update_tenant_async_from_dict(): + await test_update_tenant_async(request_type=dict) + + def test_update_tenant_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -988,7 +998,7 @@ def test_update_tenant_field_headers(): request.tenant.name = "tenant.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: call.return_value = gct_tenant.Tenant() client.update_tenant(request) @@ -1013,9 +1023,7 @@ async def test_update_tenant_field_headers_async(): request.tenant.name = "tenant.name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(gct_tenant.Tenant()) await client.update_tenant(request) @@ -1034,7 +1042,7 @@ def test_update_tenant_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.update_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant() @@ -1067,9 +1075,7 @@ async def test_update_tenant_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.update_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.update_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_tenant.Tenant() @@ -1113,7 +1119,7 @@ def test_delete_tenant( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1134,19 +1140,19 @@ def test_delete_tenant_from_dict(): @pytest.mark.asyncio -async def test_delete_tenant_async(transport: str = "grpc_asyncio"): +async def test_delete_tenant_async( + transport: str = "grpc_asyncio", request_type=tenant_service.DeleteTenantRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.DeleteTenantRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1156,12 +1162,17 @@ async def test_delete_tenant_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.DeleteTenantRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_tenant_async_from_dict(): + await test_delete_tenant_async(request_type=dict) + + def test_delete_tenant_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1171,7 +1182,7 @@ def test_delete_tenant_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_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: call.return_value = None client.delete_tenant(request) @@ -1196,9 +1207,7 @@ async def test_delete_tenant_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_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) await client.delete_tenant(request) @@ -1217,7 +1226,7 @@ def test_delete_tenant_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.delete_tenant), "__call__") as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1249,9 +1258,7 @@ async def test_delete_tenant_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.delete_tenant), "__call__" - ) as call: + with mock.patch.object(type(client.transport.delete_tenant), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1292,7 +1299,7 @@ def test_list_tenants( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant_service.ListTenantsResponse( next_page_token="next_page_token_value", @@ -1307,6 +1314,7 @@ def test_list_tenants( assert args[0] == tenant_service.ListTenantsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListTenantsPager) assert response.next_page_token == "next_page_token_value" @@ -1317,19 +1325,19 @@ def test_list_tenants_from_dict(): @pytest.mark.asyncio -async def test_list_tenants_async(transport: str = "grpc_asyncio"): +async def test_list_tenants_async( + transport: str = "grpc_asyncio", request_type=tenant_service.ListTenantsRequest +): client = TenantServiceAsyncClient( 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 = tenant_service.ListTenantsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_tenants), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tenant_service.ListTenantsResponse(next_page_token="next_page_token_value",) @@ -1341,7 +1349,7 @@ async def test_list_tenants_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == tenant_service.ListTenantsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListTenantsAsyncPager) @@ -1349,6 +1357,11 @@ async def test_list_tenants_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_tenants_async_from_dict(): + await test_list_tenants_async(request_type=dict) + + def test_list_tenants_field_headers(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1358,7 +1371,7 @@ def test_list_tenants_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_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: call.return_value = tenant_service.ListTenantsResponse() client.list_tenants(request) @@ -1383,9 +1396,7 @@ async def test_list_tenants_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_tenants), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( tenant_service.ListTenantsResponse() ) @@ -1406,7 +1417,7 @@ def test_list_tenants_flattened(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant_service.ListTenantsResponse() @@ -1438,9 +1449,7 @@ async def test_list_tenants_flattened_async(): client = TenantServiceAsyncClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_tenants), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = tenant_service.ListTenantsResponse() @@ -1475,7 +1484,7 @@ def test_list_tenants_pager(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( tenant_service.ListTenantsResponse( @@ -1509,7 +1518,7 @@ def test_list_tenants_pages(): client = TenantServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.list_tenants), "__call__") as call: + with mock.patch.object(type(client.transport.list_tenants), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( tenant_service.ListTenantsResponse( @@ -1536,9 +1545,7 @@ async def test_list_tenants_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_tenants), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_tenants), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1571,9 +1578,7 @@ async def test_list_tenants_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_tenants), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_tenants), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -1633,7 +1638,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = TenantServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -1669,7 +1674,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = TenantServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.TenantServiceGrpcTransport,) + assert isinstance(client.transport, transports.TenantServiceGrpcTransport,) def test_tenant_service_base_transport_error(): @@ -1774,7 +1779,7 @@ def test_tenant_service_host_no_port(): credentials=credentials.AnonymousCredentials(), client_options=client_options.ClientOptions(api_endpoint="jobs.googleapis.com"), ) - assert client._transport._host == "jobs.googleapis.com:443" + assert client.transport._host == "jobs.googleapis.com:443" def test_tenant_service_host_with_port(): @@ -1784,7 +1789,7 @@ def test_tenant_service_host_with_port(): api_endpoint="jobs.googleapis.com:8000" ), ) - assert client._transport._host == "jobs.googleapis.com:8000" + assert client.transport._host == "jobs.googleapis.com:8000" def test_tenant_service_grpc_transport_channel(): @@ -1796,6 +1801,7 @@ def test_tenant_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_tenant_service_grpc_asyncio_transport_channel(): @@ -1807,6 +1813,7 @@ def test_tenant_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( @@ -1853,8 +1860,13 @@ def test_tenant_service_transport_channel_mtls_with_client_cert_source(transport ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -1896,6 +1908,10 @@ def test_tenant_service_transport_channel_mtls_with_adc(transport_class): ), ssl_credentials=mock_ssl_cred, quota_project_id=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], ) assert transport.grpc_channel == mock_grpc_channel @@ -1923,6 +1939,107 @@ def test_parse_tenant_path(): assert expected == actual +def test_common_billing_account_path(): + billing_account = "oyster" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = TenantServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "nudibranch", + } + path = TenantServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "cuttlefish" + + expected = "folders/{folder}".format(folder=folder,) + actual = TenantServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "mussel", + } + path = TenantServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "winkle" + + expected = "organizations/{organization}".format(organization=organization,) + actual = TenantServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nautilus", + } + path = TenantServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "scallop" + + expected = "projects/{project}".format(project=project,) + actual = TenantServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "abalone", + } + path = TenantServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "squid" + location = "clam" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = TenantServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "whelk", + "location": "octopus", + } + path = TenantServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = TenantServiceClient.parse_common_location_path(path) + assert expected == actual + + def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo() From 39e239a78c01d58b49f3d6aacef3ddcffc8379b2 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 23 Dec 2020 15:46:46 -0800 Subject: [PATCH 4/9] changes without context (#56) autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> --- google/cloud/talent_v4/__init__.py | 2 +- google/cloud/talent_v4beta1/__init__.py | 2 +- .../services/application_service/async_client.py | 6 +++--- .../services/application_service/transports/base.py | 6 +++--- .../talent_v4beta1/services/company_service/async_client.py | 6 +++--- .../services/company_service/transports/base.py | 6 +++--- .../talent_v4beta1/services/completion/async_client.py | 2 +- .../talent_v4beta1/services/completion/transports/base.py | 2 +- .../talent_v4beta1/services/job_service/async_client.py | 6 +++--- .../talent_v4beta1/services/job_service/transports/base.py | 6 +++--- .../talent_v4beta1/services/profile_service/async_client.py | 6 +++--- .../services/profile_service/transports/base.py | 6 +++--- .../talent_v4beta1/services/tenant_service/async_client.py | 6 +++--- .../services/tenant_service/transports/base.py | 6 +++--- 14 files changed, 34 insertions(+), 34 deletions(-) diff --git a/google/cloud/talent_v4/__init__.py b/google/cloud/talent_v4/__init__.py index 2f1964fd..2edd8d10 100644 --- a/google/cloud/talent_v4/__init__.py +++ b/google/cloud/talent_v4/__init__.py @@ -113,6 +113,7 @@ "DeleteTenantRequest", "DeviceInfo", "EmploymentType", + "EventServiceClient", "GetCompanyRequest", "GetJobRequest", "GetTenantRequest", @@ -149,5 +150,4 @@ "UpdateJobRequest", "UpdateTenantRequest", "Visibility", - "EventServiceClient", ) diff --git a/google/cloud/talent_v4beta1/__init__.py b/google/cloud/talent_v4beta1/__init__.py index 9494115b..8374246b 100644 --- a/google/cloud/talent_v4beta1/__init__.py +++ b/google/cloud/talent_v4beta1/__init__.py @@ -143,6 +143,7 @@ "ApplicationDateFilter", "ApplicationJobFilter", "ApplicationOutcomeNotesFilter", + "ApplicationServiceClient", "AvailabilityFilter", "AvailabilitySignal", "AvailabilitySignalType", @@ -253,5 +254,4 @@ "UpdateTenantRequest", "Visibility", "WorkExperienceFilter", - "ApplicationServiceClient", ) diff --git a/google/cloud/talent_v4beta1/services/application_service/async_client.py b/google/cloud/talent_v4beta1/services/application_service/async_client.py index 8236846b..594ff4c2 100644 --- a/google/cloud/talent_v4beta1/services/application_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/application_service/async_client.py @@ -308,7 +308,7 @@ async def get_application( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -461,7 +461,7 @@ async def delete_application( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -547,7 +547,7 @@ async def list_applications( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/application_service/transports/base.py b/google/cloud/talent_v4beta1/services/application_service/transports/base.py index 83ba6405..9f1da4f6 100644 --- a/google/cloud/talent_v4beta1/services/application_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/application_service/transports/base.py @@ -120,7 +120,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -136,7 +136,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/company_service/async_client.py b/google/cloud/talent_v4beta1/services/company_service/async_client.py index 98c39a8e..dd7aa172 100644 --- a/google/cloud/talent_v4beta1/services/company_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/company_service/async_client.py @@ -308,7 +308,7 @@ async def get_company( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -469,7 +469,7 @@ async def delete_company( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -557,7 +557,7 @@ async def list_companies( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/company_service/transports/base.py b/google/cloud/talent_v4beta1/services/company_service/transports/base.py index 39fb541b..e6e25567 100644 --- a/google/cloud/talent_v4beta1/services/company_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/company_service/transports/base.py @@ -120,7 +120,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -136,7 +136,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/completion/async_client.py b/google/cloud/talent_v4beta1/services/completion/async_client.py index 40da92eb..06946918 100644 --- a/google/cloud/talent_v4beta1/services/completion/async_client.py +++ b/google/cloud/talent_v4beta1/services/completion/async_client.py @@ -173,7 +173,7 @@ async def complete_query( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/completion/transports/base.py b/google/cloud/talent_v4beta1/services/completion/transports/base.py index 95e41990..b84df3c7 100644 --- a/google/cloud/talent_v4beta1/services/completion/transports/base.py +++ b/google/cloud/talent_v4beta1/services/completion/transports/base.py @@ -114,7 +114,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/job_service/async_client.py b/google/cloud/talent_v4beta1/services/job_service/async_client.py index a5ad40c6..07a5b431 100644 --- a/google/cloud/talent_v4beta1/services/job_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/job_service/async_client.py @@ -407,7 +407,7 @@ async def get_job( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -667,7 +667,7 @@ async def delete_job( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -872,7 +872,7 @@ async def list_jobs( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/job_service/transports/base.py b/google/cloud/talent_v4beta1/services/job_service/transports/base.py index ffef5f17..0821af69 100644 --- a/google/cloud/talent_v4beta1/services/job_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/job_service/transports/base.py @@ -125,7 +125,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -144,7 +144,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -160,7 +160,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/profile_service/async_client.py b/google/cloud/talent_v4beta1/services/profile_service/async_client.py index 914e2bf4..c62a4c8f 100644 --- a/google/cloud/talent_v4beta1/services/profile_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/profile_service/async_client.py @@ -216,7 +216,7 @@ async def list_profiles( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -391,7 +391,7 @@ async def get_profile( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -544,7 +544,7 @@ async def delete_profile( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/profile_service/transports/base.py b/google/cloud/talent_v4beta1/services/profile_service/transports/base.py index dbd36ea2..8239d17a 100644 --- a/google/cloud/talent_v4beta1/services/profile_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/profile_service/transports/base.py @@ -117,7 +117,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -133,7 +133,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/tenant_service/async_client.py b/google/cloud/talent_v4beta1/services/tenant_service/async_client.py index be6fce85..12205e77 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/async_client.py @@ -302,7 +302,7 @@ async def get_tenant( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -458,7 +458,7 @@ async def delete_tenant( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -542,7 +542,7 @@ async def list_tenants( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py b/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py index b0f77c0d..3e9a73dc 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py @@ -120,7 +120,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -136,7 +136,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, ), ), default_timeout=30.0, From d95d9bccf6fca2ee08181d3b63572ca1a4b97eb2 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 23 Dec 2020 16:16:50 -0800 Subject: [PATCH 5/9] chore: update templates (#58) --- .flake8 | 1 + .kokoro/docs/common.cfg | 2 +- .kokoro/test-samples.sh | 8 ++- .pre-commit-config.yaml | 17 +++++ CODE_OF_CONDUCT.md | 123 +++++++++++++++++++++++++----------- CONTRIBUTING.rst | 21 ++++-- docs/conf.py | 7 +- noxfile.py | 9 +-- samples/snippets/noxfile.py | 39 +++++++++--- synth.metadata | 5 +- 10 files changed, 171 insertions(+), 61 deletions(-) create mode 100644 .pre-commit-config.yaml diff --git a/.flake8 b/.flake8 index ed931638..29227d4c 100644 --- a/.flake8 +++ b/.flake8 @@ -26,6 +26,7 @@ exclude = *_pb2.py # Standard linting exemptions. + **/.nox/** __pycache__, .git, *.pyc, diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg index 8cd3aaa0..97edc390 100644 --- a/.kokoro/docs/common.cfg +++ b/.kokoro/docs/common.cfg @@ -30,7 +30,7 @@ env_vars: { env_vars: { key: "V2_STAGING_BUCKET" - value: "docs-staging-v2-staging" + value: "docs-staging-v2" } # It will upload the docker image after successful builds. diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh index fd589498..4b0afc93 100755 --- a/.kokoro/test-samples.sh +++ b/.kokoro/test-samples.sh @@ -28,6 +28,12 @@ if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then git checkout $LATEST_RELEASE fi +# Exit early if samples directory doesn't exist +if [ ! -d "./samples" ]; then + echo "No tests run. `./samples` not found" + exit 0 +fi + # Disable buffering, so that the logs stream through. export PYTHONUNBUFFERED=1 @@ -101,4 +107,4 @@ cd "$ROOT" # Workaround for Kokoro permissions issue: delete secrets rm testing/{test-env.sh,client-secrets.json,service-account.json} -exit "$RTN" \ No newline at end of file +exit "$RTN" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..a9024b15 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,17 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v3.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml +- repo: https://github.com/psf/black + rev: 19.10b0 + hooks: + - id: black +- repo: https://gitlab.com/pycqa/flake8 + rev: 3.8.4 + hooks: + - id: flake8 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index b3d1f602..039f4368 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,44 +1,95 @@ -# Contributor Code of Conduct +# Code of Conduct -As contributors and maintainers of this project, -and in the interest of fostering an open and welcoming community, -we pledge to respect all people who contribute through reporting issues, -posting feature requests, updating documentation, -submitting pull requests or patches, and other activities. +## Our Pledge -We are committed to making participation in this project -a harassment-free experience for everyone, -regardless of level of experience, gender, gender identity and expression, -sexual orientation, disability, personal appearance, -body size, race, ethnicity, age, religion, or nationality. +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of +experience, education, socio-economic status, nationality, personal appearance, +race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members Examples of unacceptable behavior by participants include: -* The use of sexualized language or imagery -* Personal attacks -* Trolling or insulting/derogatory comments -* Public or private harassment -* Publishing other's private information, -such as physical or electronic -addresses, without explicit permission -* Other unethical or unprofessional conduct. +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject -comments, commits, code, wiki edits, issues, and other contributions -that are not aligned to this Code of Conduct. -By adopting this Code of Conduct, -project maintainers commit themselves to fairly and consistently -applying these principles to every aspect of managing this project. -Project maintainers who do not follow or enforce the Code of Conduct -may be permanently removed from the project team. - -This code of conduct applies both within project spaces and in public spaces -when an individual is representing the project or its community. - -Instances of abusive, harassing, or otherwise unacceptable behavior -may be reported by opening an issue -or contacting one or more of the project maintainers. - -This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0, -available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/) +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, or to ban temporarily or permanently any +contributor for other behaviors that they deem inappropriate, threatening, +offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +This Code of Conduct also applies outside the project spaces when the Project +Steward has a reasonable belief that an individual's behavior may have a +negative impact on the project or its community. + +## Conflict Resolution + +We do not believe that all conflict is bad; healthy debate and disagreement +often yield positive results. However, it is never okay to be disrespectful or +to engage in behavior that violates the project’s code of conduct. + +If you see someone violating the code of conduct, you are encouraged to address +the behavior directly with those involved. Many issues can be resolved quickly +and easily, and this gives people more control over the outcome of their +dispute. If you are unable to resolve the matter for any reason, or if the +behavior is threatening or harassing, report it. We are dedicated to providing +an environment where participants feel welcome and safe. + + +Reports should be directed to *googleapis-stewards@google.com*, the +Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to +receive and address reported violations of the code of conduct. They will then +work with a committee consisting of representatives from the Open Source +Programs Office and the Google Open Source Strategy team. If for any reason you +are uncomfortable reaching out to the Project Steward, please email +opensource@google.com. + +We will investigate every complaint, but you may not receive a direct response. +We will use our discretion in determining when and how to follow up on reported +incidents, which may range from not taking action to permanent expulsion from +the project and project-sponsored spaces. We will notify the accused of the +report and provide them an opportunity to discuss it before any action is taken. +The identity of the reporter will be omitted from the details of the report +supplied to the accused. In potentially harmful situations, such as ongoing +harassment or threats to anyone's safety, we may take action without notice. + +## Attribution + +This Code of Conduct is adapted from the Contributor Covenant, version 1.4, +available at +https://www.contributor-covenant.org/version/1/4/code-of-conduct.html \ No newline at end of file diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 1de28a96..12046067 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -21,8 +21,8 @@ In order to add a feature: - The feature must be documented in both the API and narrative documentation. -- The feature must work fully on the following CPython versions: 2.7, - 3.5, 3.6, 3.7 and 3.8 on both UNIX and Windows. +- The feature must work fully on the following CPython versions: + 3.6, 3.7, 3.8 and 3.9 on both UNIX and Windows. - The feature must not add unnecessary dependencies (where "unnecessary" is of course subjective, but new dependencies should @@ -111,6 +111,16 @@ Coding Style should point to the official ``googleapis`` checkout and the the branch should be the main branch on that remote (``master``). +- This repository contains configuration for the + `pre-commit `__ tool, which automates checking + our linters during a commit. If you have it installed on your ``$PATH``, + you can enable enforcing those checks via: + +.. code-block:: bash + + $ pre-commit install + pre-commit installed at .git/hooks/pre-commit + Exceptions to PEP8: - Many unit tests use a helper method, ``_call_fut`` ("FUT" is short for @@ -192,25 +202,24 @@ Supported Python Versions We support: -- `Python 3.5`_ - `Python 3.6`_ - `Python 3.7`_ - `Python 3.8`_ +- `Python 3.9`_ -.. _Python 3.5: https://docs.python.org/3.5/ .. _Python 3.6: https://docs.python.org/3.6/ .. _Python 3.7: https://docs.python.org/3.7/ .. _Python 3.8: https://docs.python.org/3.8/ +.. _Python 3.9: https://docs.python.org/3.9/ Supported versions can be found in our ``noxfile.py`` `config`_. .. _config: https://github.com/googleapis/python-talent/blob/master/noxfile.py -Python 2.7 support is deprecated. All code changes should maintain Python 2.7 compatibility until January 1, 2020. We also explicitly decided to support Python 3 beginning with version -3.5. Reasons for this include: +3.6. Reasons for this include: - Encouraging use of newest versions of Python 3 - Taking the lead of `prominent`_ open-source `projects`_ diff --git a/docs/conf.py b/docs/conf.py index d3afd421..6f1a41b2 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -345,10 +345,11 @@ # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - "python": ("http://python.readthedocs.org/en/latest/", None), - "google-auth": ("https://google-auth.readthedocs.io/en/stable", None), + "python": ("https://python.readthedocs.org/en/latest/", None), + "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), - "grpc": ("https://grpc.io/grpc/python/", None), + "grpc": ("https://grpc.github.io/grpc/python/", None), + "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), } diff --git a/noxfile.py b/noxfile.py index 539aa044..41eeb037 100644 --- a/noxfile.py +++ b/noxfile.py @@ -72,16 +72,17 @@ def default(session): # Install all test dependencies, then install this package in-place. session.install("asyncmock", "pytest-asyncio") - session.install("mock", "pytest", "pytest-cov") + session.install( + "mock", "pytest", "pytest-cov", + ) session.install("-e", ".") # Run py.test against the unit tests. session.run( "py.test", "--quiet", - "--cov=google.cloud.talent", - "--cov=google.cloud", - "--cov=tests.unit", + "--cov=google/cloud", + "--cov=tests/unit", "--cov-append", "--cov-config=.coveragerc", "--cov-report=", diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index ba55d7ce..bca0522e 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -17,6 +17,7 @@ import os from pathlib import Path import sys +from typing import Callable, Dict, List, Optional import nox @@ -39,6 +40,10 @@ # You can opt out from the test for specific Python versions. 'ignored_versions': ["2.7"], + # Old samples are opted out of enforcing Python type hints + # All new samples should feature them + 'enforce_type_hints': False, + # An envvar key for determining the project id to use. Change it # to 'BUILD_SPECIFIC_GCLOUD_PROJECT' if you want to opt in using a # build specific Cloud project. You can also use your own string @@ -64,7 +69,7 @@ TEST_CONFIG.update(TEST_CONFIG_OVERRIDE) -def get_pytest_env_vars(): +def get_pytest_env_vars() -> Dict[str, str]: """Returns a dict for pytest invocation.""" ret = {} @@ -93,7 +98,7 @@ def get_pytest_env_vars(): # -def _determine_local_import_names(start_dir): +def _determine_local_import_names(start_dir: str) -> List[str]: """Determines all import names that should be considered "local". This is used when running the linter to insure that import order is @@ -131,8 +136,11 @@ def _determine_local_import_names(start_dir): @nox.session -def lint(session): - session.install("flake8", "flake8-import-order") +def lint(session: nox.sessions.Session) -> None: + if not TEST_CONFIG['enforce_type_hints']: + session.install("flake8", "flake8-import-order") + else: + session.install("flake8", "flake8-import-order", "flake8-annotations") local_names = _determine_local_import_names(".") args = FLAKE8_COMMON_ARGS + [ @@ -141,8 +149,18 @@ def lint(session): "." ] session.run("flake8", *args) +# +# Black +# +@nox.session +def blacken(session: nox.sessions.Session) -> None: + session.install("black") + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + session.run("black", *python_files) + # # Sample Tests # @@ -151,7 +169,7 @@ def lint(session): PYTEST_COMMON_ARGS = ["--junitxml=sponge_log.xml"] -def _session_tests(session, post_install=None): +def _session_tests(session: nox.sessions.Session, post_install: Callable = None) -> None: """Runs py.test for a particular project.""" if os.path.exists("requirements.txt"): session.install("-r", "requirements.txt") @@ -177,7 +195,7 @@ def _session_tests(session, post_install=None): @nox.session(python=ALL_VERSIONS) -def py(session): +def py(session: nox.sessions.Session) -> None: """Runs py.test for a sample using the specified version of Python.""" if session.python in TESTED_VERSIONS: _session_tests(session) @@ -192,7 +210,7 @@ def py(session): # -def _get_repo_root(): +def _get_repo_root() -> Optional[str]: """ Returns the root folder of the project. """ # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) @@ -201,6 +219,11 @@ def _get_repo_root(): break if Path(p / ".git").exists(): return str(p) + # .git is not available in repos cloned via Cloud Build + # setup.py is always in the library's root, so use that instead + # https://github.com/googleapis/synthtool/issues/792 + if Path(p / "setup.py").exists(): + return str(p) p = p.parent raise Exception("Unable to detect repository root.") @@ -210,7 +233,7 @@ def _get_repo_root(): @nox.session @nox.parametrize("path", GENERATED_READMES) -def readmegen(session, path): +def readmegen(session: nox.sessions.Session, path: str) -> None: """(Re-)generates the readme for a sample.""" session.install("jinja2", "pyyaml") dir_ = os.path.dirname(path) diff --git a/synth.metadata b/synth.metadata index a7c427fa..5e9caea4 100644 --- a/synth.metadata +++ b/synth.metadata @@ -19,14 +19,14 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "0762e8ee2ec21cdfc4d82020b985a104feb0453b" + "sha": "373861061648b5fe5e0ac4f8a38b32d639ee93e4" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "0762e8ee2ec21cdfc4d82020b985a104feb0453b" + "sha": "373861061648b5fe5e0ac4f8a38b32d639ee93e4" } } ], @@ -94,6 +94,7 @@ ".kokoro/test-samples.sh", ".kokoro/trampoline.sh", ".kokoro/trampoline_v2.sh", + ".pre-commit-config.yaml", ".trampolinerc", "CODE_OF_CONDUCT.md", "CONTRIBUTING.rst", From 8a53830a77532e25ff0794e9fb5400e4ec01d4f5 Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 30 Dec 2020 08:10:33 -0800 Subject: [PATCH 6/9] chore: reorder classes and exceptions (#60) --- google/cloud/talent_v4/__init__.py | 2 +- google/cloud/talent_v4beta1/__init__.py | 2 +- .../services/application_service/async_client.py | 6 +++--- .../services/application_service/transports/base.py | 6 +++--- .../talent_v4beta1/services/company_service/async_client.py | 6 +++--- .../services/company_service/transports/base.py | 6 +++--- .../talent_v4beta1/services/completion/async_client.py | 2 +- .../talent_v4beta1/services/completion/transports/base.py | 2 +- .../talent_v4beta1/services/job_service/async_client.py | 6 +++--- .../talent_v4beta1/services/job_service/transports/base.py | 6 +++--- .../talent_v4beta1/services/profile_service/async_client.py | 6 +++--- .../services/profile_service/transports/base.py | 6 +++--- .../talent_v4beta1/services/tenant_service/async_client.py | 6 +++--- .../services/tenant_service/transports/base.py | 6 +++--- synth.metadata | 2 +- 15 files changed, 35 insertions(+), 35 deletions(-) diff --git a/google/cloud/talent_v4/__init__.py b/google/cloud/talent_v4/__init__.py index 2edd8d10..5d959d15 100644 --- a/google/cloud/talent_v4/__init__.py +++ b/google/cloud/talent_v4/__init__.py @@ -101,7 +101,6 @@ "CompensationInfo", "CompleteQueryRequest", "CompleteQueryResponse", - "CompletionClient", "CreateClientEventRequest", "CreateCompanyRequest", "CreateJobRequest", @@ -150,4 +149,5 @@ "UpdateJobRequest", "UpdateTenantRequest", "Visibility", + "CompletionClient", ) diff --git a/google/cloud/talent_v4beta1/__init__.py b/google/cloud/talent_v4beta1/__init__.py index 8374246b..e486a156 100644 --- a/google/cloud/talent_v4beta1/__init__.py +++ b/google/cloud/talent_v4beta1/__init__.py @@ -186,7 +186,6 @@ "EmployerFilter", "EmploymentRecord", "EmploymentType", - "EventServiceClient", "GetApplicationRequest", "GetCompanyRequest", "GetJobRequest", @@ -254,4 +253,5 @@ "UpdateTenantRequest", "Visibility", "WorkExperienceFilter", + "EventServiceClient", ) diff --git a/google/cloud/talent_v4beta1/services/application_service/async_client.py b/google/cloud/talent_v4beta1/services/application_service/async_client.py index 594ff4c2..8236846b 100644 --- a/google/cloud/talent_v4beta1/services/application_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/application_service/async_client.py @@ -308,7 +308,7 @@ async def get_application( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -461,7 +461,7 @@ async def delete_application( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -547,7 +547,7 @@ async def list_applications( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/application_service/transports/base.py b/google/cloud/talent_v4beta1/services/application_service/transports/base.py index 9f1da4f6..83ba6405 100644 --- a/google/cloud/talent_v4beta1/services/application_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/application_service/transports/base.py @@ -120,7 +120,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -136,7 +136,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/company_service/async_client.py b/google/cloud/talent_v4beta1/services/company_service/async_client.py index dd7aa172..98c39a8e 100644 --- a/google/cloud/talent_v4beta1/services/company_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/company_service/async_client.py @@ -308,7 +308,7 @@ async def get_company( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -469,7 +469,7 @@ async def delete_company( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -557,7 +557,7 @@ async def list_companies( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/company_service/transports/base.py b/google/cloud/talent_v4beta1/services/company_service/transports/base.py index e6e25567..39fb541b 100644 --- a/google/cloud/talent_v4beta1/services/company_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/company_service/transports/base.py @@ -120,7 +120,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -136,7 +136,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/completion/async_client.py b/google/cloud/talent_v4beta1/services/completion/async_client.py index 06946918..40da92eb 100644 --- a/google/cloud/talent_v4beta1/services/completion/async_client.py +++ b/google/cloud/talent_v4beta1/services/completion/async_client.py @@ -173,7 +173,7 @@ async def complete_query( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/completion/transports/base.py b/google/cloud/talent_v4beta1/services/completion/transports/base.py index b84df3c7..95e41990 100644 --- a/google/cloud/talent_v4beta1/services/completion/transports/base.py +++ b/google/cloud/talent_v4beta1/services/completion/transports/base.py @@ -114,7 +114,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/job_service/async_client.py b/google/cloud/talent_v4beta1/services/job_service/async_client.py index 07a5b431..a5ad40c6 100644 --- a/google/cloud/talent_v4beta1/services/job_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/job_service/async_client.py @@ -407,7 +407,7 @@ async def get_job( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -667,7 +667,7 @@ async def delete_job( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -872,7 +872,7 @@ async def list_jobs( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/job_service/transports/base.py b/google/cloud/talent_v4beta1/services/job_service/transports/base.py index 0821af69..ffef5f17 100644 --- a/google/cloud/talent_v4beta1/services/job_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/job_service/transports/base.py @@ -125,7 +125,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -144,7 +144,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -160,7 +160,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/profile_service/async_client.py b/google/cloud/talent_v4beta1/services/profile_service/async_client.py index c62a4c8f..914e2bf4 100644 --- a/google/cloud/talent_v4beta1/services/profile_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/profile_service/async_client.py @@ -216,7 +216,7 @@ async def list_profiles( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -391,7 +391,7 @@ async def get_profile( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -544,7 +544,7 @@ async def delete_profile( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/profile_service/transports/base.py b/google/cloud/talent_v4beta1/services/profile_service/transports/base.py index 8239d17a..dbd36ea2 100644 --- a/google/cloud/talent_v4beta1/services/profile_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/profile_service/transports/base.py @@ -117,7 +117,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -133,7 +133,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/tenant_service/async_client.py b/google/cloud/talent_v4beta1/services/tenant_service/async_client.py index 12205e77..be6fce85 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/async_client.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/async_client.py @@ -302,7 +302,7 @@ async def get_tenant( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -458,7 +458,7 @@ async def delete_tenant( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -542,7 +542,7 @@ async def list_tenants( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py b/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py index 3e9a73dc..b0f77c0d 100644 --- a/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py +++ b/google/cloud/talent_v4beta1/services/tenant_service/transports/base.py @@ -120,7 +120,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -136,7 +136,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, @@ -149,7 +149,7 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.ServiceUnavailable, exceptions.DeadlineExceeded, + exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, ), ), default_timeout=30.0, diff --git a/synth.metadata b/synth.metadata index 5e9caea4..c2c125ec 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-talent.git", - "sha": "fbe4d9b3c1fbd7d2ea684151e804885ce056be9f" + "sha": "d95d9bccf6fca2ee08181d3b63572ca1a4b97eb2" } }, { From cce8c40056678c3624ada4a531b8efa0eebf59c2 Mon Sep 17 00:00:00 2001 From: Justin Beckwith Date: Fri, 29 Jan 2021 08:14:08 -0800 Subject: [PATCH 7/9] build: migrate to flakybot (#67) --- .kokoro/test-samples.sh | 8 ++++---- .kokoro/trampoline_v2.sh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh index 4b0afc93..71fab05d 100755 --- a/.kokoro/test-samples.sh +++ b/.kokoro/test-samples.sh @@ -87,11 +87,11 @@ for file in samples/**/requirements.txt; do python3.6 -m nox -s "$RUN_TESTS_SESSION" EXIT=$? - # If this is a periodic build, send the test log to the Build Cop Bot. - # See https://github.com/googleapis/repo-automation-bots/tree/master/packages/buildcop. + # If this is a periodic build, send the test log to the FlakyBot. + # See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot. if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then - chmod +x $KOKORO_GFILE_DIR/linux_amd64/buildcop - $KOKORO_GFILE_DIR/linux_amd64/buildcop + chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot + $KOKORO_GFILE_DIR/linux_amd64/flakybot fi if [[ $EXIT -ne 0 ]]; then diff --git a/.kokoro/trampoline_v2.sh b/.kokoro/trampoline_v2.sh index 719bcd5b..4af6cdc2 100755 --- a/.kokoro/trampoline_v2.sh +++ b/.kokoro/trampoline_v2.sh @@ -159,7 +159,7 @@ if [[ -n "${KOKORO_BUILD_ID:-}" ]]; then "KOKORO_GITHUB_COMMIT" "KOKORO_GITHUB_PULL_REQUEST_NUMBER" "KOKORO_GITHUB_PULL_REQUEST_COMMIT" - # For Build Cop Bot + # For FlakyBot "KOKORO_GITHUB_COMMIT_URL" "KOKORO_GITHUB_PULL_REQUEST_URL" ) From b8e23be7d6adc872684f34c4ccf8fe68c0bd3de4 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Thu, 11 Feb 2021 10:32:04 -0700 Subject: [PATCH 8/9] chore: add constraints file (#61) Add constraints file to test lower bounds. These files will not be used until the noxfile is changed in googleapis/synthtool#869. --- testing/constraints-3.10.txt | 0 testing/constraints-3.11.txt | 0 testing/constraints-3.6.txt | 10 ++++++++++ testing/constraints-3.7.txt | 0 testing/constraints-3.8.txt | 0 testing/constraints-3.9.txt | 0 6 files changed, 10 insertions(+) create mode 100644 testing/constraints-3.10.txt create mode 100644 testing/constraints-3.11.txt create mode 100644 testing/constraints-3.6.txt create mode 100644 testing/constraints-3.7.txt create mode 100644 testing/constraints-3.8.txt create mode 100644 testing/constraints-3.9.txt diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt new file mode 100644 index 00000000..e69de29b diff --git a/testing/constraints-3.11.txt b/testing/constraints-3.11.txt new file mode 100644 index 00000000..e69de29b diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt new file mode 100644 index 00000000..2923be13 --- /dev/null +++ b/testing/constraints-3.6.txt @@ -0,0 +1,10 @@ +# This constraints file is used to check that lower bounds +# are correct in setup.py +# List *all* library dependencies and extras in this file. +# Pin the version to the lower bound. +# +# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", +# Then this file should have foo==1.14.0 +google-api-core==1.22.0 +proto-plus==1.4.0 +libcst==0.2.5 \ No newline at end of file diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt new file mode 100644 index 00000000..e69de29b diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt new file mode 100644 index 00000000..e69de29b diff --git a/testing/constraints-3.9.txt b/testing/constraints-3.9.txt new file mode 100644 index 00000000..e69de29b From d3cdb4347aa213944e8f39faa6abfa12adfc4b8b Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 1 Mar 2021 09:48:17 -0700 Subject: [PATCH 9/9] chore: release 2.1.0 (#59) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ setup.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 18834bcb..6d2981ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://pypi.org/project/google-cloud-talent/#history +## [2.1.0](https://www.github.com/googleapis/python-talent/compare/v2.0.0...v2.1.0) (2021-02-11) + + +### Features + +* add common resource helper methods; expose client transport remove gRPC send/recv limits ([#57](https://www.github.com/googleapis/python-talent/issues/57)) ([6f17871](https://www.github.com/googleapis/python-talent/commit/6f17871a73d2112b5792ad87bf4a2d0e25beb03e)) + ## [2.0.0](https://www.github.com/googleapis/python-talent/compare/v1.0.0...v2.0.0) (2020-10-02) diff --git a/setup.py b/setup.py index 8082e129..6cd77735 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-talent" description = "Google Cloud Talent Solution API client library" -version = "2.0.0" +version = "2.1.0" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta'