Skip to content
This repository was archived by the owner on Oct 11, 2023. It is now read-only.

chore: use gapic-generator-python 0.62.1 #64

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions google/cloud/debugger_v2/services/controller2/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ async def register_debuggee(
Response for registering a debuggee.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -337,7 +337,7 @@ async def list_active_breakpoints(

"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -430,7 +430,7 @@ async def update_active_breakpoint(

"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, breakpoint_])
if request is not None and has_flattened_params:
Expand Down
6 changes: 3 additions & 3 deletions google/cloud/debugger_v2/services/controller2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def register_debuggee(
Response for registering a debuggee.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -522,7 +522,7 @@ def list_active_breakpoints(

"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -605,7 +605,7 @@ def update_active_breakpoint(

"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, breakpoint_])
if request is not None and has_flattened_params:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ def __init__(
if not self._grpc_channel:
self._grpc_channel = type(self).create_channel(
self._host,
# use the credentials which are saved
credentials=self._credentials,
credentials_file=credentials_file,
# Set ``credentials_file`` to ``None`` here as
# the credentials that we saved earlier should be used.
credentials_file=None,
scopes=self._scopes,
ssl_credentials=self._ssl_channel_credentials,
quota_project_id=quota_project_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,11 @@ def __init__(
if not self._grpc_channel:
self._grpc_channel = type(self).create_channel(
self._host,
# use the credentials which are saved
credentials=self._credentials,
credentials_file=credentials_file,
# Set ``credentials_file`` to ``None`` here as
# the credentials that we saved earlier should be used.
credentials_file=None,
scopes=self._scopes,
ssl_credentials=self._ssl_channel_credentials,
quota_project_id=quota_project_id,
Expand Down
10 changes: 5 additions & 5 deletions google/cloud/debugger_v2/services/debugger2/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ async def set_breakpoint(
Response for setting a breakpoint.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, breakpoint_, client_version])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -342,7 +342,7 @@ async def get_breakpoint(

"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, breakpoint_id, client_version])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -431,7 +431,7 @@ async def delete_breakpoint(
sent along with the request as metadata.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, breakpoint_id, client_version])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -515,7 +515,7 @@ async def list_breakpoints(
Response for listing breakpoints.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, client_version])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -598,7 +598,7 @@ async def list_debuggees(
Response for listing debuggees.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([project, client_version])
if request is not None and has_flattened_params:
Expand Down
10 changes: 5 additions & 5 deletions google/cloud/debugger_v2/services/debugger2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ def set_breakpoint(
Response for setting a breakpoint.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, breakpoint_, client_version])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -529,7 +529,7 @@ def get_breakpoint(

"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, breakpoint_id, client_version])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -608,7 +608,7 @@ def delete_breakpoint(
sent along with the request as metadata.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, breakpoint_id, client_version])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -682,7 +682,7 @@ def list_breakpoints(
Response for listing breakpoints.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([debuggee_id, client_version])
if request is not None and has_flattened_params:
Expand Down Expand Up @@ -755,7 +755,7 @@ def list_debuggees(
Response for listing debuggees.
"""
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# Quick check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([project, client_version])
if request is not None and has_flattened_params:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,11 @@ def __init__(
if not self._grpc_channel:
self._grpc_channel = type(self).create_channel(
self._host,
# use the credentials which are saved
credentials=self._credentials,
credentials_file=credentials_file,
# Set ``credentials_file`` to ``None`` here as
# the credentials that we saved earlier should be used.
credentials_file=None,
scopes=self._scopes,
ssl_credentials=self._ssl_channel_credentials,
quota_project_id=quota_project_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,11 @@ def __init__(
if not self._grpc_channel:
self._grpc_channel = type(self).create_channel(
self._host,
# use the credentials which are saved
credentials=self._credentials,
credentials_file=credentials_file,
# Set ``credentials_file`` to ``None`` here as
# the credentials that we saved earlier should be used.
credentials_file=None,
scopes=self._scopes,
ssl_credentials=self._ssl_channel_credentials,
quota_project_id=quota_project_id,
Expand Down
72 changes: 69 additions & 3 deletions tests/unit/gapic/debugger_v2/test_controller2.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,21 +496,23 @@ def test_controller2_client_client_options_scopes(


@pytest.mark.parametrize(
"client_class,transport_class,transport_name",
"client_class,transport_class,transport_name,grpc_helpers",
[
(Controller2Client, transports.Controller2GrpcTransport, "grpc"),
(Controller2Client, transports.Controller2GrpcTransport, "grpc", grpc_helpers),
(
Controller2AsyncClient,
transports.Controller2GrpcAsyncIOTransport,
"grpc_asyncio",
grpc_helpers_async,
),
],
)
def test_controller2_client_client_options_credentials_file(
client_class, transport_class, transport_name
client_class, transport_class, transport_name, grpc_helpers
):
# Check the case credentials file is provided.
options = client_options.ClientOptions(credentials_file="credentials.json")

with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(client_options=options, transport=transport_name)
Expand Down Expand Up @@ -544,6 +546,70 @@ def test_controller2_client_client_options_from_dict():
)


@pytest.mark.parametrize(
"client_class,transport_class,transport_name,grpc_helpers",
[
(Controller2Client, transports.Controller2GrpcTransport, "grpc", grpc_helpers),
(
Controller2AsyncClient,
transports.Controller2GrpcAsyncIOTransport,
"grpc_asyncio",
grpc_helpers_async,
),
],
)
def test_controller2_client_create_channel_credentials_file(
client_class, transport_class, transport_name, grpc_helpers
):
# Check the case credentials file is provided.
options = client_options.ClientOptions(credentials_file="credentials.json")

with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file="credentials.json",
host=client.DEFAULT_ENDPOINT,
scopes=None,
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
always_use_jwt_access=True,
)

# test that the credentials from file are saved and used as the credentials.
with mock.patch.object(
google.auth, "load_credentials_from_file", autospec=True
) as load_creds, mock.patch.object(
google.auth, "default", autospec=True
) as adc, mock.patch.object(
grpc_helpers, "create_channel"
) as create_channel:
creds = ga_credentials.AnonymousCredentials()
file_creds = ga_credentials.AnonymousCredentials()
load_creds.return_value = (file_creds, None)
adc.return_value = (creds, None)
client = client_class(client_options=options, transport=transport_name)
create_channel.assert_called_with(
"clouddebugger.googleapis.com:443",
credentials=file_creds,
credentials_file=None,
quota_project_id=None,
default_scopes=(
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/cloud_debugger",
),
scopes=None,
default_host="clouddebugger.googleapis.com",
ssl_credentials=None,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)


@pytest.mark.parametrize("request_type", [controller.RegisterDebuggeeRequest, dict,])
def test_register_debuggee(request_type, transport: str = "grpc"):
client = Controller2Client(
Expand Down
72 changes: 69 additions & 3 deletions tests/unit/gapic/debugger_v2/test_debugger2.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,21 +491,23 @@ def test_debugger2_client_client_options_scopes(


@pytest.mark.parametrize(
"client_class,transport_class,transport_name",
"client_class,transport_class,transport_name,grpc_helpers",
[
(Debugger2Client, transports.Debugger2GrpcTransport, "grpc"),
(Debugger2Client, transports.Debugger2GrpcTransport, "grpc", grpc_helpers),
(
Debugger2AsyncClient,
transports.Debugger2GrpcAsyncIOTransport,
"grpc_asyncio",
grpc_helpers_async,
),
],
)
def test_debugger2_client_client_options_credentials_file(
client_class, transport_class, transport_name
client_class, transport_class, transport_name, grpc_helpers
):
# Check the case credentials file is provided.
options = client_options.ClientOptions(credentials_file="credentials.json")

with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(client_options=options, transport=transport_name)
Expand Down Expand Up @@ -539,6 +541,70 @@ def test_debugger2_client_client_options_from_dict():
)


@pytest.mark.parametrize(
"client_class,transport_class,transport_name,grpc_helpers",
[
(Debugger2Client, transports.Debugger2GrpcTransport, "grpc", grpc_helpers),
(
Debugger2AsyncClient,
transports.Debugger2GrpcAsyncIOTransport,
"grpc_asyncio",
grpc_helpers_async,
),
],
)
def test_debugger2_client_create_channel_credentials_file(
client_class, transport_class, transport_name, grpc_helpers
):
# Check the case credentials file is provided.
options = client_options.ClientOptions(credentials_file="credentials.json")

with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file="credentials.json",
host=client.DEFAULT_ENDPOINT,
scopes=None,
client_cert_source_for_mtls=None,
quota_project_id=None,
client_info=transports.base.DEFAULT_CLIENT_INFO,
always_use_jwt_access=True,
)

# test that the credentials from file are saved and used as the credentials.
with mock.patch.object(
google.auth, "load_credentials_from_file", autospec=True
) as load_creds, mock.patch.object(
google.auth, "default", autospec=True
) as adc, mock.patch.object(
grpc_helpers, "create_channel"
) as create_channel:
creds = ga_credentials.AnonymousCredentials()
file_creds = ga_credentials.AnonymousCredentials()
load_creds.return_value = (file_creds, None)
adc.return_value = (creds, None)
client = client_class(client_options=options, transport=transport_name)
create_channel.assert_called_with(
"clouddebugger.googleapis.com:443",
credentials=file_creds,
credentials_file=None,
quota_project_id=None,
default_scopes=(
"https://www.googleapis.com/auth/cloud-platform",
"https://www.googleapis.com/auth/cloud_debugger",
),
scopes=None,
default_host="clouddebugger.googleapis.com",
ssl_credentials=None,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)


@pytest.mark.parametrize("request_type", [debugger.SetBreakpointRequest, dict,])
def test_set_breakpoint(request_type, transport: str = "grpc"):
client = Debugger2Client(
Expand Down