From 362e0fe51364101bd770cce851d986eea6c56e6a Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Wed, 28 Oct 2020 12:18:18 -0700 Subject: [PATCH] feat: add path formatting helper methods autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. --- docs/reservation_v1/types.rst | 1 + .../reservation_service/async_client.py | 100 ++- .../services/reservation_service/client.py | 99 ++- .../reservation_service/transports/grpc.py | 18 +- .../transports/grpc_asyncio.py | 4 + .../reservation_v1/types/reservation.py | 24 +- scripts/fixup_reservation_v1_keywords.py | 1 + synth.metadata | 2 +- .../test_reservation_service.py | 704 ++++++++++++------ 9 files changed, 658 insertions(+), 295 deletions(-) diff --git a/docs/reservation_v1/types.rst b/docs/reservation_v1/types.rst index b89970ad..71b6c38f 100644 --- a/docs/reservation_v1/types.rst +++ b/docs/reservation_v1/types.rst @@ -3,3 +3,4 @@ Types for Google Cloud Bigquery Reservation v1 API .. automodule:: google.cloud.bigquery.reservation_v1.types :members: + :show-inheritance: diff --git a/google/cloud/bigquery/reservation_v1/services/reservation_service/async_client.py b/google/cloud/bigquery/reservation_v1/services/reservation_service/async_client.py index 0d9008c8..60a800b6 100644 --- a/google/cloud/bigquery/reservation_v1/services/reservation_service/async_client.py +++ b/google/cloud/bigquery/reservation_v1/services/reservation_service/async_client.py @@ -82,9 +82,47 @@ class ReservationServiceAsyncClient: ReservationServiceClient.parse_reservation_path ) + common_billing_account_path = staticmethod( + ReservationServiceClient.common_billing_account_path + ) + parse_common_billing_account_path = staticmethod( + ReservationServiceClient.parse_common_billing_account_path + ) + + common_folder_path = staticmethod(ReservationServiceClient.common_folder_path) + parse_common_folder_path = staticmethod( + ReservationServiceClient.parse_common_folder_path + ) + + common_organization_path = staticmethod( + ReservationServiceClient.common_organization_path + ) + parse_common_organization_path = staticmethod( + ReservationServiceClient.parse_common_organization_path + ) + + common_project_path = staticmethod(ReservationServiceClient.common_project_path) + parse_common_project_path = staticmethod( + ReservationServiceClient.parse_common_project_path + ) + + common_location_path = staticmethod(ReservationServiceClient.common_location_path) + parse_common_location_path = staticmethod( + ReservationServiceClient.parse_common_location_path + ) + from_service_account_file = ReservationServiceClient.from_service_account_file from_service_account_json = from_service_account_file + @property + def transport(self) -> ReservationServiceTransport: + """Return the transport used by the client instance. + + Returns: + ReservationServiceTransport: The transport used by the client instance. + """ + return self._client.transport + get_transport_class = functools.partial( type(ReservationServiceClient).get_transport_class, type(ReservationServiceClient), @@ -191,7 +229,8 @@ async def create_reservation( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, reservation, reservation_id]): + has_flattened_params = any([parent, reservation, reservation_id]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -270,7 +309,8 @@ async def list_reservations( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -348,7 +388,8 @@ async def get_reservation( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -416,7 +457,8 @@ async def delete_reservation( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -492,7 +534,8 @@ async def update_reservation( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([reservation, update_mask]): + has_flattened_params = any([reservation, update_mask]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -586,7 +629,8 @@ async def create_capacity_commitment( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, capacity_commitment]): + has_flattened_params = any([parent, capacity_commitment]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -663,7 +707,8 @@ async def list_capacity_commitments( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -753,7 +798,8 @@ async def get_capacity_commitment( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -821,7 +867,8 @@ async def delete_capacity_commitment( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -917,7 +964,8 @@ async def update_capacity_commitment( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([capacity_commitment, update_mask]): + has_flattened_params = any([capacity_commitment, update_mask]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1007,7 +1055,8 @@ async def split_capacity_commitment( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name, slot_count]): + has_flattened_params = any([name, slot_count]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1113,7 +1162,8 @@ async def merge_capacity_commitments( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, capacity_commitment_ids]): + has_flattened_params = any([parent, capacity_commitment_ids]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1126,8 +1176,9 @@ async def merge_capacity_commitments( if parent is not None: request.parent = parent - if capacity_commitment_ids is not None: - request.capacity_commitment_ids = capacity_commitment_ids + + if capacity_commitment_ids: + request.capacity_commitment_ids.extend(capacity_commitment_ids) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1227,7 +1278,8 @@ async def create_assignment( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, assignment]): + has_flattened_params = any([parent, assignment]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1329,7 +1381,8 @@ async def list_assignments( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent]): + has_flattened_params = any([parent]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1417,7 +1470,8 @@ async def delete_assignment( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1530,7 +1584,8 @@ async def search_assignments( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([parent, query]): + has_flattened_params = any([parent, query]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1627,7 +1682,8 @@ async def move_assignment( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name, destination_id]): + has_flattened_params = any([name, destination_id]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1699,7 +1755,8 @@ async def get_bi_reservation( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([name]): + has_flattened_params = any([name]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." @@ -1781,7 +1838,8 @@ async def update_bi_reservation( # Create or coerce a protobuf request object. # Sanity check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. - if request is not None and any([bi_reservation, update_mask]): + has_flattened_params = any([bi_reservation, update_mask]) + if request is not None and has_flattened_params: raise ValueError( "If the `request` argument is set, then none of " "the individual field arguments should be set." diff --git a/google/cloud/bigquery/reservation_v1/services/reservation_service/client.py b/google/cloud/bigquery/reservation_v1/services/reservation_service/client.py index 9e68bb31..c2b0f9bc 100644 --- a/google/cloud/bigquery/reservation_v1/services/reservation_service/client.py +++ b/google/cloud/bigquery/reservation_v1/services/reservation_service/client.py @@ -19,10 +19,10 @@ from distutils import util import os import re -from typing import Callable, Dict, Sequence, Tuple, Type, Union +from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -import google.api_core.client_options as ClientOptions # type: ignore +from google.api_core import client_options as client_options_lib # type: ignore from google.api_core import exceptions # type: ignore from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore @@ -153,6 +153,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @property + def transport(self) -> ReservationServiceTransport: + """Return the transport used by the client instance. + + Returns: + ReservationServiceTransport: The transport used by the client instance. + """ + return self._transport + @staticmethod def assignment_path( project: str, location: str, reservation: str, assignment: str, @@ -224,12 +233,71 @@ def parse_reservation_path(path: str) -> Dict[str, str]: ) return m.groupdict() if m else {} + @staticmethod + def common_billing_account_path(billing_account: str,) -> str: + """Return a fully-qualified billing_account string.""" + return "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + + @staticmethod + def parse_common_billing_account_path(path: str) -> Dict[str, str]: + """Parse a billing_account path into its component segments.""" + m = re.match(r"^billingAccounts/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_folder_path(folder: str,) -> str: + """Return a fully-qualified folder string.""" + return "folders/{folder}".format(folder=folder,) + + @staticmethod + def parse_common_folder_path(path: str) -> Dict[str, str]: + """Parse a folder path into its component segments.""" + m = re.match(r"^folders/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_organization_path(organization: str,) -> str: + """Return a fully-qualified organization string.""" + return "organizations/{organization}".format(organization=organization,) + + @staticmethod + def parse_common_organization_path(path: str) -> Dict[str, str]: + """Parse a organization path into its component segments.""" + m = re.match(r"^organizations/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_project_path(project: str,) -> str: + """Return a fully-qualified project string.""" + return "projects/{project}".format(project=project,) + + @staticmethod + def parse_common_project_path(path: str) -> Dict[str, str]: + """Parse a project path into its component segments.""" + m = re.match(r"^projects/(?P.+?)$", path) + return m.groupdict() if m else {} + + @staticmethod + def common_location_path(project: str, location: str,) -> str: + """Return a fully-qualified location string.""" + return "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + + @staticmethod + def parse_common_location_path(path: str) -> Dict[str, str]: + """Parse a location path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) + return m.groupdict() if m else {} + def __init__( self, *, - credentials: credentials.Credentials = None, - transport: Union[str, ReservationServiceTransport] = None, - client_options: ClientOptions = None, + credentials: Optional[credentials.Credentials] = None, + transport: Union[str, ReservationServiceTransport, None] = None, + client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: """Instantiate the reservation service client. @@ -243,8 +311,8 @@ def __init__( transport (Union[str, ~.ReservationServiceTransport]): The transport to use. If set to None, a transport is chosen automatically. - client_options (ClientOptions): Custom options for the client. It - won't take effect if a ``transport`` instance is provided. + client_options (client_options_lib.ClientOptions): Custom options for the + client. It won't take effect if a ``transport`` instance is provided. (1) The ``api_endpoint`` property can be used to override the default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT environment variable can also be used to override the endpoint: @@ -259,10 +327,10 @@ def __init__( not provided, the default SSL client certificate will be used if present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not set, no client certificate will be used. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. Raises: @@ -270,9 +338,9 @@ def __init__( creation failed for any reason. """ if isinstance(client_options, dict): - client_options = ClientOptions.from_dict(client_options) + client_options = client_options_lib.from_dict(client_options) if client_options is None: - client_options = ClientOptions.ClientOptions() + client_options = client_options_lib.ClientOptions() # Create SSL credentials for mutual TLS if needed. use_client_cert = bool( @@ -1367,8 +1435,9 @@ def merge_capacity_commitments( if parent is not None: request.parent = parent - if capacity_commitment_ids is not None: - request.capacity_commitment_ids = capacity_commitment_ids + + if capacity_commitment_ids: + request.capacity_commitment_ids.extend(capacity_commitment_ids) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. diff --git a/google/cloud/bigquery/reservation_v1/services/reservation_service/transports/grpc.py b/google/cloud/bigquery/reservation_v1/services/reservation_service/transports/grpc.py index bb379e09..266aab8c 100644 --- a/google/cloud/bigquery/reservation_v1/services/reservation_service/transports/grpc.py +++ b/google/cloud/bigquery/reservation_v1/services/reservation_service/transports/grpc.py @@ -107,10 +107,10 @@ def __init__( for grpc channel. It is ignored if ``channel`` is provided. quota_project_id (Optional[str]): An optional project to use for billing and quota. - client_info (google.api_core.gapic_v1.client_info.ClientInfo): - The client info used to send a user-agent string along with - API requests. If ``None``, then default info will be used. - Generally, you only need to set this if you're developing + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing your own client library. Raises: @@ -119,6 +119,8 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._ssl_channel_credentials = ssl_channel_credentials + if channel: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -126,6 +128,7 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel + self._ssl_channel_credentials = None elif api_mtls_endpoint: warnings.warn( "api_mtls_endpoint and client_cert_source are deprecated", @@ -162,6 +165,7 @@ def __init__( scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" @@ -239,12 +243,8 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Create the channel designed to connect to this service. - - This property caches on the instance; repeated calls return - the same channel. + """Return the channel designed to connect to this service. """ - # Return the channel from cache. return self._grpc_channel @property diff --git a/google/cloud/bigquery/reservation_v1/services/reservation_service/transports/grpc_asyncio.py b/google/cloud/bigquery/reservation_v1/services/reservation_service/transports/grpc_asyncio.py index d287954b..9ea590aa 100644 --- a/google/cloud/bigquery/reservation_v1/services/reservation_service/transports/grpc_asyncio.py +++ b/google/cloud/bigquery/reservation_v1/services/reservation_service/transports/grpc_asyncio.py @@ -164,6 +164,8 @@ def __init__( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ + self._ssl_channel_credentials = ssl_channel_credentials + if channel: # Sanity check: Ensure that channel and credentials are not both # provided. @@ -171,6 +173,7 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel + self._ssl_channel_credentials = None elif api_mtls_endpoint: warnings.warn( "api_mtls_endpoint and client_cert_source are deprecated", @@ -207,6 +210,7 @@ def __init__( scopes=scopes or self.AUTH_SCOPES, quota_project_id=quota_project_id, ) + self._ssl_channel_credentials = ssl_credentials else: host = host if ":" in host else host + ":443" diff --git a/google/cloud/bigquery/reservation_v1/types/reservation.py b/google/cloud/bigquery/reservation_v1/types/reservation.py index 5a7fbdbe..f743aab4 100644 --- a/google/cloud/bigquery/reservation_v1/types/reservation.py +++ b/google/cloud/bigquery/reservation_v1/types/reservation.py @@ -188,7 +188,7 @@ class CreateReservationRequest(proto.Message): reservation_id = proto.Field(proto.STRING, number=2) - reservation = proto.Field(proto.MESSAGE, number=3, message=Reservation,) + reservation = proto.Field(proto.MESSAGE, number=3, message="Reservation",) class ListReservationsRequest(proto.Message): @@ -231,7 +231,7 @@ class ListReservationsResponse(proto.Message): def raw_page(self): return self - reservations = proto.RepeatedField(proto.MESSAGE, number=1, message=Reservation,) + reservations = proto.RepeatedField(proto.MESSAGE, number=1, message="Reservation",) next_page_token = proto.Field(proto.STRING, number=2) @@ -276,7 +276,7 @@ class UpdateReservationRequest(proto.Message): be updated. """ - reservation = proto.Field(proto.MESSAGE, number=1, message=Reservation,) + reservation = proto.Field(proto.MESSAGE, number=1, message="Reservation",) update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) @@ -299,7 +299,7 @@ class CreateCapacityCommitmentRequest(proto.Message): parent = proto.Field(proto.STRING, number=1) capacity_commitment = proto.Field( - proto.MESSAGE, number=2, message=CapacityCommitment, + proto.MESSAGE, number=2, message="CapacityCommitment", ) enforce_single_admin_project_per_org = proto.Field(proto.BOOL, number=4) @@ -346,7 +346,7 @@ def raw_page(self): return self capacity_commitments = proto.RepeatedField( - proto.MESSAGE, number=1, message=CapacityCommitment, + proto.MESSAGE, number=1, message="CapacityCommitment", ) next_page_token = proto.Field(proto.STRING, number=2) @@ -393,7 +393,7 @@ class UpdateCapacityCommitmentRequest(proto.Message): """ capacity_commitment = proto.Field( - proto.MESSAGE, number=1, message=CapacityCommitment, + proto.MESSAGE, number=1, message="CapacityCommitment", ) update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) @@ -429,9 +429,9 @@ class SplitCapacityCommitmentResponse(proto.Message): split. """ - first = proto.Field(proto.MESSAGE, number=1, message=CapacityCommitment,) + first = proto.Field(proto.MESSAGE, number=1, message="CapacityCommitment",) - second = proto.Field(proto.MESSAGE, number=2, message=CapacityCommitment,) + second = proto.Field(proto.MESSAGE, number=2, message="CapacityCommitment",) class MergeCapacityCommitmentsRequest(proto.Message): @@ -517,7 +517,7 @@ class CreateAssignmentRequest(proto.Message): parent = proto.Field(proto.STRING, number=1) - assignment = proto.Field(proto.MESSAGE, number=2, message=Assignment,) + assignment = proto.Field(proto.MESSAGE, number=2, message="Assignment",) class ListAssignmentsRequest(proto.Message): @@ -565,7 +565,7 @@ class ListAssignmentsResponse(proto.Message): def raw_page(self): return self - assignments = proto.RepeatedField(proto.MESSAGE, number=1, message=Assignment,) + assignments = proto.RepeatedField(proto.MESSAGE, number=1, message="Assignment",) next_page_token = proto.Field(proto.STRING, number=2) @@ -638,7 +638,7 @@ class SearchAssignmentsResponse(proto.Message): def raw_page(self): return self - assignments = proto.RepeatedField(proto.MESSAGE, number=1, message=Assignment,) + assignments = proto.RepeatedField(proto.MESSAGE, number=1, message="Assignment",) next_page_token = proto.Field(proto.STRING, number=2) @@ -713,7 +713,7 @@ class UpdateBiReservationRequest(proto.Message): request. """ - bi_reservation = proto.Field(proto.MESSAGE, number=1, message=BiReservation,) + bi_reservation = proto.Field(proto.MESSAGE, number=1, message="BiReservation",) update_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask.FieldMask,) diff --git a/scripts/fixup_reservation_v1_keywords.py b/scripts/fixup_reservation_v1_keywords.py index 598edc38..bc9c8f00 100644 --- a/scripts/fixup_reservation_v1_keywords.py +++ b/scripts/fixup_reservation_v1_keywords.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright 2020 Google LLC diff --git a/synth.metadata b/synth.metadata index e9d2b8c6..f9298ddc 100644 --- a/synth.metadata +++ b/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/python-bigquery-reservation.git", - "sha": "660abdcc27a9c584d9a771dbf80bcc53fb0a5797" + "sha": "21bff87047519754a01983c9a4551cb534bcb88c" } }, { diff --git a/tests/unit/gapic/reservation_v1/test_reservation_service.py b/tests/unit/gapic/reservation_v1/test_reservation_service.py index 68e6964d..466b0281 100644 --- a/tests/unit/gapic/reservation_v1/test_reservation_service.py +++ b/tests/unit/gapic/reservation_v1/test_reservation_service.py @@ -43,7 +43,7 @@ from google.cloud.bigquery.reservation_v1.types import reservation from google.cloud.bigquery.reservation_v1.types import reservation as gcbr_reservation from google.oauth2 import service_account -from google.protobuf import any_pb2 as any # type: ignore +from google.protobuf import any_pb2 as gp_any # type: ignore from google.protobuf import field_mask_pb2 as field_mask # type: ignore from google.protobuf import timestamp_pb2 as timestamp # type: ignore from google.rpc import status_pb2 as status # type: ignore @@ -104,12 +104,12 @@ def test_reservation_service_client_from_service_account_file(client_class): ) as factory: factory.return_value = creds client = client_class.from_service_account_file("dummy/file/path.json") - assert client._transport._credentials == creds + assert client.transport._credentials == creds client = client_class.from_service_account_json("dummy/file/path.json") - assert client._transport._credentials == creds + assert client.transport._credentials == creds - assert client._transport._host == "bigqueryreservation.googleapis.com:443" + assert client.transport._host == "bigqueryreservation.googleapis.com:443" def test_reservation_service_client_get_transport_class(): @@ -470,7 +470,7 @@ def test_create_reservation( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_reservation), "__call__" + type(client.transport.create_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gcbr_reservation.Reservation( @@ -486,6 +486,7 @@ def test_create_reservation( assert args[0] == gcbr_reservation.CreateReservationRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gcbr_reservation.Reservation) assert response.name == "name_value" @@ -500,18 +501,21 @@ def test_create_reservation_from_dict(): @pytest.mark.asyncio -async def test_create_reservation_async(transport: str = "grpc_asyncio"): +async def test_create_reservation_async( + transport: str = "grpc_asyncio", + request_type=gcbr_reservation.CreateReservationRequest, +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = gcbr_reservation.CreateReservationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_reservation), "__call__" + type(client.transport.create_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -526,7 +530,7 @@ async def test_create_reservation_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == gcbr_reservation.CreateReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, gcbr_reservation.Reservation) @@ -538,6 +542,11 @@ async def test_create_reservation_async(transport: str = "grpc_asyncio"): assert response.ignore_idle_slots is True +@pytest.mark.asyncio +async def test_create_reservation_async_from_dict(): + await test_create_reservation_async(request_type=dict) + + def test_create_reservation_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -548,7 +557,7 @@ def test_create_reservation_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_reservation), "__call__" + type(client.transport.create_reservation), "__call__" ) as call: call.return_value = gcbr_reservation.Reservation() @@ -577,7 +586,7 @@ async def test_create_reservation_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_reservation), "__call__" + type(client.transport.create_reservation), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gcbr_reservation.Reservation() @@ -600,7 +609,7 @@ def test_create_reservation_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_reservation), "__call__" + type(client.transport.create_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gcbr_reservation.Reservation() @@ -647,7 +656,7 @@ async def test_create_reservation_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_reservation), "__call__" + type(client.transport.create_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gcbr_reservation.Reservation() @@ -705,7 +714,7 @@ def test_list_reservations( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_reservations), "__call__" + type(client.transport.list_reservations), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListReservationsResponse( @@ -721,6 +730,7 @@ def test_list_reservations( assert args[0] == reservation.ListReservationsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListReservationsPager) assert response.next_page_token == "next_page_token_value" @@ -731,18 +741,20 @@ def test_list_reservations_from_dict(): @pytest.mark.asyncio -async def test_list_reservations_async(transport: str = "grpc_asyncio"): +async def test_list_reservations_async( + transport: str = "grpc_asyncio", request_type=reservation.ListReservationsRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.ListReservationsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_reservations), "__call__" + type(client.transport.list_reservations), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -757,7 +769,7 @@ async def test_list_reservations_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.ListReservationsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListReservationsAsyncPager) @@ -765,6 +777,11 @@ async def test_list_reservations_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_reservations_async_from_dict(): + await test_list_reservations_async(request_type=dict) + + def test_list_reservations_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -775,7 +792,7 @@ def test_list_reservations_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_reservations), "__call__" + type(client.transport.list_reservations), "__call__" ) as call: call.return_value = reservation.ListReservationsResponse() @@ -804,7 +821,7 @@ async def test_list_reservations_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_reservations), "__call__" + type(client.transport.list_reservations), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.ListReservationsResponse() @@ -827,7 +844,7 @@ def test_list_reservations_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_reservations), "__call__" + type(client.transport.list_reservations), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListReservationsResponse() @@ -863,7 +880,7 @@ async def test_list_reservations_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_reservations), "__call__" + type(client.transport.list_reservations), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListReservationsResponse() @@ -902,7 +919,7 @@ def test_list_reservations_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_reservations), "__call__" + type(client.transport.list_reservations), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -944,7 +961,7 @@ def test_list_reservations_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_reservations), "__call__" + type(client.transport.list_reservations), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -980,7 +997,7 @@ async def test_list_reservations_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_reservations), + type(client.transport.list_reservations), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -1023,7 +1040,7 @@ async def test_list_reservations_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_reservations), + type(client.transport.list_reservations), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -1067,7 +1084,7 @@ def test_get_reservation( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_reservation), "__call__") as call: + with mock.patch.object(type(client.transport.get_reservation), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.Reservation( name="name_value", slot_capacity=1391, ignore_idle_slots=True, @@ -1082,6 +1099,7 @@ def test_get_reservation( assert args[0] == reservation.GetReservationRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.Reservation) assert response.name == "name_value" @@ -1096,19 +1114,19 @@ def test_get_reservation_from_dict(): @pytest.mark.asyncio -async def test_get_reservation_async(transport: str = "grpc_asyncio"): +async def test_get_reservation_async( + transport: str = "grpc_asyncio", request_type=reservation.GetReservationRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.GetReservationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_reservation), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_reservation), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.Reservation( @@ -1122,7 +1140,7 @@ async def test_get_reservation_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.GetReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.Reservation) @@ -1134,6 +1152,11 @@ async def test_get_reservation_async(transport: str = "grpc_asyncio"): assert response.ignore_idle_slots is True +@pytest.mark.asyncio +async def test_get_reservation_async_from_dict(): + await test_get_reservation_async(request_type=dict) + + def test_get_reservation_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1143,7 +1166,7 @@ def test_get_reservation_field_headers(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_reservation), "__call__") as call: + with mock.patch.object(type(client.transport.get_reservation), "__call__") as call: call.return_value = reservation.Reservation() client.get_reservation(request) @@ -1170,9 +1193,7 @@ async def test_get_reservation_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_reservation), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_reservation), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.Reservation() ) @@ -1193,7 +1214,7 @@ def test_get_reservation_flattened(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.get_reservation), "__call__") as call: + with mock.patch.object(type(client.transport.get_reservation), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.Reservation() @@ -1227,9 +1248,7 @@ async def test_get_reservation_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.get_reservation), "__call__" - ) as call: + with mock.patch.object(type(client.transport.get_reservation), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.Reservation() @@ -1275,7 +1294,7 @@ def test_delete_reservation( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_reservation), "__call__" + type(client.transport.delete_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1297,18 +1316,20 @@ def test_delete_reservation_from_dict(): @pytest.mark.asyncio -async def test_delete_reservation_async(transport: str = "grpc_asyncio"): +async def test_delete_reservation_async( + transport: str = "grpc_asyncio", request_type=reservation.DeleteReservationRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.DeleteReservationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_reservation), "__call__" + type(client.transport.delete_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1319,12 +1340,17 @@ async def test_delete_reservation_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.DeleteReservationRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_reservation_async_from_dict(): + await test_delete_reservation_async(request_type=dict) + + def test_delete_reservation_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1335,7 +1361,7 @@ def test_delete_reservation_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_reservation), "__call__" + type(client.transport.delete_reservation), "__call__" ) as call: call.return_value = None @@ -1364,7 +1390,7 @@ async def test_delete_reservation_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_reservation), "__call__" + type(client.transport.delete_reservation), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -1385,7 +1411,7 @@ def test_delete_reservation_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_reservation), "__call__" + type(client.transport.delete_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1421,7 +1447,7 @@ async def test_delete_reservation_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_reservation), "__call__" + type(client.transport.delete_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -1466,7 +1492,7 @@ def test_update_reservation( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_reservation), "__call__" + type(client.transport.update_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gcbr_reservation.Reservation( @@ -1482,6 +1508,7 @@ def test_update_reservation( assert args[0] == gcbr_reservation.UpdateReservationRequest() # Establish that the response is the type that we expect. + assert isinstance(response, gcbr_reservation.Reservation) assert response.name == "name_value" @@ -1496,18 +1523,21 @@ def test_update_reservation_from_dict(): @pytest.mark.asyncio -async def test_update_reservation_async(transport: str = "grpc_asyncio"): +async def test_update_reservation_async( + transport: str = "grpc_asyncio", + request_type=gcbr_reservation.UpdateReservationRequest, +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = gcbr_reservation.UpdateReservationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_reservation), "__call__" + type(client.transport.update_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1522,7 +1552,7 @@ async def test_update_reservation_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == gcbr_reservation.UpdateReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, gcbr_reservation.Reservation) @@ -1534,6 +1564,11 @@ async def test_update_reservation_async(transport: str = "grpc_asyncio"): assert response.ignore_idle_slots is True +@pytest.mark.asyncio +async def test_update_reservation_async_from_dict(): + await test_update_reservation_async(request_type=dict) + + def test_update_reservation_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1544,7 +1579,7 @@ def test_update_reservation_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_reservation), "__call__" + type(client.transport.update_reservation), "__call__" ) as call: call.return_value = gcbr_reservation.Reservation() @@ -1575,7 +1610,7 @@ async def test_update_reservation_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_reservation), "__call__" + type(client.transport.update_reservation), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( gcbr_reservation.Reservation() @@ -1600,7 +1635,7 @@ def test_update_reservation_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_reservation), "__call__" + type(client.transport.update_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gcbr_reservation.Reservation() @@ -1643,7 +1678,7 @@ async def test_update_reservation_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_reservation), "__call__" + type(client.transport.update_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = gcbr_reservation.Reservation() @@ -1697,7 +1732,7 @@ def test_create_capacity_commitment( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_capacity_commitment), "__call__" + type(client.transport.create_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment( @@ -1717,6 +1752,7 @@ def test_create_capacity_commitment( assert args[0] == reservation.CreateCapacityCommitmentRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.CapacityCommitment) assert response.name == "name_value" @@ -1735,18 +1771,21 @@ def test_create_capacity_commitment_from_dict(): @pytest.mark.asyncio -async def test_create_capacity_commitment_async(transport: str = "grpc_asyncio"): +async def test_create_capacity_commitment_async( + transport: str = "grpc_asyncio", + request_type=reservation.CreateCapacityCommitmentRequest, +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.CreateCapacityCommitmentRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_capacity_commitment), "__call__" + type(client.transport.create_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1765,7 +1804,7 @@ async def test_create_capacity_commitment_async(transport: str = "grpc_asyncio") assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.CreateCapacityCommitmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.CapacityCommitment) @@ -1781,6 +1820,11 @@ async def test_create_capacity_commitment_async(transport: str = "grpc_asyncio") assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX +@pytest.mark.asyncio +async def test_create_capacity_commitment_async_from_dict(): + await test_create_capacity_commitment_async(request_type=dict) + + def test_create_capacity_commitment_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -1791,7 +1835,7 @@ def test_create_capacity_commitment_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_capacity_commitment), "__call__" + type(client.transport.create_capacity_commitment), "__call__" ) as call: call.return_value = reservation.CapacityCommitment() @@ -1820,7 +1864,7 @@ async def test_create_capacity_commitment_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_capacity_commitment), "__call__" + type(client.transport.create_capacity_commitment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.CapacityCommitment() @@ -1843,7 +1887,7 @@ def test_create_capacity_commitment_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_capacity_commitment), "__call__" + type(client.transport.create_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() @@ -1888,7 +1932,7 @@ async def test_create_capacity_commitment_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_capacity_commitment), "__call__" + type(client.transport.create_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() @@ -1944,7 +1988,7 @@ def test_list_capacity_commitments( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_capacity_commitments), "__call__" + type(client.transport.list_capacity_commitments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListCapacityCommitmentsResponse( @@ -1960,6 +2004,7 @@ def test_list_capacity_commitments( assert args[0] == reservation.ListCapacityCommitmentsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListCapacityCommitmentsPager) assert response.next_page_token == "next_page_token_value" @@ -1970,18 +2015,21 @@ def test_list_capacity_commitments_from_dict(): @pytest.mark.asyncio -async def test_list_capacity_commitments_async(transport: str = "grpc_asyncio"): +async def test_list_capacity_commitments_async( + transport: str = "grpc_asyncio", + request_type=reservation.ListCapacityCommitmentsRequest, +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.ListCapacityCommitmentsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_capacity_commitments), "__call__" + type(client.transport.list_capacity_commitments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -1996,7 +2044,7 @@ async def test_list_capacity_commitments_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.ListCapacityCommitmentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListCapacityCommitmentsAsyncPager) @@ -2004,6 +2052,11 @@ async def test_list_capacity_commitments_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_capacity_commitments_async_from_dict(): + await test_list_capacity_commitments_async(request_type=dict) + + def test_list_capacity_commitments_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2014,7 +2067,7 @@ def test_list_capacity_commitments_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_capacity_commitments), "__call__" + type(client.transport.list_capacity_commitments), "__call__" ) as call: call.return_value = reservation.ListCapacityCommitmentsResponse() @@ -2043,7 +2096,7 @@ async def test_list_capacity_commitments_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_capacity_commitments), "__call__" + type(client.transport.list_capacity_commitments), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.ListCapacityCommitmentsResponse() @@ -2066,7 +2119,7 @@ def test_list_capacity_commitments_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_capacity_commitments), "__call__" + type(client.transport.list_capacity_commitments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListCapacityCommitmentsResponse() @@ -2102,7 +2155,7 @@ async def test_list_capacity_commitments_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_capacity_commitments), "__call__" + type(client.transport.list_capacity_commitments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListCapacityCommitmentsResponse() @@ -2141,7 +2194,7 @@ def test_list_capacity_commitments_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_capacity_commitments), "__call__" + type(client.transport.list_capacity_commitments), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2187,7 +2240,7 @@ def test_list_capacity_commitments_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.list_capacity_commitments), "__call__" + type(client.transport.list_capacity_commitments), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -2227,7 +2280,7 @@ async def test_list_capacity_commitments_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_capacity_commitments), + type(client.transport.list_capacity_commitments), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -2274,7 +2327,7 @@ async def test_list_capacity_commitments_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_capacity_commitments), + type(client.transport.list_capacity_commitments), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -2323,7 +2376,7 @@ def test_get_capacity_commitment( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_capacity_commitment), "__call__" + type(client.transport.get_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment( @@ -2343,6 +2396,7 @@ def test_get_capacity_commitment( assert args[0] == reservation.GetCapacityCommitmentRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.CapacityCommitment) assert response.name == "name_value" @@ -2361,18 +2415,21 @@ def test_get_capacity_commitment_from_dict(): @pytest.mark.asyncio -async def test_get_capacity_commitment_async(transport: str = "grpc_asyncio"): +async def test_get_capacity_commitment_async( + transport: str = "grpc_asyncio", + request_type=reservation.GetCapacityCommitmentRequest, +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.GetCapacityCommitmentRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_capacity_commitment), "__call__" + type(client.transport.get_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2391,7 +2448,7 @@ async def test_get_capacity_commitment_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.GetCapacityCommitmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.CapacityCommitment) @@ -2407,6 +2464,11 @@ async def test_get_capacity_commitment_async(transport: str = "grpc_asyncio"): assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX +@pytest.mark.asyncio +async def test_get_capacity_commitment_async_from_dict(): + await test_get_capacity_commitment_async(request_type=dict) + + def test_get_capacity_commitment_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2417,7 +2479,7 @@ def test_get_capacity_commitment_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_capacity_commitment), "__call__" + type(client.transport.get_capacity_commitment), "__call__" ) as call: call.return_value = reservation.CapacityCommitment() @@ -2446,7 +2508,7 @@ async def test_get_capacity_commitment_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_capacity_commitment), "__call__" + type(client.transport.get_capacity_commitment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.CapacityCommitment() @@ -2469,7 +2531,7 @@ def test_get_capacity_commitment_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_capacity_commitment), "__call__" + type(client.transport.get_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() @@ -2505,7 +2567,7 @@ async def test_get_capacity_commitment_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_capacity_commitment), "__call__" + type(client.transport.get_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() @@ -2552,7 +2614,7 @@ def test_delete_capacity_commitment( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_capacity_commitment), "__call__" + type(client.transport.delete_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -2574,18 +2636,21 @@ def test_delete_capacity_commitment_from_dict(): @pytest.mark.asyncio -async def test_delete_capacity_commitment_async(transport: str = "grpc_asyncio"): +async def test_delete_capacity_commitment_async( + transport: str = "grpc_asyncio", + request_type=reservation.DeleteCapacityCommitmentRequest, +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.DeleteCapacityCommitmentRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_capacity_commitment), "__call__" + type(client.transport.delete_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -2596,12 +2661,17 @@ async def test_delete_capacity_commitment_async(transport: str = "grpc_asyncio") assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.DeleteCapacityCommitmentRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_capacity_commitment_async_from_dict(): + await test_delete_capacity_commitment_async(request_type=dict) + + def test_delete_capacity_commitment_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2612,7 +2682,7 @@ def test_delete_capacity_commitment_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_capacity_commitment), "__call__" + type(client.transport.delete_capacity_commitment), "__call__" ) as call: call.return_value = None @@ -2641,7 +2711,7 @@ async def test_delete_capacity_commitment_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_capacity_commitment), "__call__" + type(client.transport.delete_capacity_commitment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -2662,7 +2732,7 @@ def test_delete_capacity_commitment_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_capacity_commitment), "__call__" + type(client.transport.delete_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -2698,7 +2768,7 @@ async def test_delete_capacity_commitment_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_capacity_commitment), "__call__" + type(client.transport.delete_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -2743,7 +2813,7 @@ def test_update_capacity_commitment( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_capacity_commitment), "__call__" + type(client.transport.update_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment( @@ -2763,6 +2833,7 @@ def test_update_capacity_commitment( assert args[0] == reservation.UpdateCapacityCommitmentRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.CapacityCommitment) assert response.name == "name_value" @@ -2781,18 +2852,21 @@ def test_update_capacity_commitment_from_dict(): @pytest.mark.asyncio -async def test_update_capacity_commitment_async(transport: str = "grpc_asyncio"): +async def test_update_capacity_commitment_async( + transport: str = "grpc_asyncio", + request_type=reservation.UpdateCapacityCommitmentRequest, +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.UpdateCapacityCommitmentRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_capacity_commitment), "__call__" + type(client.transport.update_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -2811,7 +2885,7 @@ async def test_update_capacity_commitment_async(transport: str = "grpc_asyncio") assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.UpdateCapacityCommitmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.CapacityCommitment) @@ -2827,6 +2901,11 @@ async def test_update_capacity_commitment_async(transport: str = "grpc_asyncio") assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX +@pytest.mark.asyncio +async def test_update_capacity_commitment_async_from_dict(): + await test_update_capacity_commitment_async(request_type=dict) + + def test_update_capacity_commitment_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -2837,7 +2916,7 @@ def test_update_capacity_commitment_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_capacity_commitment), "__call__" + type(client.transport.update_capacity_commitment), "__call__" ) as call: call.return_value = reservation.CapacityCommitment() @@ -2869,7 +2948,7 @@ async def test_update_capacity_commitment_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_capacity_commitment), "__call__" + type(client.transport.update_capacity_commitment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.CapacityCommitment() @@ -2895,7 +2974,7 @@ def test_update_capacity_commitment_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_capacity_commitment), "__call__" + type(client.transport.update_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() @@ -2940,7 +3019,7 @@ async def test_update_capacity_commitment_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_capacity_commitment), "__call__" + type(client.transport.update_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() @@ -2996,7 +3075,7 @@ def test_split_capacity_commitment( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.split_capacity_commitment), "__call__" + type(client.transport.split_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.SplitCapacityCommitmentResponse() @@ -3010,6 +3089,7 @@ def test_split_capacity_commitment( assert args[0] == reservation.SplitCapacityCommitmentRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.SplitCapacityCommitmentResponse) @@ -3018,18 +3098,21 @@ def test_split_capacity_commitment_from_dict(): @pytest.mark.asyncio -async def test_split_capacity_commitment_async(transport: str = "grpc_asyncio"): +async def test_split_capacity_commitment_async( + transport: str = "grpc_asyncio", + request_type=reservation.SplitCapacityCommitmentRequest, +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.SplitCapacityCommitmentRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.split_capacity_commitment), "__call__" + type(client.transport.split_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -3042,12 +3125,17 @@ async def test_split_capacity_commitment_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.SplitCapacityCommitmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.SplitCapacityCommitmentResponse) +@pytest.mark.asyncio +async def test_split_capacity_commitment_async_from_dict(): + await test_split_capacity_commitment_async(request_type=dict) + + def test_split_capacity_commitment_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3058,7 +3146,7 @@ def test_split_capacity_commitment_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.split_capacity_commitment), "__call__" + type(client.transport.split_capacity_commitment), "__call__" ) as call: call.return_value = reservation.SplitCapacityCommitmentResponse() @@ -3087,7 +3175,7 @@ async def test_split_capacity_commitment_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.split_capacity_commitment), "__call__" + type(client.transport.split_capacity_commitment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.SplitCapacityCommitmentResponse() @@ -3110,7 +3198,7 @@ def test_split_capacity_commitment_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.split_capacity_commitment), "__call__" + type(client.transport.split_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.SplitCapacityCommitmentResponse() @@ -3152,7 +3240,7 @@ async def test_split_capacity_commitment_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.split_capacity_commitment), "__call__" + type(client.transport.split_capacity_commitment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.SplitCapacityCommitmentResponse() @@ -3205,7 +3293,7 @@ def test_merge_capacity_commitments( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.merge_capacity_commitments), "__call__" + type(client.transport.merge_capacity_commitments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment( @@ -3225,6 +3313,7 @@ def test_merge_capacity_commitments( assert args[0] == reservation.MergeCapacityCommitmentsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.CapacityCommitment) assert response.name == "name_value" @@ -3243,18 +3332,21 @@ def test_merge_capacity_commitments_from_dict(): @pytest.mark.asyncio -async def test_merge_capacity_commitments_async(transport: str = "grpc_asyncio"): +async def test_merge_capacity_commitments_async( + transport: str = "grpc_asyncio", + request_type=reservation.MergeCapacityCommitmentsRequest, +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.MergeCapacityCommitmentsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.merge_capacity_commitments), "__call__" + type(client.transport.merge_capacity_commitments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -3273,7 +3365,7 @@ async def test_merge_capacity_commitments_async(transport: str = "grpc_asyncio") assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.MergeCapacityCommitmentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.CapacityCommitment) @@ -3289,6 +3381,11 @@ async def test_merge_capacity_commitments_async(transport: str = "grpc_asyncio") assert response.renewal_plan == reservation.CapacityCommitment.CommitmentPlan.FLEX +@pytest.mark.asyncio +async def test_merge_capacity_commitments_async_from_dict(): + await test_merge_capacity_commitments_async(request_type=dict) + + def test_merge_capacity_commitments_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3299,7 +3396,7 @@ def test_merge_capacity_commitments_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.merge_capacity_commitments), "__call__" + type(client.transport.merge_capacity_commitments), "__call__" ) as call: call.return_value = reservation.CapacityCommitment() @@ -3328,7 +3425,7 @@ async def test_merge_capacity_commitments_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.merge_capacity_commitments), "__call__" + type(client.transport.merge_capacity_commitments), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.CapacityCommitment() @@ -3351,7 +3448,7 @@ def test_merge_capacity_commitments_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.merge_capacity_commitments), "__call__" + type(client.transport.merge_capacity_commitments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() @@ -3394,7 +3491,7 @@ async def test_merge_capacity_commitments_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.merge_capacity_commitments), "__call__" + type(client.transport.merge_capacity_commitments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.CapacityCommitment() @@ -3448,7 +3545,7 @@ def test_create_assignment( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_assignment), "__call__" + type(client.transport.create_assignment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.Assignment( @@ -3467,6 +3564,7 @@ def test_create_assignment( assert args[0] == reservation.CreateAssignmentRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.Assignment) assert response.name == "name_value" @@ -3483,18 +3581,20 @@ def test_create_assignment_from_dict(): @pytest.mark.asyncio -async def test_create_assignment_async(transport: str = "grpc_asyncio"): +async def test_create_assignment_async( + transport: str = "grpc_asyncio", request_type=reservation.CreateAssignmentRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.CreateAssignmentRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_assignment), "__call__" + type(client.transport.create_assignment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -3512,7 +3612,7 @@ async def test_create_assignment_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.CreateAssignmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.Assignment) @@ -3526,6 +3626,11 @@ async def test_create_assignment_async(transport: str = "grpc_asyncio"): assert response.state == reservation.Assignment.State.PENDING +@pytest.mark.asyncio +async def test_create_assignment_async_from_dict(): + await test_create_assignment_async(request_type=dict) + + def test_create_assignment_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3536,7 +3641,7 @@ def test_create_assignment_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_assignment), "__call__" + type(client.transport.create_assignment), "__call__" ) as call: call.return_value = reservation.Assignment() @@ -3565,7 +3670,7 @@ async def test_create_assignment_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_assignment), "__call__" + type(client.transport.create_assignment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.Assignment() @@ -3588,7 +3693,7 @@ def test_create_assignment_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.create_assignment), "__call__" + type(client.transport.create_assignment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.Assignment() @@ -3630,7 +3735,7 @@ async def test_create_assignment_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.create_assignment), "__call__" + type(client.transport.create_assignment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.Assignment() @@ -3682,9 +3787,7 @@ def test_list_assignments( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._transport.list_assignments), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListAssignmentsResponse( next_page_token="next_page_token_value", @@ -3699,6 +3802,7 @@ def test_list_assignments( assert args[0] == reservation.ListAssignmentsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.ListAssignmentsPager) assert response.next_page_token == "next_page_token_value" @@ -3709,19 +3813,19 @@ def test_list_assignments_from_dict(): @pytest.mark.asyncio -async def test_list_assignments_async(transport: str = "grpc_asyncio"): +async def test_list_assignments_async( + transport: str = "grpc_asyncio", request_type=reservation.ListAssignmentsRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.ListAssignmentsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_assignments), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.ListAssignmentsResponse( @@ -3735,7 +3839,7 @@ async def test_list_assignments_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.ListAssignmentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListAssignmentsAsyncPager) @@ -3743,6 +3847,11 @@ async def test_list_assignments_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_list_assignments_async_from_dict(): + await test_list_assignments_async(request_type=dict) + + def test_list_assignments_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -3752,9 +3861,7 @@ def test_list_assignments_field_headers(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._transport.list_assignments), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: call.return_value = reservation.ListAssignmentsResponse() client.list_assignments(request) @@ -3781,9 +3888,7 @@ async def test_list_assignments_field_headers_async(): request.parent = "parent/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_assignments), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.ListAssignmentsResponse() ) @@ -3804,9 +3909,7 @@ def test_list_assignments_flattened(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._transport.list_assignments), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListAssignmentsResponse() @@ -3840,9 +3943,7 @@ async def test_list_assignments_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.list_assignments), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.ListAssignmentsResponse() @@ -3879,9 +3980,7 @@ def test_list_assignments_pager(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._transport.list_assignments), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( reservation.ListAssignmentsResponse( @@ -3919,9 +4018,7 @@ def test_list_assignments_pages(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._transport.list_assignments), "__call__" - ) as call: + with mock.patch.object(type(client.transport.list_assignments), "__call__") as call: # Set the response to a series of pages. call.side_effect = ( reservation.ListAssignmentsResponse( @@ -3954,9 +4051,7 @@ async def test_list_assignments_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_assignments), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_assignments), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -3995,9 +4090,7 @@ async def test_list_assignments_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.list_assignments), - "__call__", - new_callable=mock.AsyncMock, + type(client.transport.list_assignments), "__call__", new_callable=mock.AsyncMock ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -4038,7 +4131,7 @@ def test_delete_assignment( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_assignment), "__call__" + type(client.transport.delete_assignment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -4060,18 +4153,20 @@ def test_delete_assignment_from_dict(): @pytest.mark.asyncio -async def test_delete_assignment_async(transport: str = "grpc_asyncio"): +async def test_delete_assignment_async( + transport: str = "grpc_asyncio", request_type=reservation.DeleteAssignmentRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.DeleteAssignmentRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_assignment), "__call__" + type(client.transport.delete_assignment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -4082,12 +4177,17 @@ async def test_delete_assignment_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.DeleteAssignmentRequest() # Establish that the response is the type that we expect. assert response is None +@pytest.mark.asyncio +async def test_delete_assignment_async_from_dict(): + await test_delete_assignment_async(request_type=dict) + + def test_delete_assignment_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -4098,7 +4198,7 @@ def test_delete_assignment_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_assignment), "__call__" + type(client.transport.delete_assignment), "__call__" ) as call: call.return_value = None @@ -4127,7 +4227,7 @@ async def test_delete_assignment_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_assignment), "__call__" + type(client.transport.delete_assignment), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) @@ -4148,7 +4248,7 @@ def test_delete_assignment_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.delete_assignment), "__call__" + type(client.transport.delete_assignment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -4184,7 +4284,7 @@ async def test_delete_assignment_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.delete_assignment), "__call__" + type(client.transport.delete_assignment), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = None @@ -4229,7 +4329,7 @@ def test_search_assignments( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_assignments), "__call__" + type(client.transport.search_assignments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.SearchAssignmentsResponse( @@ -4245,6 +4345,7 @@ def test_search_assignments( assert args[0] == reservation.SearchAssignmentsRequest() # Establish that the response is the type that we expect. + assert isinstance(response, pagers.SearchAssignmentsPager) assert response.next_page_token == "next_page_token_value" @@ -4255,18 +4356,20 @@ def test_search_assignments_from_dict(): @pytest.mark.asyncio -async def test_search_assignments_async(transport: str = "grpc_asyncio"): +async def test_search_assignments_async( + transport: str = "grpc_asyncio", request_type=reservation.SearchAssignmentsRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.SearchAssignmentsRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_assignments), "__call__" + type(client.transport.search_assignments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -4281,7 +4384,7 @@ async def test_search_assignments_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.SearchAssignmentsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.SearchAssignmentsAsyncPager) @@ -4289,6 +4392,11 @@ async def test_search_assignments_async(transport: str = "grpc_asyncio"): assert response.next_page_token == "next_page_token_value" +@pytest.mark.asyncio +async def test_search_assignments_async_from_dict(): + await test_search_assignments_async(request_type=dict) + + def test_search_assignments_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -4299,7 +4407,7 @@ def test_search_assignments_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_assignments), "__call__" + type(client.transport.search_assignments), "__call__" ) as call: call.return_value = reservation.SearchAssignmentsResponse() @@ -4328,7 +4436,7 @@ async def test_search_assignments_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_assignments), "__call__" + type(client.transport.search_assignments), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.SearchAssignmentsResponse() @@ -4351,7 +4459,7 @@ def test_search_assignments_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_assignments), "__call__" + type(client.transport.search_assignments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.SearchAssignmentsResponse() @@ -4393,7 +4501,7 @@ async def test_search_assignments_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_assignments), "__call__" + type(client.transport.search_assignments), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.SearchAssignmentsResponse() @@ -4438,7 +4546,7 @@ def test_search_assignments_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_assignments), "__call__" + type(client.transport.search_assignments), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -4480,7 +4588,7 @@ def test_search_assignments_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.search_assignments), "__call__" + type(client.transport.search_assignments), "__call__" ) as call: # Set the response to a series of pages. call.side_effect = ( @@ -4516,7 +4624,7 @@ async def test_search_assignments_async_pager(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_assignments), + type(client.transport.search_assignments), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -4559,7 +4667,7 @@ async def test_search_assignments_async_pages(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.search_assignments), + type(client.transport.search_assignments), "__call__", new_callable=mock.AsyncMock, ) as call: @@ -4603,7 +4711,7 @@ def test_move_assignment( request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.move_assignment), "__call__") as call: + with mock.patch.object(type(client.transport.move_assignment), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.Assignment( name="name_value", @@ -4621,6 +4729,7 @@ def test_move_assignment( assert args[0] == reservation.MoveAssignmentRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.Assignment) assert response.name == "name_value" @@ -4637,19 +4746,19 @@ def test_move_assignment_from_dict(): @pytest.mark.asyncio -async def test_move_assignment_async(transport: str = "grpc_asyncio"): +async def test_move_assignment_async( + transport: str = "grpc_asyncio", request_type=reservation.MoveAssignmentRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.MoveAssignmentRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.move_assignment), "__call__" - ) as call: + with mock.patch.object(type(client.transport.move_assignment), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.Assignment( @@ -4666,7 +4775,7 @@ async def test_move_assignment_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.MoveAssignmentRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.Assignment) @@ -4680,6 +4789,11 @@ async def test_move_assignment_async(transport: str = "grpc_asyncio"): assert response.state == reservation.Assignment.State.PENDING +@pytest.mark.asyncio +async def test_move_assignment_async_from_dict(): + await test_move_assignment_async(request_type=dict) + + def test_move_assignment_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -4689,7 +4803,7 @@ def test_move_assignment_field_headers(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.move_assignment), "__call__") as call: + with mock.patch.object(type(client.transport.move_assignment), "__call__") as call: call.return_value = reservation.Assignment() client.move_assignment(request) @@ -4716,9 +4830,7 @@ async def test_move_assignment_field_headers_async(): request.name = "name/value" # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.move_assignment), "__call__" - ) as call: + with mock.patch.object(type(client.transport.move_assignment), "__call__") as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.Assignment() ) @@ -4739,7 +4851,7 @@ def test_move_assignment_flattened(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object(type(client._transport.move_assignment), "__call__") as call: + with mock.patch.object(type(client.transport.move_assignment), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.Assignment() @@ -4779,9 +4891,7 @@ async def test_move_assignment_flattened_async(): ) # Mock the actual call within the gRPC stub, and fake the request. - with mock.patch.object( - type(client._client._transport.move_assignment), "__call__" - ) as call: + with mock.patch.object(type(client.transport.move_assignment), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = reservation.Assignment() @@ -4833,7 +4943,7 @@ def test_get_bi_reservation( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_bi_reservation), "__call__" + type(client.transport.get_bi_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation(name="name_value", size=443,) @@ -4847,6 +4957,7 @@ def test_get_bi_reservation( assert args[0] == reservation.GetBiReservationRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.BiReservation) assert response.name == "name_value" @@ -4859,18 +4970,20 @@ def test_get_bi_reservation_from_dict(): @pytest.mark.asyncio -async def test_get_bi_reservation_async(transport: str = "grpc_asyncio"): +async def test_get_bi_reservation_async( + transport: str = "grpc_asyncio", request_type=reservation.GetBiReservationRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.GetBiReservationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_bi_reservation), "__call__" + type(client.transport.get_bi_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -4883,7 +4996,7 @@ async def test_get_bi_reservation_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.GetBiReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.BiReservation) @@ -4893,6 +5006,11 @@ async def test_get_bi_reservation_async(transport: str = "grpc_asyncio"): assert response.size == 443 +@pytest.mark.asyncio +async def test_get_bi_reservation_async_from_dict(): + await test_get_bi_reservation_async(request_type=dict) + + def test_get_bi_reservation_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -4903,7 +5021,7 @@ def test_get_bi_reservation_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_bi_reservation), "__call__" + type(client.transport.get_bi_reservation), "__call__" ) as call: call.return_value = reservation.BiReservation() @@ -4932,7 +5050,7 @@ async def test_get_bi_reservation_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_bi_reservation), "__call__" + type(client.transport.get_bi_reservation), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.BiReservation() @@ -4955,7 +5073,7 @@ def test_get_bi_reservation_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.get_bi_reservation), "__call__" + type(client.transport.get_bi_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation() @@ -4991,7 +5109,7 @@ async def test_get_bi_reservation_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.get_bi_reservation), "__call__" + type(client.transport.get_bi_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation() @@ -5038,7 +5156,7 @@ def test_update_bi_reservation( # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_bi_reservation), "__call__" + type(client.transport.update_bi_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation(name="name_value", size=443,) @@ -5052,6 +5170,7 @@ def test_update_bi_reservation( assert args[0] == reservation.UpdateBiReservationRequest() # Establish that the response is the type that we expect. + assert isinstance(response, reservation.BiReservation) assert response.name == "name_value" @@ -5064,18 +5183,20 @@ def test_update_bi_reservation_from_dict(): @pytest.mark.asyncio -async def test_update_bi_reservation_async(transport: str = "grpc_asyncio"): +async def test_update_bi_reservation_async( + transport: str = "grpc_asyncio", request_type=reservation.UpdateBiReservationRequest +): client = ReservationServiceAsyncClient( credentials=credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, # and we are mocking out the actual API, so just send an empty request. - request = reservation.UpdateBiReservationRequest() + request = request_type() # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_bi_reservation), "__call__" + type(client.transport.update_bi_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( @@ -5088,7 +5209,7 @@ async def test_update_bi_reservation_async(transport: str = "grpc_asyncio"): assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == request + assert args[0] == reservation.UpdateBiReservationRequest() # Establish that the response is the type that we expect. assert isinstance(response, reservation.BiReservation) @@ -5098,6 +5219,11 @@ async def test_update_bi_reservation_async(transport: str = "grpc_asyncio"): assert response.size == 443 +@pytest.mark.asyncio +async def test_update_bi_reservation_async_from_dict(): + await test_update_bi_reservation_async(request_type=dict) + + def test_update_bi_reservation_field_headers(): client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) @@ -5108,7 +5234,7 @@ def test_update_bi_reservation_field_headers(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_bi_reservation), "__call__" + type(client.transport.update_bi_reservation), "__call__" ) as call: call.return_value = reservation.BiReservation() @@ -5140,7 +5266,7 @@ async def test_update_bi_reservation_field_headers_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_bi_reservation), "__call__" + type(client.transport.update_bi_reservation), "__call__" ) as call: call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( reservation.BiReservation() @@ -5166,7 +5292,7 @@ def test_update_bi_reservation_flattened(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._transport.update_bi_reservation), "__call__" + type(client.transport.update_bi_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation() @@ -5209,7 +5335,7 @@ async def test_update_bi_reservation_flattened_async(): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( - type(client._client._transport.update_bi_reservation), "__call__" + type(client.transport.update_bi_reservation), "__call__" ) as call: # Designate an appropriate return value for the call. call.return_value = reservation.BiReservation() @@ -5286,7 +5412,7 @@ def test_transport_instance(): credentials=credentials.AnonymousCredentials(), ) client = ReservationServiceClient(transport=transport) - assert client._transport is transport + assert client.transport is transport def test_transport_get_channel(): @@ -5322,7 +5448,7 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. client = ReservationServiceClient(credentials=credentials.AnonymousCredentials(),) - assert isinstance(client._transport, transports.ReservationServiceGrpcTransport,) + assert isinstance(client.transport, transports.ReservationServiceGrpcTransport,) def test_reservation_service_base_transport_error(): @@ -5443,7 +5569,7 @@ def test_reservation_service_host_no_port(): api_endpoint="bigqueryreservation.googleapis.com" ), ) - assert client._transport._host == "bigqueryreservation.googleapis.com:443" + assert client.transport._host == "bigqueryreservation.googleapis.com:443" def test_reservation_service_host_with_port(): @@ -5453,7 +5579,7 @@ def test_reservation_service_host_with_port(): api_endpoint="bigqueryreservation.googleapis.com:8000" ), ) - assert client._transport._host == "bigqueryreservation.googleapis.com:8000" + assert client.transport._host == "bigqueryreservation.googleapis.com:8000" def test_reservation_service_grpc_transport_channel(): @@ -5465,6 +5591,7 @@ def test_reservation_service_grpc_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None def test_reservation_service_grpc_asyncio_transport_channel(): @@ -5476,6 +5603,7 @@ def test_reservation_service_grpc_asyncio_transport_channel(): ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" + assert transport._ssl_channel_credentials == None @pytest.mark.parametrize( @@ -5526,6 +5654,7 @@ def test_reservation_service_transport_channel_mtls_with_client_cert_source( quota_project_id=None, ) assert transport.grpc_channel == mock_grpc_channel + assert transport._ssl_channel_credentials == mock_ssl_cred @pytest.mark.parametrize( @@ -5604,8 +5733,8 @@ def test_parse_assignment_path(): def test_bi_reservation_path(): - project = "squid" - location = "clam" + project = "winkle" + location = "nautilus" expected = "projects/{project}/locations/{location}/bireservation".format( project=project, location=location, @@ -5616,8 +5745,8 @@ def test_bi_reservation_path(): def test_parse_bi_reservation_path(): expected = { - "project": "whelk", - "location": "octopus", + "project": "scallop", + "location": "abalone", } path = ReservationServiceClient.bi_reservation_path(**expected) @@ -5654,9 +5783,9 @@ def test_parse_capacity_commitment_path(): def test_reservation_path(): - project = "squid" - location = "clam" - reservation = "whelk" + project = "cuttlefish" + location = "mussel" + reservation = "winkle" expected = "projects/{project}/locations/{location}/reservations/{reservation}".format( project=project, location=location, reservation=reservation, @@ -5667,9 +5796,9 @@ def test_reservation_path(): def test_parse_reservation_path(): expected = { - "project": "octopus", - "location": "oyster", - "reservation": "nudibranch", + "project": "nautilus", + "location": "scallop", + "reservation": "abalone", } path = ReservationServiceClient.reservation_path(**expected) @@ -5678,6 +5807,107 @@ def test_parse_reservation_path(): assert expected == actual +def test_common_billing_account_path(): + billing_account = "squid" + + expected = "billingAccounts/{billing_account}".format( + billing_account=billing_account, + ) + actual = ReservationServiceClient.common_billing_account_path(billing_account) + assert expected == actual + + +def test_parse_common_billing_account_path(): + expected = { + "billing_account": "clam", + } + path = ReservationServiceClient.common_billing_account_path(**expected) + + # Check that the path construction is reversible. + actual = ReservationServiceClient.parse_common_billing_account_path(path) + assert expected == actual + + +def test_common_folder_path(): + folder = "whelk" + + expected = "folders/{folder}".format(folder=folder,) + actual = ReservationServiceClient.common_folder_path(folder) + assert expected == actual + + +def test_parse_common_folder_path(): + expected = { + "folder": "octopus", + } + path = ReservationServiceClient.common_folder_path(**expected) + + # Check that the path construction is reversible. + actual = ReservationServiceClient.parse_common_folder_path(path) + assert expected == actual + + +def test_common_organization_path(): + organization = "oyster" + + expected = "organizations/{organization}".format(organization=organization,) + actual = ReservationServiceClient.common_organization_path(organization) + assert expected == actual + + +def test_parse_common_organization_path(): + expected = { + "organization": "nudibranch", + } + path = ReservationServiceClient.common_organization_path(**expected) + + # Check that the path construction is reversible. + actual = ReservationServiceClient.parse_common_organization_path(path) + assert expected == actual + + +def test_common_project_path(): + project = "cuttlefish" + + expected = "projects/{project}".format(project=project,) + actual = ReservationServiceClient.common_project_path(project) + assert expected == actual + + +def test_parse_common_project_path(): + expected = { + "project": "mussel", + } + path = ReservationServiceClient.common_project_path(**expected) + + # Check that the path construction is reversible. + actual = ReservationServiceClient.parse_common_project_path(path) + assert expected == actual + + +def test_common_location_path(): + project = "winkle" + location = "nautilus" + + expected = "projects/{project}/locations/{location}".format( + project=project, location=location, + ) + actual = ReservationServiceClient.common_location_path(project, location) + assert expected == actual + + +def test_parse_common_location_path(): + expected = { + "project": "scallop", + "location": "abalone", + } + path = ReservationServiceClient.common_location_path(**expected) + + # Check that the path construction is reversible. + actual = ReservationServiceClient.parse_common_location_path(path) + assert expected == actual + + def test_client_withDEFAULT_CLIENT_INFO(): client_info = gapic_v1.client_info.ClientInfo()