Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
chore: use gapic-generator-python 0.58.4 (#62)
Browse files Browse the repository at this point in the history
- [ ] Regenerate this pull request now.

fix: provide appropriate mock values for message body fields

committer: dovs
PiperOrigin-RevId: 419025932

Source-Link: googleapis/googleapis@73da669

Source-Link: googleapis/googleapis-gen@46df624
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9
  • Loading branch information
gcf-owl-bot[bot] committed Jan 7, 2022
1 parent 1f846f4 commit 24cf144
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 43 deletions.
Expand Up @@ -101,7 +101,6 @@ def __init__(
credentials, _ = google.auth.load_credentials_from_file(
credentials_file, **scopes_kwargs, quota_project_id=quota_project_id
)

elif credentials is None:
credentials, _ = google.auth.default(
**scopes_kwargs, quota_project_id=quota_project_id
Expand Down
61 changes: 19 additions & 42 deletions tests/unit/gapic/shell_v1/test_cloud_shell_service.py
Expand Up @@ -253,20 +253,20 @@ def test_cloud_shell_service_client_client_options(
# unsupported value.
with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}):
with pytest.raises(MutualTLSChannelError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value.
with mock.patch.dict(
os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"}
):
with pytest.raises(ValueError):
client = client_class()
client = client_class(transport=transport_name)

# Check the case quota_project_id is provided
options = client_options.ClientOptions(quota_project_id="octopus")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -335,7 +335,7 @@ def test_cloud_shell_service_client_mtls_env_auto(
)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)

if use_client_cert_env == "false":
expected_client_cert_source = None
Expand Down Expand Up @@ -430,7 +430,7 @@ def test_cloud_shell_service_client_client_options_scopes(
options = client_options.ClientOptions(scopes=["1", "2"],)
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file=None,
Expand Down Expand Up @@ -461,7 +461,7 @@ def test_cloud_shell_service_client_client_options_credentials_file(
options = client_options.ClientOptions(credentials_file="credentials.json")
with mock.patch.object(transport_class, "__init__") as patched:
patched.return_value = None
client = client_class(transport=transport_name, client_options=options)
client = client_class(client_options=options, transport=transport_name)
patched.assert_called_once_with(
credentials=None,
credentials_file="credentials.json",
Expand Down Expand Up @@ -494,9 +494,8 @@ def test_cloud_shell_service_client_client_options_from_dict():
)


def test_get_environment(
transport: str = "grpc", request_type=cloudshell.GetEnvironmentRequest
):
@pytest.mark.parametrize("request_type", [cloudshell.GetEnvironmentRequest, dict,])
def test_get_environment(request_type, transport: str = "grpc"):
client = CloudShellServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand Down Expand Up @@ -539,10 +538,6 @@ def test_get_environment(
assert response.public_keys == ["public_keys_value"]


def test_get_environment_from_dict():
test_get_environment(request_type=dict)


def test_get_environment_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -736,9 +731,8 @@ async def test_get_environment_flattened_error_async():
)


def test_start_environment(
transport: str = "grpc", request_type=cloudshell.StartEnvironmentRequest
):
@pytest.mark.parametrize("request_type", [cloudshell.StartEnvironmentRequest, dict,])
def test_start_environment(request_type, transport: str = "grpc"):
client = CloudShellServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -764,10 +758,6 @@ def test_start_environment(
assert isinstance(response, future.Future)


def test_start_environment_from_dict():
test_start_environment(request_type=dict)


def test_start_environment_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -878,9 +868,10 @@ async def test_start_environment_field_headers_async():
assert ("x-goog-request-params", "name=name/value",) in kw["metadata"]


def test_authorize_environment(
transport: str = "grpc", request_type=cloudshell.AuthorizeEnvironmentRequest
):
@pytest.mark.parametrize(
"request_type", [cloudshell.AuthorizeEnvironmentRequest, dict,]
)
def test_authorize_environment(request_type, transport: str = "grpc"):
client = CloudShellServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -906,10 +897,6 @@ def test_authorize_environment(
assert isinstance(response, future.Future)


def test_authorize_environment_from_dict():
test_authorize_environment(request_type=dict)


def test_authorize_environment_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -1020,9 +1007,8 @@ async def test_authorize_environment_field_headers_async():
assert ("x-goog-request-params", "name=name/value",) in kw["metadata"]


def test_add_public_key(
transport: str = "grpc", request_type=cloudshell.AddPublicKeyRequest
):
@pytest.mark.parametrize("request_type", [cloudshell.AddPublicKeyRequest, dict,])
def test_add_public_key(request_type, transport: str = "grpc"):
client = CloudShellServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -1046,10 +1032,6 @@ def test_add_public_key(
assert isinstance(response, future.Future)


def test_add_public_key_from_dict():
test_add_public_key(request_type=dict)


def test_add_public_key_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -1152,9 +1134,8 @@ async def test_add_public_key_field_headers_async():
assert ("x-goog-request-params", "environment=environment/value",) in kw["metadata"]


def test_remove_public_key(
transport: str = "grpc", request_type=cloudshell.RemovePublicKeyRequest
):
@pytest.mark.parametrize("request_type", [cloudshell.RemovePublicKeyRequest, dict,])
def test_remove_public_key(request_type, transport: str = "grpc"):
client = CloudShellServiceClient(
credentials=ga_credentials.AnonymousCredentials(), transport=transport,
)
Expand All @@ -1180,10 +1161,6 @@ def test_remove_public_key(
assert isinstance(response, future.Future)


def test_remove_public_key_from_dict():
test_remove_public_key(request_type=dict)


def test_remove_public_key_empty_call():
# This test is a coverage failsafe to make sure that totally empty calls,
# i.e. request == None and no flattened fields passed, work.
Expand Down Expand Up @@ -1843,7 +1820,7 @@ def test_parse_common_location_path():
assert expected == actual


def test_client_withDEFAULT_CLIENT_INFO():
def test_client_with_default_client_info():
client_info = gapic_v1.client_info.ClientInfo()

with mock.patch.object(
Expand Down

0 comments on commit 24cf144

Please sign in to comment.