From d516460f96d0a5913eb7d5c331afd94ecb6edca4 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 00:02:28 +0000 Subject: [PATCH] chore(python): use black==22.3.0 (#163) Source-Link: https://github.com/googleapis/synthtool/commit/6fab84af09f2cf89a031fd8671d1def6b2931b11 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe --- .../.github/.OwlBot.lock.yaml | 2 +- packages/google-cloud-billing/docs/conf.py | 5 +- .../services/cloud_billing/async_client.py | 95 ++- .../services/cloud_billing/client.py | 125 ++- .../services/cloud_billing/transports/base.py | 10 +- .../services/cloud_billing/transports/grpc.py | 3 +- .../services/cloud_catalog/async_client.py | 28 +- .../services/cloud_catalog/client.py | 87 ++- .../services/cloud_catalog/transports/base.py | 18 +- .../services/cloud_catalog/transports/grpc.py | 3 +- .../cloud/billing_v1/types/cloud_billing.py | 128 +++- .../cloud/billing_v1/types/cloud_catalog.py | 231 ++++-- packages/google-cloud-billing/noxfile.py | 9 +- .../gapic/billing_v1/test_cloud_billing.py | 721 +++++++++++++----- .../gapic/billing_v1/test_cloud_catalog.py | 352 +++++++-- 15 files changed, 1401 insertions(+), 416 deletions(-) diff --git a/packages/google-cloud-billing/.github/.OwlBot.lock.yaml b/packages/google-cloud-billing/.github/.OwlBot.lock.yaml index 88076277a251..87dd00611576 100644 --- a/packages/google-cloud-billing/.github/.OwlBot.lock.yaml +++ b/packages/google-cloud-billing/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:2d13c2172a5d6129c861edaa48b60ead15aeaf58aa75e02d870c4cbdfa63aaba + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/packages/google-cloud-billing/docs/conf.py b/packages/google-cloud-billing/docs/conf.py index 964b39f6b621..8cfe2ad0abab 100644 --- a/packages/google-cloud-billing/docs/conf.py +++ b/packages/google-cloud-billing/docs/conf.py @@ -361,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/async_client.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/async_client.py index 02d3c2da2f1c..7400a9dba0d5 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/async_client.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/async_client.py @@ -300,7 +300,12 @@ def sample_get_billing_account(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -377,12 +382,20 @@ def sample_list_billing_accounts(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListBillingAccountsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -501,7 +514,12 @@ def sample_update_billing_account(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -599,7 +617,12 @@ def sample_create_billing_account(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -708,12 +731,20 @@ def sample_list_project_billing_info(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListProjectBillingInfoAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -821,7 +852,12 @@ def sample_get_project_billing_info(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -972,7 +1008,12 @@ def sample_update_project_billing_info(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1104,7 +1145,9 @@ def sample_get_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.GetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.GetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1131,7 +1174,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1264,7 +1312,9 @@ def sample_set_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.SetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.SetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1291,7 +1341,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1381,7 +1436,8 @@ def sample_test_iam_permissions(): request = iam_policy_pb2.TestIamPermissionsRequest(**request) elif not request: request = iam_policy_pb2.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1409,7 +1465,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1423,7 +1484,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-billing",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-billing", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/client.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/client.py index 7aca1ac575e1..239452c4b3c2 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/client.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/client.py @@ -55,7 +55,10 @@ class CloudBillingClientMeta(type): _transport_registry["grpc"] = CloudBillingGrpcTransport _transport_registry["grpc_asyncio"] = CloudBillingGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[CloudBillingTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[CloudBillingTransport]: """Returns an appropriate transport class. Args: @@ -162,7 +165,9 @@ def transport(self) -> CloudBillingTransport: return self._transport @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -175,9 +180,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -186,9 +195,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -197,9 +210,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -208,10 +225,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -475,7 +496,12 @@ def sample_get_billing_account(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -543,12 +569,20 @@ def sample_list_billing_accounts(): rpc = self._transport._wrapped_methods[self._transport.list_billing_accounts] # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListBillingAccountsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -657,7 +691,12 @@ def sample_update_billing_account(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -755,7 +794,12 @@ def sample_create_billing_account(): rpc = self._transport._wrapped_methods[self._transport.create_billing_account] # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -856,12 +900,20 @@ def sample_list_project_billing_info(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListProjectBillingInfoPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -959,7 +1011,12 @@ def sample_get_project_billing_info(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1102,7 +1159,12 @@ def sample_update_project_billing_info(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1250,7 +1312,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1399,7 +1466,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1506,7 +1578,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1527,7 +1604,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-billing",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-billing", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/base.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/base.py index 0cfea949d128..7d14a9465192 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/base.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/base.py @@ -31,7 +31,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-billing",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-billing", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -265,9 +267,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc.py index db1f17ed0007..cb83ac2bc1cc 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc.py @@ -227,8 +227,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/async_client.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/async_client.py index 2378ff02ce57..b6e41598f988 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/async_client.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/async_client.py @@ -261,12 +261,20 @@ def sample_list_services(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListServicesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -361,12 +369,20 @@ def sample_list_skus(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListSkusAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -381,7 +397,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-billing",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-billing", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/client.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/client.py index a8859cd2c5d6..10b3feb7a7d4 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/client.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/client.py @@ -53,7 +53,10 @@ class CloudCatalogClientMeta(type): _transport_registry["grpc"] = CloudCatalogGrpcTransport _transport_registry["grpc_asyncio"] = CloudCatalogGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[CloudCatalogTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[CloudCatalogTransport]: """Returns an appropriate transport class. Args: @@ -161,9 +164,13 @@ def transport(self) -> CloudCatalogTransport: return self._transport @staticmethod - def service_path(service: str,) -> str: + def service_path( + service: str, + ) -> str: """Returns a fully-qualified service string.""" - return "services/{service}".format(service=service,) + return "services/{service}".format( + service=service, + ) @staticmethod def parse_service_path(path: str) -> Dict[str, str]: @@ -172,9 +179,15 @@ def parse_service_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def sku_path(service: str, sku: str,) -> str: + def sku_path( + service: str, + sku: str, + ) -> str: """Returns a fully-qualified sku string.""" - return "services/{service}/skus/{sku}".format(service=service, sku=sku,) + return "services/{service}/skus/{sku}".format( + service=service, + sku=sku, + ) @staticmethod def parse_sku_path(path: str) -> Dict[str, str]: @@ -183,7 +196,9 @@ def parse_sku_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -196,9 +211,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -207,9 +226,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -218,9 +241,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -229,10 +256,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -465,12 +496,20 @@ def sample_list_services(): rpc = self._transport._wrapped_methods[self._transport.list_services] # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListServicesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -565,12 +604,20 @@ def sample_list_skus(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListSkusPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -592,7 +639,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-billing",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-billing", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/base.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/base.py index 0ceb1f41f590..38ba04b6f827 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/base.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/base.py @@ -29,7 +29,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-billing",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-billing", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -119,19 +121,23 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.list_services: gapic_v1.method.wrap_method( - self.list_services, default_timeout=60.0, client_info=client_info, + self.list_services, + default_timeout=60.0, + client_info=client_info, ), self.list_skus: gapic_v1.method.wrap_method( - self.list_skus, default_timeout=60.0, client_info=client_info, + self.list_skus, + default_timeout=60.0, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc.py index 342954a17f34..03080fbb1b13 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc.py @@ -226,8 +226,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/types/cloud_billing.py b/packages/google-cloud-billing/google/cloud/billing_v1/types/cloud_billing.py index 789d4101f04a..76e0bdbda5e3 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/types/cloud_billing.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/types/cloud_billing.py @@ -67,10 +67,22 @@ class BillingAccount(proto.Message): be empty. """ - name = proto.Field(proto.STRING, number=1,) - open_ = proto.Field(proto.BOOL, number=2,) - display_name = proto.Field(proto.STRING, number=3,) - master_billing_account = proto.Field(proto.STRING, number=4,) + name = proto.Field( + proto.STRING, + number=1, + ) + open_ = proto.Field( + proto.BOOL, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) + master_billing_account = proto.Field( + proto.STRING, + number=4, + ) class ProjectBillingInfo(proto.Message): @@ -106,10 +118,22 @@ class ProjectBillingInfo(proto.Message): paid services. This field is read-only. """ - name = proto.Field(proto.STRING, number=1,) - project_id = proto.Field(proto.STRING, number=2,) - billing_account_name = proto.Field(proto.STRING, number=3,) - billing_enabled = proto.Field(proto.BOOL, number=4,) + name = proto.Field( + proto.STRING, + number=1, + ) + project_id = proto.Field( + proto.STRING, + number=2, + ) + billing_account_name = proto.Field( + proto.STRING, + number=3, + ) + billing_enabled = proto.Field( + proto.BOOL, + number=4, + ) class GetBillingAccountRequest(proto.Message): @@ -122,7 +146,10 @@ class GetBillingAccountRequest(proto.Message): ``billingAccounts/012345-567890-ABCDEF``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListBillingAccountsRequest(proto.Message): @@ -147,9 +174,18 @@ class ListBillingAccountsRequest(proto.Message): supported. """ - page_size = proto.Field(proto.INT32, number=1,) - page_token = proto.Field(proto.STRING, number=2,) - filter = proto.Field(proto.STRING, number=3,) + page_size = proto.Field( + proto.INT32, + number=1, + ) + page_token = proto.Field( + proto.STRING, + number=2, + ) + filter = proto.Field( + proto.STRING, + number=3, + ) class ListBillingAccountsResponse(proto.Message): @@ -170,9 +206,14 @@ def raw_page(self): return self billing_accounts = proto.RepeatedField( - proto.MESSAGE, number=1, message="BillingAccount", + proto.MESSAGE, + number=1, + message="BillingAccount", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class CreateBillingAccountRequest(proto.Message): @@ -187,7 +228,11 @@ class CreateBillingAccountRequest(proto.Message): billing account. """ - billing_account = proto.Field(proto.MESSAGE, number=1, message="BillingAccount",) + billing_account = proto.Field( + proto.MESSAGE, + number=1, + message="BillingAccount", + ) class UpdateBillingAccountRequest(proto.Message): @@ -205,10 +250,19 @@ class UpdateBillingAccountRequest(proto.Message): is currently supported. """ - name = proto.Field(proto.STRING, number=1,) - account = proto.Field(proto.MESSAGE, number=2, message="BillingAccount",) + name = proto.Field( + proto.STRING, + number=1, + ) + account = proto.Field( + proto.MESSAGE, + number=2, + message="BillingAccount", + ) update_mask = proto.Field( - proto.MESSAGE, number=3, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=3, + message=field_mask_pb2.FieldMask, ) @@ -230,9 +284,18 @@ class ListProjectBillingInfoRequest(proto.Message): the first page of results is returned. """ - name = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + name = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListProjectBillingInfoResponse(proto.Message): @@ -254,9 +317,14 @@ def raw_page(self): return self project_billing_info = proto.RepeatedField( - proto.MESSAGE, number=1, message="ProjectBillingInfo", + proto.MESSAGE, + number=1, + message="ProjectBillingInfo", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class GetProjectBillingInfoRequest(proto.Message): @@ -269,7 +337,10 @@ class GetProjectBillingInfoRequest(proto.Message): ``projects/tokyo-rain-123``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class UpdateProjectBillingInfoRequest(proto.Message): @@ -286,9 +357,14 @@ class UpdateProjectBillingInfoRequest(proto.Message): except ``billing_account_name``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) project_billing_info = proto.Field( - proto.MESSAGE, number=2, message="ProjectBillingInfo", + proto.MESSAGE, + number=2, + message="ProjectBillingInfo", ) diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/types/cloud_catalog.py b/packages/google-cloud-billing/google/cloud/billing_v1/types/cloud_catalog.py index 693129adf24f..90c72fac1909 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/types/cloud_catalog.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/types/cloud_catalog.py @@ -55,10 +55,22 @@ class Service(proto.Message): "businessEntities/Maps". """ - name = proto.Field(proto.STRING, number=1,) - service_id = proto.Field(proto.STRING, number=2,) - display_name = proto.Field(proto.STRING, number=3,) - business_entity_name = proto.Field(proto.STRING, number=4,) + name = proto.Field( + proto.STRING, + number=1, + ) + service_id = proto.Field( + proto.STRING, + number=2, + ) + display_name = proto.Field( + proto.STRING, + number=3, + ) + business_entity_name = proto.Field( + proto.STRING, + number=4, + ) class Sku(proto.Message): @@ -92,13 +104,36 @@ class Sku(proto.Message): Google Cloud Platform. """ - name = proto.Field(proto.STRING, number=1,) - sku_id = proto.Field(proto.STRING, number=2,) - description = proto.Field(proto.STRING, number=3,) - category = proto.Field(proto.MESSAGE, number=4, message="Category",) - service_regions = proto.RepeatedField(proto.STRING, number=5,) - pricing_info = proto.RepeatedField(proto.MESSAGE, number=6, message="PricingInfo",) - service_provider_name = proto.Field(proto.STRING, number=7,) + name = proto.Field( + proto.STRING, + number=1, + ) + sku_id = proto.Field( + proto.STRING, + number=2, + ) + description = proto.Field( + proto.STRING, + number=3, + ) + category = proto.Field( + proto.MESSAGE, + number=4, + message="Category", + ) + service_regions = proto.RepeatedField( + proto.STRING, + number=5, + ) + pricing_info = proto.RepeatedField( + proto.MESSAGE, + number=6, + message="PricingInfo", + ) + service_provider_name = proto.Field( + proto.STRING, + number=7, + ) class Category(proto.Message): @@ -122,10 +157,22 @@ class Category(proto.Message): "Commit1Yr" etc. """ - service_display_name = proto.Field(proto.STRING, number=1,) - resource_family = proto.Field(proto.STRING, number=2,) - resource_group = proto.Field(proto.STRING, number=3,) - usage_type = proto.Field(proto.STRING, number=4,) + service_display_name = proto.Field( + proto.STRING, + number=1, + ) + resource_family = proto.Field( + proto.STRING, + number=2, + ) + resource_group = proto.Field( + proto.STRING, + number=3, + ) + usage_type = proto.Field( + proto.STRING, + number=4, + ) class PricingInfo(proto.Message): @@ -161,14 +208,28 @@ class PricingInfo(proto.Message): """ effective_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, + ) + summary = proto.Field( + proto.STRING, + number=2, ) - summary = proto.Field(proto.STRING, number=2,) pricing_expression = proto.Field( - proto.MESSAGE, number=3, message="PricingExpression", + proto.MESSAGE, + number=3, + message="PricingExpression", + ) + aggregation_info = proto.Field( + proto.MESSAGE, + number=4, + message="AggregationInfo", + ) + currency_conversion_rate = proto.Field( + proto.DOUBLE, + number=5, ) - aggregation_info = proto.Field(proto.MESSAGE, number=4, message="AggregationInfo",) - currency_conversion_rate = proto.Field(proto.DOUBLE, number=5,) class PricingExpression(proto.Message): @@ -234,16 +295,45 @@ class TierRate(proto.Message): $10 indicates that each unit will cost $10. """ - start_usage_amount = proto.Field(proto.DOUBLE, number=1,) - unit_price = proto.Field(proto.MESSAGE, number=2, message=money_pb2.Money,) - - usage_unit = proto.Field(proto.STRING, number=1,) - usage_unit_description = proto.Field(proto.STRING, number=4,) - base_unit = proto.Field(proto.STRING, number=5,) - base_unit_description = proto.Field(proto.STRING, number=6,) - base_unit_conversion_factor = proto.Field(proto.DOUBLE, number=7,) - display_quantity = proto.Field(proto.DOUBLE, number=2,) - tiered_rates = proto.RepeatedField(proto.MESSAGE, number=3, message=TierRate,) + start_usage_amount = proto.Field( + proto.DOUBLE, + number=1, + ) + unit_price = proto.Field( + proto.MESSAGE, + number=2, + message=money_pb2.Money, + ) + + usage_unit = proto.Field( + proto.STRING, + number=1, + ) + usage_unit_description = proto.Field( + proto.STRING, + number=4, + ) + base_unit = proto.Field( + proto.STRING, + number=5, + ) + base_unit_description = proto.Field( + proto.STRING, + number=6, + ) + base_unit_conversion_factor = proto.Field( + proto.DOUBLE, + number=7, + ) + display_quantity = proto.Field( + proto.DOUBLE, + number=2, + ) + tiered_rates = proto.RepeatedField( + proto.MESSAGE, + number=3, + message=TierRate, + ) class AggregationInfo(proto.Message): @@ -280,9 +370,20 @@ class AggregationInterval(proto.Enum): DAILY = 1 MONTHLY = 2 - aggregation_level = proto.Field(proto.ENUM, number=1, enum=AggregationLevel,) - aggregation_interval = proto.Field(proto.ENUM, number=2, enum=AggregationInterval,) - aggregation_count = proto.Field(proto.INT32, number=3,) + aggregation_level = proto.Field( + proto.ENUM, + number=1, + enum=AggregationLevel, + ) + aggregation_interval = proto.Field( + proto.ENUM, + number=2, + enum=AggregationInterval, + ) + aggregation_count = proto.Field( + proto.INT32, + number=3, + ) class ListServicesRequest(proto.Message): @@ -298,8 +399,14 @@ class ListServicesRequest(proto.Message): results is returned. """ - page_size = proto.Field(proto.INT32, number=1,) - page_token = proto.Field(proto.STRING, number=2,) + page_size = proto.Field( + proto.INT32, + number=1, + ) + page_token = proto.Field( + proto.STRING, + number=2, + ) class ListServicesResponse(proto.Message): @@ -319,8 +426,15 @@ class ListServicesResponse(proto.Message): def raw_page(self): return self - services = proto.RepeatedField(proto.MESSAGE, number=1, message="Service",) - next_page_token = proto.Field(proto.STRING, number=2,) + services = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Service", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class ListSkusRequest(proto.Message): @@ -357,12 +471,32 @@ class ListSkusRequest(proto.Message): is returned. """ - parent = proto.Field(proto.STRING, number=1,) - start_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - currency_code = proto.Field(proto.STRING, number=4,) - page_size = proto.Field(proto.INT32, number=5,) - page_token = proto.Field(proto.STRING, number=6,) + parent = proto.Field( + proto.STRING, + number=1, + ) + start_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + end_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + currency_code = proto.Field( + proto.STRING, + number=4, + ) + page_size = proto.Field( + proto.INT32, + number=5, + ) + page_token = proto.Field( + proto.STRING, + number=6, + ) class ListSkusResponse(proto.Message): @@ -382,8 +516,15 @@ class ListSkusResponse(proto.Message): def raw_page(self): return self - skus = proto.RepeatedField(proto.MESSAGE, number=1, message="Sku",) - next_page_token = proto.Field(proto.STRING, number=2,) + skus = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Sku", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/packages/google-cloud-billing/noxfile.py b/packages/google-cloud-billing/noxfile.py index 2a2001c49998..3addb4ed9431 100644 --- a/packages/google-cloud-billing/noxfile.py +++ b/packages/google-cloud-billing/noxfile.py @@ -24,7 +24,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" @@ -57,7 +57,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +69,8 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) diff --git a/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_billing.py b/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_billing.py index 2099ec76e867..92c1c4662c47 100644 --- a/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_billing.py +++ b/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_billing.py @@ -86,7 +86,13 @@ def test__get_default_mtls_endpoint(): assert CloudBillingClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [CloudBillingClient, CloudBillingAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + CloudBillingClient, + CloudBillingAsyncClient, + ], +) def test_cloud_billing_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -126,7 +132,13 @@ def test_cloud_billing_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [CloudBillingClient, CloudBillingAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + CloudBillingClient, + CloudBillingAsyncClient, + ], +) def test_cloud_billing_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -481,7 +493,9 @@ def test_cloud_billing_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -620,11 +634,16 @@ def test_cloud_billing_client_create_channel_credentials_file( @pytest.mark.parametrize( - "request_type", [cloud_billing.GetBillingAccountRequest, dict,] + "request_type", + [ + cloud_billing.GetBillingAccountRequest, + dict, + ], ) def test_get_billing_account(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -661,7 +680,8 @@ def test_get_billing_account_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -679,7 +699,8 @@ async def test_get_billing_account_async( transport: str = "grpc_asyncio", request_type=cloud_billing.GetBillingAccountRequest ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -720,7 +741,9 @@ async def test_get_billing_account_async_from_dict(): def test_get_billing_account_field_headers(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -742,12 +765,17 @@ def test_get_billing_account_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_billing_account_field_headers_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -771,11 +799,16 @@ async def test_get_billing_account_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_billing_account_flattened(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -785,7 +818,9 @@ def test_get_billing_account_flattened(): call.return_value = cloud_billing.BillingAccount() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_billing_account(name="name_value",) + client.get_billing_account( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -797,19 +832,24 @@ def test_get_billing_account_flattened(): def test_get_billing_account_flattened_error(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_billing_account( - cloud_billing.GetBillingAccountRequest(), name="name_value", + cloud_billing.GetBillingAccountRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_billing_account_flattened_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -823,7 +863,9 @@ async def test_get_billing_account_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_billing_account(name="name_value",) + response = await client.get_billing_account( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -836,22 +878,30 @@ async def test_get_billing_account_flattened_async(): @pytest.mark.asyncio async def test_get_billing_account_flattened_error_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_billing_account( - cloud_billing.GetBillingAccountRequest(), name="name_value", + cloud_billing.GetBillingAccountRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [cloud_billing.ListBillingAccountsRequest, dict,] + "request_type", + [ + cloud_billing.ListBillingAccountsRequest, + dict, + ], ) def test_list_billing_accounts(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -882,7 +932,8 @@ def test_list_billing_accounts_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -901,7 +952,8 @@ async def test_list_billing_accounts_async( request_type=cloud_billing.ListBillingAccountsRequest, ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -937,7 +989,8 @@ async def test_list_billing_accounts_async_from_dict(): def test_list_billing_accounts_pager(transport_name: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -955,10 +1008,13 @@ def test_list_billing_accounts_pager(transport_name: str = "grpc"): next_page_token="abc", ), cloud_billing.ListBillingAccountsResponse( - billing_accounts=[], next_page_token="def", + billing_accounts=[], + next_page_token="def", ), cloud_billing.ListBillingAccountsResponse( - billing_accounts=[cloud_billing.BillingAccount(),], + billing_accounts=[ + cloud_billing.BillingAccount(), + ], next_page_token="ghi", ), cloud_billing.ListBillingAccountsResponse( @@ -982,7 +1038,8 @@ def test_list_billing_accounts_pager(transport_name: str = "grpc"): def test_list_billing_accounts_pages(transport_name: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1000,10 +1057,13 @@ def test_list_billing_accounts_pages(transport_name: str = "grpc"): next_page_token="abc", ), cloud_billing.ListBillingAccountsResponse( - billing_accounts=[], next_page_token="def", + billing_accounts=[], + next_page_token="def", ), cloud_billing.ListBillingAccountsResponse( - billing_accounts=[cloud_billing.BillingAccount(),], + billing_accounts=[ + cloud_billing.BillingAccount(), + ], next_page_token="ghi", ), cloud_billing.ListBillingAccountsResponse( @@ -1021,7 +1081,9 @@ def test_list_billing_accounts_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_billing_accounts_async_pager(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1040,10 +1102,13 @@ async def test_list_billing_accounts_async_pager(): next_page_token="abc", ), cloud_billing.ListBillingAccountsResponse( - billing_accounts=[], next_page_token="def", + billing_accounts=[], + next_page_token="def", ), cloud_billing.ListBillingAccountsResponse( - billing_accounts=[cloud_billing.BillingAccount(),], + billing_accounts=[ + cloud_billing.BillingAccount(), + ], next_page_token="ghi", ), cloud_billing.ListBillingAccountsResponse( @@ -1054,7 +1119,9 @@ async def test_list_billing_accounts_async_pager(): ), RuntimeError, ) - async_pager = await client.list_billing_accounts(request={},) + async_pager = await client.list_billing_accounts( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1066,7 +1133,9 @@ async def test_list_billing_accounts_async_pager(): @pytest.mark.asyncio async def test_list_billing_accounts_async_pages(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1085,10 +1154,13 @@ async def test_list_billing_accounts_async_pages(): next_page_token="abc", ), cloud_billing.ListBillingAccountsResponse( - billing_accounts=[], next_page_token="def", + billing_accounts=[], + next_page_token="def", ), cloud_billing.ListBillingAccountsResponse( - billing_accounts=[cloud_billing.BillingAccount(),], + billing_accounts=[ + cloud_billing.BillingAccount(), + ], next_page_token="ghi", ), cloud_billing.ListBillingAccountsResponse( @@ -1107,11 +1179,16 @@ async def test_list_billing_accounts_async_pages(): @pytest.mark.parametrize( - "request_type", [cloud_billing.UpdateBillingAccountRequest, dict,] + "request_type", + [ + cloud_billing.UpdateBillingAccountRequest, + dict, + ], ) def test_update_billing_account(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1148,7 +1225,8 @@ def test_update_billing_account_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1167,7 +1245,8 @@ async def test_update_billing_account_async( request_type=cloud_billing.UpdateBillingAccountRequest, ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1208,7 +1287,9 @@ async def test_update_billing_account_async_from_dict(): def test_update_billing_account_field_headers(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1230,12 +1311,17 @@ def test_update_billing_account_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_billing_account_field_headers_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1259,11 +1345,16 @@ async def test_update_billing_account_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_update_billing_account_flattened(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1274,7 +1365,8 @@ def test_update_billing_account_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_billing_account( - name="name_value", account=cloud_billing.BillingAccount(name="name_value"), + name="name_value", + account=cloud_billing.BillingAccount(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1290,7 +1382,9 @@ def test_update_billing_account_flattened(): def test_update_billing_account_flattened_error(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1304,7 +1398,9 @@ def test_update_billing_account_flattened_error(): @pytest.mark.asyncio async def test_update_billing_account_flattened_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1319,7 +1415,8 @@ async def test_update_billing_account_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.update_billing_account( - name="name_value", account=cloud_billing.BillingAccount(name="name_value"), + name="name_value", + account=cloud_billing.BillingAccount(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1336,7 +1433,9 @@ async def test_update_billing_account_flattened_async(): @pytest.mark.asyncio async def test_update_billing_account_flattened_error_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1349,11 +1448,16 @@ async def test_update_billing_account_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [cloud_billing.CreateBillingAccountRequest, dict,] + "request_type", + [ + cloud_billing.CreateBillingAccountRequest, + dict, + ], ) def test_create_billing_account(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1390,7 +1494,8 @@ def test_create_billing_account_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1409,7 +1514,8 @@ async def test_create_billing_account_async( request_type=cloud_billing.CreateBillingAccountRequest, ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1450,7 +1556,9 @@ async def test_create_billing_account_async_from_dict(): def test_create_billing_account_flattened(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1474,7 +1582,9 @@ def test_create_billing_account_flattened(): def test_create_billing_account_flattened_error(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1487,7 +1597,9 @@ def test_create_billing_account_flattened_error(): @pytest.mark.asyncio async def test_create_billing_account_flattened_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1516,7 +1628,9 @@ async def test_create_billing_account_flattened_async(): @pytest.mark.asyncio async def test_create_billing_account_flattened_error_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1528,11 +1642,16 @@ async def test_create_billing_account_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [cloud_billing.ListProjectBillingInfoRequest, dict,] + "request_type", + [ + cloud_billing.ListProjectBillingInfoRequest, + dict, + ], ) def test_list_project_billing_info(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1563,7 +1682,8 @@ def test_list_project_billing_info_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1582,7 +1702,8 @@ async def test_list_project_billing_info_async( request_type=cloud_billing.ListProjectBillingInfoRequest, ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1617,7 +1738,9 @@ async def test_list_project_billing_info_async_from_dict(): def test_list_project_billing_info_field_headers(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1639,12 +1762,17 @@ def test_list_project_billing_info_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_project_billing_info_field_headers_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1668,11 +1796,16 @@ async def test_list_project_billing_info_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_list_project_billing_info_flattened(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1682,7 +1815,9 @@ def test_list_project_billing_info_flattened(): call.return_value = cloud_billing.ListProjectBillingInfoResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_project_billing_info(name="name_value",) + client.list_project_billing_info( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1694,19 +1829,24 @@ def test_list_project_billing_info_flattened(): def test_list_project_billing_info_flattened_error(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_project_billing_info( - cloud_billing.ListProjectBillingInfoRequest(), name="name_value", + cloud_billing.ListProjectBillingInfoRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_list_project_billing_info_flattened_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1720,7 +1860,9 @@ async def test_list_project_billing_info_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_project_billing_info(name="name_value",) + response = await client.list_project_billing_info( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1733,19 +1875,23 @@ async def test_list_project_billing_info_flattened_async(): @pytest.mark.asyncio async def test_list_project_billing_info_flattened_error_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_project_billing_info( - cloud_billing.ListProjectBillingInfoRequest(), name="name_value", + cloud_billing.ListProjectBillingInfoRequest(), + name="name_value", ) def test_list_project_billing_info_pager(transport_name: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1763,10 +1909,13 @@ def test_list_project_billing_info_pager(transport_name: str = "grpc"): next_page_token="abc", ), cloud_billing.ListProjectBillingInfoResponse( - project_billing_info=[], next_page_token="def", + project_billing_info=[], + next_page_token="def", ), cloud_billing.ListProjectBillingInfoResponse( - project_billing_info=[cloud_billing.ProjectBillingInfo(),], + project_billing_info=[ + cloud_billing.ProjectBillingInfo(), + ], next_page_token="ghi", ), cloud_billing.ListProjectBillingInfoResponse( @@ -1793,7 +1942,8 @@ def test_list_project_billing_info_pager(transport_name: str = "grpc"): def test_list_project_billing_info_pages(transport_name: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1811,10 +1961,13 @@ def test_list_project_billing_info_pages(transport_name: str = "grpc"): next_page_token="abc", ), cloud_billing.ListProjectBillingInfoResponse( - project_billing_info=[], next_page_token="def", + project_billing_info=[], + next_page_token="def", ), cloud_billing.ListProjectBillingInfoResponse( - project_billing_info=[cloud_billing.ProjectBillingInfo(),], + project_billing_info=[ + cloud_billing.ProjectBillingInfo(), + ], next_page_token="ghi", ), cloud_billing.ListProjectBillingInfoResponse( @@ -1832,7 +1985,9 @@ def test_list_project_billing_info_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_project_billing_info_async_pager(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1851,10 +2006,13 @@ async def test_list_project_billing_info_async_pager(): next_page_token="abc", ), cloud_billing.ListProjectBillingInfoResponse( - project_billing_info=[], next_page_token="def", + project_billing_info=[], + next_page_token="def", ), cloud_billing.ListProjectBillingInfoResponse( - project_billing_info=[cloud_billing.ProjectBillingInfo(),], + project_billing_info=[ + cloud_billing.ProjectBillingInfo(), + ], next_page_token="ghi", ), cloud_billing.ListProjectBillingInfoResponse( @@ -1865,7 +2023,9 @@ async def test_list_project_billing_info_async_pager(): ), RuntimeError, ) - async_pager = await client.list_project_billing_info(request={},) + async_pager = await client.list_project_billing_info( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1877,7 +2037,9 @@ async def test_list_project_billing_info_async_pager(): @pytest.mark.asyncio async def test_list_project_billing_info_async_pages(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1896,10 +2058,13 @@ async def test_list_project_billing_info_async_pages(): next_page_token="abc", ), cloud_billing.ListProjectBillingInfoResponse( - project_billing_info=[], next_page_token="def", + project_billing_info=[], + next_page_token="def", ), cloud_billing.ListProjectBillingInfoResponse( - project_billing_info=[cloud_billing.ProjectBillingInfo(),], + project_billing_info=[ + cloud_billing.ProjectBillingInfo(), + ], next_page_token="ghi", ), cloud_billing.ListProjectBillingInfoResponse( @@ -1918,11 +2083,16 @@ async def test_list_project_billing_info_async_pages(): @pytest.mark.parametrize( - "request_type", [cloud_billing.GetProjectBillingInfoRequest, dict,] + "request_type", + [ + cloud_billing.GetProjectBillingInfoRequest, + dict, + ], ) def test_get_project_billing_info(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1959,7 +2129,8 @@ def test_get_project_billing_info_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1978,7 +2149,8 @@ async def test_get_project_billing_info_async( request_type=cloud_billing.GetProjectBillingInfoRequest, ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2019,7 +2191,9 @@ async def test_get_project_billing_info_async_from_dict(): def test_get_project_billing_info_field_headers(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2041,12 +2215,17 @@ def test_get_project_billing_info_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_project_billing_info_field_headers_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2070,11 +2249,16 @@ async def test_get_project_billing_info_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_project_billing_info_flattened(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2084,7 +2268,9 @@ def test_get_project_billing_info_flattened(): call.return_value = cloud_billing.ProjectBillingInfo() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_project_billing_info(name="name_value",) + client.get_project_billing_info( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2096,19 +2282,24 @@ def test_get_project_billing_info_flattened(): def test_get_project_billing_info_flattened_error(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_project_billing_info( - cloud_billing.GetProjectBillingInfoRequest(), name="name_value", + cloud_billing.GetProjectBillingInfoRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_project_billing_info_flattened_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2122,7 +2313,9 @@ async def test_get_project_billing_info_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_project_billing_info(name="name_value",) + response = await client.get_project_billing_info( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2135,22 +2328,30 @@ async def test_get_project_billing_info_flattened_async(): @pytest.mark.asyncio async def test_get_project_billing_info_flattened_error_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_project_billing_info( - cloud_billing.GetProjectBillingInfoRequest(), name="name_value", + cloud_billing.GetProjectBillingInfoRequest(), + name="name_value", ) @pytest.mark.parametrize( - "request_type", [cloud_billing.UpdateProjectBillingInfoRequest, dict,] + "request_type", + [ + cloud_billing.UpdateProjectBillingInfoRequest, + dict, + ], ) def test_update_project_billing_info(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2187,7 +2388,8 @@ def test_update_project_billing_info_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2206,7 +2408,8 @@ async def test_update_project_billing_info_async( request_type=cloud_billing.UpdateProjectBillingInfoRequest, ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2247,7 +2450,9 @@ async def test_update_project_billing_info_async_from_dict(): def test_update_project_billing_info_field_headers(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2269,12 +2474,17 @@ def test_update_project_billing_info_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_project_billing_info_field_headers_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2298,11 +2508,16 @@ async def test_update_project_billing_info_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_update_project_billing_info_flattened(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2330,7 +2545,9 @@ def test_update_project_billing_info_flattened(): def test_update_project_billing_info_flattened_error(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2344,7 +2561,9 @@ def test_update_project_billing_info_flattened_error(): @pytest.mark.asyncio async def test_update_project_billing_info_flattened_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2377,7 +2596,9 @@ async def test_update_project_billing_info_flattened_async(): @pytest.mark.asyncio async def test_update_project_billing_info_flattened_error_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2389,10 +2610,17 @@ async def test_update_project_billing_info_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) def test_get_iam_policy(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2402,7 +2630,10 @@ def test_get_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2420,7 +2651,8 @@ def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2436,7 +2668,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2447,7 +2680,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -2468,7 +2704,9 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2488,12 +2726,17 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2513,11 +2756,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2532,7 +2780,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2540,7 +2790,9 @@ def test_get_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy(resource="resource_value",) + client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2552,19 +2804,24 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_get_iam_policy_flattened_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2574,7 +2831,9 @@ async def test_get_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy(resource="resource_value",) + response = await client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2587,20 +2846,30 @@ async def test_get_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_get_iam_policy_flattened_error_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) def test_set_iam_policy(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2610,7 +2879,10 @@ def test_set_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2628,7 +2900,8 @@ def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2644,7 +2917,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2655,7 +2929,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -2676,7 +2953,9 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2696,12 +2975,17 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2721,11 +3005,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2740,7 +3029,9 @@ def test_set_iam_policy_from_dict_foreign(): def test_set_iam_policy_flattened(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2748,7 +3039,9 @@ def test_set_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy(resource="resource_value",) + client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2760,19 +3053,24 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_set_iam_policy_flattened_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2782,7 +3080,9 @@ async def test_set_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy(resource="resource_value",) + response = await client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2795,22 +3095,30 @@ async def test_set_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_set_iam_policy_flattened_error_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.parametrize( - "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], ) def test_test_iam_permissions(request_type, transport: str = "grpc"): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2841,7 +3149,8 @@ def test_test_iam_permissions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2860,7 +3169,8 @@ async def test_test_iam_permissions_async( request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2895,7 +3205,9 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2917,12 +3229,17 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2946,11 +3263,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -2967,7 +3289,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2978,7 +3302,8 @@ def test_test_iam_permissions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2994,7 +3319,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3008,7 +3335,9 @@ def test_test_iam_permissions_flattened_error(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3023,7 +3352,8 @@ async def test_test_iam_permissions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -3040,7 +3370,9 @@ async def test_test_iam_permissions_flattened_async(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_error_async(): - client = CloudBillingAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBillingAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3059,7 +3391,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -3079,7 +3412,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = CloudBillingClient(client_options=options, transport=transport,) + client = CloudBillingClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -3095,7 +3431,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudBillingClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -3140,8 +3477,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = CloudBillingClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.CloudBillingGrpcTransport,) + client = CloudBillingClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CloudBillingGrpcTransport, + ) def test_cloud_billing_base_transport_error(): @@ -3195,7 +3537,8 @@ def test_cloud_billing_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CloudBillingTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -3350,7 +3693,8 @@ def test_cloud_billing_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.CloudBillingGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3362,7 +3706,8 @@ def test_cloud_billing_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.CloudBillingGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3483,7 +3828,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = CloudBillingClient.common_folder_path(folder) assert expected == actual @@ -3501,7 +3848,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = CloudBillingClient.common_organization_path(organization) assert expected == actual @@ -3519,7 +3868,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = CloudBillingClient.common_project_path(project) assert expected == actual @@ -3539,7 +3890,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = CloudBillingClient.common_location_path(project, location) assert expected == actual @@ -3564,7 +3916,8 @@ def test_client_with_default_client_info(): transports.CloudBillingTransport, "_prep_wrapped_messages" ) as prep: client = CloudBillingClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3573,7 +3926,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = CloudBillingClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3581,7 +3935,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = CloudBillingAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_catalog.py b/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_catalog.py index 619f96ac1a43..3f45fc6f1115 100644 --- a/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_catalog.py +++ b/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_catalog.py @@ -82,7 +82,13 @@ def test__get_default_mtls_endpoint(): assert CloudCatalogClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [CloudCatalogClient, CloudCatalogAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + CloudCatalogClient, + CloudCatalogAsyncClient, + ], +) def test_cloud_catalog_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -122,7 +128,13 @@ def test_cloud_catalog_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [CloudCatalogClient, CloudCatalogAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + CloudCatalogClient, + CloudCatalogAsyncClient, + ], +) def test_cloud_catalog_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -477,7 +489,9 @@ def test_cloud_catalog_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -615,10 +629,17 @@ def test_cloud_catalog_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [cloud_catalog.ListServicesRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloud_catalog.ListServicesRequest, + dict, + ], +) def test_list_services(request_type, transport: str = "grpc"): client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -647,7 +668,8 @@ def test_list_services_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -663,7 +685,8 @@ async def test_list_services_async( transport: str = "grpc_asyncio", request_type=cloud_catalog.ListServicesRequest ): client = CloudCatalogAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -674,7 +697,9 @@ async def test_list_services_async( with mock.patch.object(type(client.transport.list_services), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloud_catalog.ListServicesResponse(next_page_token="next_page_token_value",) + cloud_catalog.ListServicesResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_services(request) @@ -695,7 +720,8 @@ async def test_list_services_async_from_dict(): def test_list_services_pager(transport_name: str = "grpc"): client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -710,12 +736,21 @@ def test_list_services_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - cloud_catalog.ListServicesResponse(services=[], next_page_token="def",), cloud_catalog.ListServicesResponse( - services=[cloud_catalog.Service(),], next_page_token="ghi", + services=[], + next_page_token="def", ), cloud_catalog.ListServicesResponse( - services=[cloud_catalog.Service(), cloud_catalog.Service(),], + services=[ + cloud_catalog.Service(), + ], + next_page_token="ghi", + ), + cloud_catalog.ListServicesResponse( + services=[ + cloud_catalog.Service(), + cloud_catalog.Service(), + ], ), RuntimeError, ) @@ -732,7 +767,8 @@ def test_list_services_pager(transport_name: str = "grpc"): def test_list_services_pages(transport_name: str = "grpc"): client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -747,12 +783,21 @@ def test_list_services_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - cloud_catalog.ListServicesResponse(services=[], next_page_token="def",), cloud_catalog.ListServicesResponse( - services=[cloud_catalog.Service(),], next_page_token="ghi", + services=[], + next_page_token="def", ), cloud_catalog.ListServicesResponse( - services=[cloud_catalog.Service(), cloud_catalog.Service(),], + services=[ + cloud_catalog.Service(), + ], + next_page_token="ghi", + ), + cloud_catalog.ListServicesResponse( + services=[ + cloud_catalog.Service(), + cloud_catalog.Service(), + ], ), RuntimeError, ) @@ -763,7 +808,9 @@ def test_list_services_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_services_async_pager(): - client = CloudCatalogAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudCatalogAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -779,16 +826,27 @@ async def test_list_services_async_pager(): ], next_page_token="abc", ), - cloud_catalog.ListServicesResponse(services=[], next_page_token="def",), cloud_catalog.ListServicesResponse( - services=[cloud_catalog.Service(),], next_page_token="ghi", + services=[], + next_page_token="def", ), cloud_catalog.ListServicesResponse( - services=[cloud_catalog.Service(), cloud_catalog.Service(),], + services=[ + cloud_catalog.Service(), + ], + next_page_token="ghi", + ), + cloud_catalog.ListServicesResponse( + services=[ + cloud_catalog.Service(), + cloud_catalog.Service(), + ], ), RuntimeError, ) - async_pager = await client.list_services(request={},) + async_pager = await client.list_services( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -800,7 +858,9 @@ async def test_list_services_async_pager(): @pytest.mark.asyncio async def test_list_services_async_pages(): - client = CloudCatalogAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudCatalogAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -816,12 +876,21 @@ async def test_list_services_async_pages(): ], next_page_token="abc", ), - cloud_catalog.ListServicesResponse(services=[], next_page_token="def",), cloud_catalog.ListServicesResponse( - services=[cloud_catalog.Service(),], next_page_token="ghi", + services=[], + next_page_token="def", + ), + cloud_catalog.ListServicesResponse( + services=[ + cloud_catalog.Service(), + ], + next_page_token="ghi", ), cloud_catalog.ListServicesResponse( - services=[cloud_catalog.Service(), cloud_catalog.Service(),], + services=[ + cloud_catalog.Service(), + cloud_catalog.Service(), + ], ), RuntimeError, ) @@ -832,10 +901,17 @@ async def test_list_services_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [cloud_catalog.ListSkusRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloud_catalog.ListSkusRequest, + dict, + ], +) def test_list_skus(request_type, transport: str = "grpc"): client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -864,7 +940,8 @@ def test_list_skus_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -880,7 +957,8 @@ async def test_list_skus_async( transport: str = "grpc_asyncio", request_type=cloud_catalog.ListSkusRequest ): client = CloudCatalogAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -891,7 +969,9 @@ async def test_list_skus_async( with mock.patch.object(type(client.transport.list_skus), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloud_catalog.ListSkusResponse(next_page_token="next_page_token_value",) + cloud_catalog.ListSkusResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_skus(request) @@ -911,7 +991,9 @@ async def test_list_skus_async_from_dict(): def test_list_skus_field_headers(): - client = CloudCatalogClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudCatalogClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -931,12 +1013,17 @@ def test_list_skus_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_skus_field_headers_async(): - client = CloudCatalogAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudCatalogAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -958,11 +1045,16 @@ async def test_list_skus_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_skus_flattened(): - client = CloudCatalogClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudCatalogClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_skus), "__call__") as call: @@ -970,7 +1062,9 @@ def test_list_skus_flattened(): call.return_value = cloud_catalog.ListSkusResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_skus(parent="parent_value",) + client.list_skus( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -982,19 +1076,24 @@ def test_list_skus_flattened(): def test_list_skus_flattened_error(): - client = CloudCatalogClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudCatalogClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_skus( - cloud_catalog.ListSkusRequest(), parent="parent_value", + cloud_catalog.ListSkusRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_skus_flattened_async(): - client = CloudCatalogAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudCatalogAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_skus), "__call__") as call: @@ -1006,7 +1105,9 @@ async def test_list_skus_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_skus(parent="parent_value",) + response = await client.list_skus( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1019,19 +1120,23 @@ async def test_list_skus_flattened_async(): @pytest.mark.asyncio async def test_list_skus_flattened_error_async(): - client = CloudCatalogAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudCatalogAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_skus( - cloud_catalog.ListSkusRequest(), parent="parent_value", + cloud_catalog.ListSkusRequest(), + parent="parent_value", ) def test_list_skus_pager(transport_name: str = "grpc"): client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1039,15 +1144,28 @@ def test_list_skus_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(), cloud_catalog.Sku(), cloud_catalog.Sku(),], + skus=[ + cloud_catalog.Sku(), + cloud_catalog.Sku(), + cloud_catalog.Sku(), + ], next_page_token="abc", ), - cloud_catalog.ListSkusResponse(skus=[], next_page_token="def",), cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(),], next_page_token="ghi", + skus=[], + next_page_token="def", ), cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(), cloud_catalog.Sku(),], + skus=[ + cloud_catalog.Sku(), + ], + next_page_token="ghi", + ), + cloud_catalog.ListSkusResponse( + skus=[ + cloud_catalog.Sku(), + cloud_catalog.Sku(), + ], ), RuntimeError, ) @@ -1067,7 +1185,8 @@ def test_list_skus_pager(transport_name: str = "grpc"): def test_list_skus_pages(transport_name: str = "grpc"): client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1075,15 +1194,28 @@ def test_list_skus_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(), cloud_catalog.Sku(), cloud_catalog.Sku(),], + skus=[ + cloud_catalog.Sku(), + cloud_catalog.Sku(), + cloud_catalog.Sku(), + ], next_page_token="abc", ), - cloud_catalog.ListSkusResponse(skus=[], next_page_token="def",), cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(),], next_page_token="ghi", + skus=[], + next_page_token="def", + ), + cloud_catalog.ListSkusResponse( + skus=[ + cloud_catalog.Sku(), + ], + next_page_token="ghi", ), cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(), cloud_catalog.Sku(),], + skus=[ + cloud_catalog.Sku(), + cloud_catalog.Sku(), + ], ), RuntimeError, ) @@ -1094,7 +1226,9 @@ def test_list_skus_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_skus_async_pager(): - client = CloudCatalogAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudCatalogAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1103,19 +1237,34 @@ async def test_list_skus_async_pager(): # Set the response to a series of pages. call.side_effect = ( cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(), cloud_catalog.Sku(), cloud_catalog.Sku(),], + skus=[ + cloud_catalog.Sku(), + cloud_catalog.Sku(), + cloud_catalog.Sku(), + ], next_page_token="abc", ), - cloud_catalog.ListSkusResponse(skus=[], next_page_token="def",), cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(),], next_page_token="ghi", + skus=[], + next_page_token="def", ), cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(), cloud_catalog.Sku(),], + skus=[ + cloud_catalog.Sku(), + ], + next_page_token="ghi", + ), + cloud_catalog.ListSkusResponse( + skus=[ + cloud_catalog.Sku(), + cloud_catalog.Sku(), + ], ), RuntimeError, ) - async_pager = await client.list_skus(request={},) + async_pager = await client.list_skus( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1127,7 +1276,9 @@ async def test_list_skus_async_pager(): @pytest.mark.asyncio async def test_list_skus_async_pages(): - client = CloudCatalogAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudCatalogAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1136,15 +1287,28 @@ async def test_list_skus_async_pages(): # Set the response to a series of pages. call.side_effect = ( cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(), cloud_catalog.Sku(), cloud_catalog.Sku(),], + skus=[ + cloud_catalog.Sku(), + cloud_catalog.Sku(), + cloud_catalog.Sku(), + ], next_page_token="abc", ), - cloud_catalog.ListSkusResponse(skus=[], next_page_token="def",), cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(),], next_page_token="ghi", + skus=[], + next_page_token="def", ), cloud_catalog.ListSkusResponse( - skus=[cloud_catalog.Sku(), cloud_catalog.Sku(),], + skus=[ + cloud_catalog.Sku(), + ], + next_page_token="ghi", + ), + cloud_catalog.ListSkusResponse( + skus=[ + cloud_catalog.Sku(), + cloud_catalog.Sku(), + ], ), RuntimeError, ) @@ -1162,7 +1326,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1182,7 +1347,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = CloudCatalogClient(client_options=options, transport=transport,) + client = CloudCatalogClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1198,7 +1366,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudCatalogClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -1243,8 +1412,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = CloudCatalogClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.CloudCatalogGrpcTransport,) + client = CloudCatalogClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CloudCatalogGrpcTransport, + ) def test_cloud_catalog_base_transport_error(): @@ -1290,7 +1464,8 @@ def test_cloud_catalog_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CloudCatalogTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -1445,7 +1620,8 @@ def test_cloud_catalog_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.CloudCatalogGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1457,7 +1633,8 @@ def test_cloud_catalog_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.CloudCatalogGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -1558,7 +1735,9 @@ def test_cloud_catalog_transport_channel_mtls_with_adc(transport_class): def test_service_path(): service = "squid" - expected = "services/{service}".format(service=service,) + expected = "services/{service}".format( + service=service, + ) actual = CloudCatalogClient.service_path(service) assert expected == actual @@ -1577,7 +1756,10 @@ def test_parse_service_path(): def test_sku_path(): service = "whelk" sku = "octopus" - expected = "services/{service}/skus/{sku}".format(service=service, sku=sku,) + expected = "services/{service}/skus/{sku}".format( + service=service, + sku=sku, + ) actual = CloudCatalogClient.sku_path(service, sku) assert expected == actual @@ -1616,7 +1798,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "winkle" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = CloudCatalogClient.common_folder_path(folder) assert expected == actual @@ -1634,7 +1818,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "scallop" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = CloudCatalogClient.common_organization_path(organization) assert expected == actual @@ -1652,7 +1838,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "squid" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = CloudCatalogClient.common_project_path(project) assert expected == actual @@ -1672,7 +1860,8 @@ def test_common_location_path(): project = "whelk" location = "octopus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = CloudCatalogClient.common_location_path(project, location) assert expected == actual @@ -1697,7 +1886,8 @@ def test_client_with_default_client_info(): transports.CloudCatalogTransport, "_prep_wrapped_messages" ) as prep: client = CloudCatalogClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1706,7 +1896,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = CloudCatalogClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -1714,7 +1905,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = CloudCatalogAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close"