From cabb43b2c8db83f78df5a6d87a1b4051431415e2 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 7 Jan 2022 13:53:22 -0500 Subject: [PATCH] chore: use gapic-generator-python 0.58.4 (#103) 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 Co-authored-by: Anthonios Partheniou --- .../transports/base.py | 1 - .../system_policy_v1/transports/base.py | 1 - .../validation_helper_v1/transports/base.py | 1 - .../transports/base.py | 1 - .../system_policy_v1_beta1/transports/base.py | 1 - .../test_binauthz_management_service_v1.py | 81 ++++++------------- .../test_system_policy_v1.py | 23 +++--- .../test_validation_helper_v1.py | 25 +++--- ...st_binauthz_management_service_v1_beta1.py | 81 ++++++------------- .../test_system_policy_v1_beta1.py | 23 +++--- 10 files changed, 79 insertions(+), 159 deletions(-) diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py index 5dc7906c8526..76a8268fa085 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/base.py @@ -103,7 +103,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-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py index 5b5aab155f2b..70448e1f8b9c 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/base.py @@ -102,7 +102,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-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py index 6929c1ca0a59..6eab85c8cf2a 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/base.py @@ -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 diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py index 5c3fbaf86c1a..9e68259b81cc 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/base.py @@ -103,7 +103,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-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/base.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/base.py index 5f9526f692b3..ec49c46daa8f 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/base.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/base.py @@ -102,7 +102,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-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py index 39255f98db68..5571c222cf16 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py @@ -269,20 +269,20 @@ def test_binauthz_management_service_v1_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, @@ -351,7 +351,7 @@ def test_binauthz_management_service_v1_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 @@ -450,7 +450,7 @@ def test_binauthz_management_service_v1_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, @@ -485,7 +485,7 @@ def test_binauthz_management_service_v1_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", @@ -518,7 +518,8 @@ def test_binauthz_management_service_v1_client_client_options_from_dict(): ) -def test_get_policy(transport: str = "grpc", request_type=service.GetPolicyRequest): +@pytest.mark.parametrize("request_type", [service.GetPolicyRequest, dict,]) +def test_get_policy(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -552,10 +553,6 @@ def test_get_policy(transport: str = "grpc", request_type=service.GetPolicyReque ) -def test_get_policy_from_dict(): - test_get_policy(request_type=dict) - - def test_get_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. @@ -742,9 +739,8 @@ async def test_get_policy_flattened_error_async(): ) -def test_update_policy( - transport: str = "grpc", request_type=service.UpdatePolicyRequest -): +@pytest.mark.parametrize("request_type", [service.UpdatePolicyRequest, dict,]) +def test_update_policy(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -778,10 +774,6 @@ def test_update_policy( ) -def test_update_policy_from_dict(): - test_update_policy(request_type=dict) - - def test_update_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. @@ -970,9 +962,8 @@ async def test_update_policy_flattened_error_async(): ) -def test_create_attestor( - transport: str = "grpc", request_type=service.CreateAttestorRequest -): +@pytest.mark.parametrize("request_type", [service.CreateAttestorRequest, dict,]) +def test_create_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1004,10 +995,6 @@ def test_create_attestor( assert response.description == "description_value" -def test_create_attestor_from_dict(): - test_create_attestor(request_type=dict) - - def test_create_attestor_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. @@ -1212,7 +1199,8 @@ async def test_create_attestor_flattened_error_async(): ) -def test_get_attestor(transport: str = "grpc", request_type=service.GetAttestorRequest): +@pytest.mark.parametrize("request_type", [service.GetAttestorRequest, dict,]) +def test_get_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1244,10 +1232,6 @@ def test_get_attestor(transport: str = "grpc", request_type=service.GetAttestorR assert response.description == "description_value" -def test_get_attestor_from_dict(): - test_get_attestor(request_type=dict) - - def test_get_attestor_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. @@ -1426,9 +1410,8 @@ async def test_get_attestor_flattened_error_async(): ) -def test_update_attestor( - transport: str = "grpc", request_type=service.UpdateAttestorRequest -): +@pytest.mark.parametrize("request_type", [service.UpdateAttestorRequest, dict,]) +def test_update_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1460,10 +1443,6 @@ def test_update_attestor( assert response.description == "description_value" -def test_update_attestor_from_dict(): - test_update_attestor(request_type=dict) - - def test_update_attestor_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. @@ -1650,9 +1629,8 @@ async def test_update_attestor_flattened_error_async(): ) -def test_list_attestors( - transport: str = "grpc", request_type=service.ListAttestorsRequest -): +@pytest.mark.parametrize("request_type", [service.ListAttestorsRequest, dict,]) +def test_list_attestors(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1679,10 +1657,6 @@ def test_list_attestors( assert response.next_page_token == "next_page_token_value" -def test_list_attestors_from_dict(): - test_list_attestors(request_type=dict) - - def test_list_attestors_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. @@ -1864,9 +1838,9 @@ async def test_list_attestors_flattened_error_async(): ) -def test_list_attestors_pager(): +def test_list_attestors_pager(transport_name: str = "grpc"): client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1904,9 +1878,9 @@ def test_list_attestors_pager(): assert all(isinstance(i, resources.Attestor) for i in results) -def test_list_attestors_pages(): +def test_list_attestors_pages(transport_name: str = "grpc"): client = BinauthzManagementServiceV1Client( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2010,9 +1984,8 @@ async def test_list_attestors_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_attestor( - transport: str = "grpc", request_type=service.DeleteAttestorRequest -): +@pytest.mark.parametrize("request_type", [service.DeleteAttestorRequest, dict,]) +def test_delete_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2036,10 +2009,6 @@ def test_delete_attestor( assert response is None -def test_delete_attestor_from_dict(): - test_delete_attestor(request_type=dict) - - def test_delete_attestor_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. @@ -2765,7 +2734,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( diff --git a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py index f5cc3dac5567..f116ada6eeab 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py @@ -251,20 +251,20 @@ def test_system_policy_v1_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, @@ -323,7 +323,7 @@ def test_system_policy_v1_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 @@ -418,7 +418,7 @@ def test_system_policy_v1_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, @@ -449,7 +449,7 @@ def test_system_policy_v1_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", @@ -482,9 +482,8 @@ def test_system_policy_v1_client_client_options_from_dict(): ) -def test_get_system_policy( - transport: str = "grpc", request_type=service.GetSystemPolicyRequest -): +@pytest.mark.parametrize("request_type", [service.GetSystemPolicyRequest, dict,]) +def test_get_system_policy(request_type, transport: str = "grpc"): client = SystemPolicyV1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -520,10 +519,6 @@ def test_get_system_policy( ) -def test_get_system_policy_from_dict(): - test_get_system_policy(request_type=dict) - - def test_get_system_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. @@ -1222,7 +1217,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( diff --git a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py index 5cb80b74247e..ec462f99b484 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py @@ -252,20 +252,20 @@ def test_validation_helper_v1_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, @@ -334,7 +334,7 @@ def test_validation_helper_v1_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 @@ -429,7 +429,7 @@ def test_validation_helper_v1_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, @@ -460,7 +460,7 @@ def test_validation_helper_v1_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", @@ -493,9 +493,10 @@ def test_validation_helper_v1_client_client_options_from_dict(): ) -def test_validate_attestation_occurrence( - transport: str = "grpc", request_type=service.ValidateAttestationOccurrenceRequest -): +@pytest.mark.parametrize( + "request_type", [service.ValidateAttestationOccurrenceRequest, dict,] +) +def test_validate_attestation_occurrence(request_type, transport: str = "grpc"): client = ValidationHelperV1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -528,10 +529,6 @@ def test_validate_attestation_occurrence( assert response.denial_reason == "denial_reason_value" -def test_validate_attestation_occurrence_from_dict(): - test_validate_attestation_occurrence(request_type=dict) - - def test_validate_attestation_occurrence_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. @@ -1144,7 +1141,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( diff --git a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py index d1534c9b4597..3c8248bdbb84 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py @@ -288,20 +288,20 @@ def test_binauthz_management_service_v1_beta1_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, @@ -370,7 +370,7 @@ def test_binauthz_management_service_v1_beta1_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 @@ -469,7 +469,7 @@ def test_binauthz_management_service_v1_beta1_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, @@ -504,7 +504,7 @@ def test_binauthz_management_service_v1_beta1_client_client_options_credentials_ 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", @@ -537,7 +537,8 @@ def test_binauthz_management_service_v1_beta1_client_client_options_from_dict(): ) -def test_get_policy(transport: str = "grpc", request_type=service.GetPolicyRequest): +@pytest.mark.parametrize("request_type", [service.GetPolicyRequest, dict,]) +def test_get_policy(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -571,10 +572,6 @@ def test_get_policy(transport: str = "grpc", request_type=service.GetPolicyReque ) -def test_get_policy_from_dict(): - test_get_policy(request_type=dict) - - def test_get_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. @@ -761,9 +758,8 @@ async def test_get_policy_flattened_error_async(): ) -def test_update_policy( - transport: str = "grpc", request_type=service.UpdatePolicyRequest -): +@pytest.mark.parametrize("request_type", [service.UpdatePolicyRequest, dict,]) +def test_update_policy(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -797,10 +793,6 @@ def test_update_policy( ) -def test_update_policy_from_dict(): - test_update_policy(request_type=dict) - - def test_update_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. @@ -989,9 +981,8 @@ async def test_update_policy_flattened_error_async(): ) -def test_create_attestor( - transport: str = "grpc", request_type=service.CreateAttestorRequest -): +@pytest.mark.parametrize("request_type", [service.CreateAttestorRequest, dict,]) +def test_create_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1023,10 +1014,6 @@ def test_create_attestor( assert response.description == "description_value" -def test_create_attestor_from_dict(): - test_create_attestor(request_type=dict) - - def test_create_attestor_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. @@ -1231,7 +1218,8 @@ async def test_create_attestor_flattened_error_async(): ) -def test_get_attestor(transport: str = "grpc", request_type=service.GetAttestorRequest): +@pytest.mark.parametrize("request_type", [service.GetAttestorRequest, dict,]) +def test_get_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1263,10 +1251,6 @@ def test_get_attestor(transport: str = "grpc", request_type=service.GetAttestorR assert response.description == "description_value" -def test_get_attestor_from_dict(): - test_get_attestor(request_type=dict) - - def test_get_attestor_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. @@ -1445,9 +1429,8 @@ async def test_get_attestor_flattened_error_async(): ) -def test_update_attestor( - transport: str = "grpc", request_type=service.UpdateAttestorRequest -): +@pytest.mark.parametrize("request_type", [service.UpdateAttestorRequest, dict,]) +def test_update_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1479,10 +1462,6 @@ def test_update_attestor( assert response.description == "description_value" -def test_update_attestor_from_dict(): - test_update_attestor(request_type=dict) - - def test_update_attestor_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. @@ -1669,9 +1648,8 @@ async def test_update_attestor_flattened_error_async(): ) -def test_list_attestors( - transport: str = "grpc", request_type=service.ListAttestorsRequest -): +@pytest.mark.parametrize("request_type", [service.ListAttestorsRequest, dict,]) +def test_list_attestors(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1698,10 +1676,6 @@ def test_list_attestors( assert response.next_page_token == "next_page_token_value" -def test_list_attestors_from_dict(): - test_list_attestors(request_type=dict) - - def test_list_attestors_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. @@ -1883,9 +1857,9 @@ async def test_list_attestors_flattened_error_async(): ) -def test_list_attestors_pager(): +def test_list_attestors_pager(transport_name: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1923,9 +1897,9 @@ def test_list_attestors_pager(): assert all(isinstance(i, resources.Attestor) for i in results) -def test_list_attestors_pages(): +def test_list_attestors_pages(transport_name: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( - credentials=ga_credentials.AnonymousCredentials, + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2029,9 +2003,8 @@ async def test_list_attestors_async_pages(): assert page_.raw_page.next_page_token == token -def test_delete_attestor( - transport: str = "grpc", request_type=service.DeleteAttestorRequest -): +@pytest.mark.parametrize("request_type", [service.DeleteAttestorRequest, dict,]) +def test_delete_attestor(request_type, transport: str = "grpc"): client = BinauthzManagementServiceV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2055,10 +2028,6 @@ def test_delete_attestor( assert response is None -def test_delete_attestor_from_dict(): - test_delete_attestor(request_type=dict) - - def test_delete_attestor_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. @@ -2792,7 +2761,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( diff --git a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py index 9e7dda5c50bf..13f0e4992b67 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py @@ -258,20 +258,20 @@ def test_system_policy_v1_beta1_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, @@ -340,7 +340,7 @@ def test_system_policy_v1_beta1_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 @@ -439,7 +439,7 @@ def test_system_policy_v1_beta1_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, @@ -474,7 +474,7 @@ def test_system_policy_v1_beta1_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", @@ -507,9 +507,8 @@ def test_system_policy_v1_beta1_client_client_options_from_dict(): ) -def test_get_system_policy( - transport: str = "grpc", request_type=service.GetSystemPolicyRequest -): +@pytest.mark.parametrize("request_type", [service.GetSystemPolicyRequest, dict,]) +def test_get_system_policy(request_type, transport: str = "grpc"): client = SystemPolicyV1Beta1Client( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -545,10 +544,6 @@ def test_get_system_policy( ) -def test_get_system_policy_from_dict(): - test_get_system_policy(request_type=dict) - - def test_get_system_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. @@ -1257,7 +1252,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(