From 4f3041632293dd1464358811605617fba190affc Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 8 Jan 2022 05:35:31 -0500 Subject: [PATCH] chore: use gapic-generator-python 0.58.4 (#230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: use gapic-generator-python 0.58.4 fix: provide appropriate mock values for message body fields committer: dovs PiperOrigin-RevId: 419025932 Source-Link: https://github.com/googleapis/googleapis/commit/73da6697f598f1ba30618924936a59f8e457ec89 Source-Link: https://github.com/googleapis/googleapis-gen/commit/46df624a54b9ed47c1a7eefb7a49413cf7b82f98 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDZkZjYyNGE1NGI5ZWQ0N2MxYTdlZWZiN2E0OTQxM2NmN2I4MmY5OCJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot --- .../secret_manager_service/transports/base.py | 1 - .../test_secret_manager_service.py | 163 +++++------------- 2 files changed, 47 insertions(+), 117 deletions(-) diff --git a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py index 35356563c0cc..346bf670f77f 100644 --- a/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py +++ b/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/transports/base.py @@ -105,7 +105,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 diff --git a/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py b/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py index e2084ff9e8f1..ec4ffac9a776 100644 --- a/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py +++ b/packages/google-cloud-secret-manager/tests/unit/gapic/secretmanager_v1/test_secret_manager_service.py @@ -263,20 +263,20 @@ def test_secret_manager_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, @@ -345,7 +345,7 @@ def test_secret_manager_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 @@ -444,7 +444,7 @@ def test_secret_manager_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, @@ -479,7 +479,7 @@ def test_secret_manager_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", @@ -512,7 +512,8 @@ def test_secret_manager_service_client_client_options_from_dict(): ) -def test_list_secrets(transport: str = "grpc", request_type=service.ListSecretsRequest): +@pytest.mark.parametrize("request_type", [service.ListSecretsRequest, dict,]) +def test_list_secrets(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -540,10 +541,6 @@ def test_list_secrets(transport: str = "grpc", request_type=service.ListSecretsR assert response.total_size == 1086 -def test_list_secrets_from_dict(): - test_list_secrets(request_type=dict) - - def test_list_secrets_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. @@ -728,9 +725,9 @@ async def test_list_secrets_flattened_error_async(): ) -def test_list_secrets_pager(): +def test_list_secrets_pager(transport_name: str = "grpc"): client = SecretManagerServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -764,9 +761,9 @@ def test_list_secrets_pager(): assert all(isinstance(i, resources.Secret) for i in results) -def test_list_secrets_pages(): +def test_list_secrets_pages(transport_name: str = "grpc"): client = SecretManagerServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -858,9 +855,8 @@ async def test_list_secrets_async_pages(): assert page_.raw_page.next_page_token == token -def test_create_secret( - transport: str = "grpc", request_type=service.CreateSecretRequest -): +@pytest.mark.parametrize("request_type", [service.CreateSecretRequest, dict,]) +def test_create_secret(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -890,10 +886,6 @@ def test_create_secret( assert response.etag == "etag_value" -def test_create_secret_from_dict(): - test_create_secret(request_type=dict) - - def test_create_secret_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. @@ -1098,9 +1090,8 @@ async def test_create_secret_flattened_error_async(): ) -def test_add_secret_version( - transport: str = "grpc", request_type=service.AddSecretVersionRequest -): +@pytest.mark.parametrize("request_type", [service.AddSecretVersionRequest, dict,]) +def test_add_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1133,10 +1124,6 @@ def test_add_secret_version( assert response.etag == "etag_value" -def test_add_secret_version_from_dict(): - test_add_secret_version(request_type=dict) - - def test_add_secret_version_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. @@ -1350,7 +1337,8 @@ async def test_add_secret_version_flattened_error_async(): ) -def test_get_secret(transport: str = "grpc", request_type=service.GetSecretRequest): +@pytest.mark.parametrize("request_type", [service.GetSecretRequest, dict,]) +def test_get_secret(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1380,10 +1368,6 @@ def test_get_secret(transport: str = "grpc", request_type=service.GetSecretReque assert response.etag == "etag_value" -def test_get_secret_from_dict(): - test_get_secret(request_type=dict) - - def test_get_secret_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. @@ -1562,9 +1546,8 @@ async def test_get_secret_flattened_error_async(): ) -def test_update_secret( - transport: str = "grpc", request_type=service.UpdateSecretRequest -): +@pytest.mark.parametrize("request_type", [service.UpdateSecretRequest, dict,]) +def test_update_secret(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1594,10 +1577,6 @@ def test_update_secret( assert response.etag == "etag_value" -def test_update_secret_from_dict(): - test_update_secret(request_type=dict) - - def test_update_secret_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. @@ -1792,9 +1771,8 @@ async def test_update_secret_flattened_error_async(): ) -def test_delete_secret( - transport: str = "grpc", request_type=service.DeleteSecretRequest -): +@pytest.mark.parametrize("request_type", [service.DeleteSecretRequest, dict,]) +def test_delete_secret(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1818,10 +1796,6 @@ def test_delete_secret( assert response is None -def test_delete_secret_from_dict(): - test_delete_secret(request_type=dict) - - def test_delete_secret_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. @@ -1996,9 +1970,8 @@ async def test_delete_secret_flattened_error_async(): ) -def test_list_secret_versions( - transport: str = "grpc", request_type=service.ListSecretVersionsRequest -): +@pytest.mark.parametrize("request_type", [service.ListSecretVersionsRequest, dict,]) +def test_list_secret_versions(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2028,10 +2001,6 @@ def test_list_secret_versions( assert response.total_size == 1086 -def test_list_secret_versions_from_dict(): - test_list_secret_versions(request_type=dict) - - def test_list_secret_versions_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. @@ -2228,9 +2197,9 @@ async def test_list_secret_versions_flattened_error_async(): ) -def test_list_secret_versions_pager(): +def test_list_secret_versions_pager(transport_name: str = "grpc"): client = SecretManagerServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2270,9 +2239,9 @@ def test_list_secret_versions_pager(): assert all(isinstance(i, resources.SecretVersion) for i in results) -def test_list_secret_versions_pages(): +def test_list_secret_versions_pages(transport_name: str = "grpc"): client = SecretManagerServiceClient( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2382,9 +2351,8 @@ async def test_list_secret_versions_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_secret_version( - transport: str = "grpc", request_type=service.GetSecretVersionRequest -): +@pytest.mark.parametrize("request_type", [service.GetSecretVersionRequest, dict,]) +def test_get_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2417,10 +2385,6 @@ def test_get_secret_version( assert response.etag == "etag_value" -def test_get_secret_version_from_dict(): - test_get_secret_version(request_type=dict) - - def test_get_secret_version_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. @@ -2620,9 +2584,8 @@ async def test_get_secret_version_flattened_error_async(): ) -def test_access_secret_version( - transport: str = "grpc", request_type=service.AccessSecretVersionRequest -): +@pytest.mark.parametrize("request_type", [service.AccessSecretVersionRequest, dict,]) +def test_access_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2649,10 +2612,6 @@ def test_access_secret_version( assert response.name == "name_value" -def test_access_secret_version_from_dict(): - test_access_secret_version(request_type=dict) - - def test_access_secret_version_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. @@ -2846,9 +2805,8 @@ async def test_access_secret_version_flattened_error_async(): ) -def test_disable_secret_version( - transport: str = "grpc", request_type=service.DisableSecretVersionRequest -): +@pytest.mark.parametrize("request_type", [service.DisableSecretVersionRequest, dict,]) +def test_disable_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2881,10 +2839,6 @@ def test_disable_secret_version( assert response.etag == "etag_value" -def test_disable_secret_version_from_dict(): - test_disable_secret_version(request_type=dict) - - def test_disable_secret_version_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. @@ -3084,9 +3038,8 @@ async def test_disable_secret_version_flattened_error_async(): ) -def test_enable_secret_version( - transport: str = "grpc", request_type=service.EnableSecretVersionRequest -): +@pytest.mark.parametrize("request_type", [service.EnableSecretVersionRequest, dict,]) +def test_enable_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3119,10 +3072,6 @@ def test_enable_secret_version( assert response.etag == "etag_value" -def test_enable_secret_version_from_dict(): - test_enable_secret_version(request_type=dict) - - def test_enable_secret_version_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. @@ -3322,9 +3271,8 @@ async def test_enable_secret_version_flattened_error_async(): ) -def test_destroy_secret_version( - transport: str = "grpc", request_type=service.DestroySecretVersionRequest -): +@pytest.mark.parametrize("request_type", [service.DestroySecretVersionRequest, dict,]) +def test_destroy_secret_version(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3357,10 +3305,6 @@ def test_destroy_secret_version( assert response.etag == "etag_value" -def test_destroy_secret_version_from_dict(): - test_destroy_secret_version(request_type=dict) - - def test_destroy_secret_version_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. @@ -3560,9 +3504,8 @@ async def test_destroy_secret_version_flattened_error_async(): ) -def test_set_iam_policy( - transport: str = "grpc", request_type=iam_policy_pb2.SetIamPolicyRequest -): +@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +def test_set_iam_policy(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3588,10 +3531,6 @@ def test_set_iam_policy( assert response.etag == b"etag_blob" -def test_set_iam_policy_from_dict(): - test_set_iam_policy(request_type=dict) - - def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3713,9 +3652,8 @@ def test_set_iam_policy_from_dict_foreign(): call.assert_called() -def test_get_iam_policy( - transport: str = "grpc", request_type=iam_policy_pb2.GetIamPolicyRequest -): +@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +def test_get_iam_policy(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3741,10 +3679,6 @@ def test_get_iam_policy( assert response.etag == b"etag_blob" -def test_get_iam_policy_from_dict(): - test_get_iam_policy(request_type=dict) - - def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3866,9 +3800,10 @@ def test_get_iam_policy_from_dict_foreign(): call.assert_called() -def test_test_iam_permissions( - transport: str = "grpc", request_type=iam_policy_pb2.TestIamPermissionsRequest -): +@pytest.mark.parametrize( + "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] +) +def test_test_iam_permissions(request_type, transport: str = "grpc"): client = SecretManagerServiceClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3897,10 +3832,6 @@ def test_test_iam_permissions( assert response.permissions == ["permissions_value"] -def test_test_iam_permissions_from_dict(): - test_test_iam_permissions(request_type=dict) - - def test_test_iam_permissions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4612,7 +4543,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(