diff --git a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/base.py b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/base.py index 4392fb8805f4..60510edd113a 100644 --- a/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/transports/base.py +++ b/packages/google-cloud-access-approval/google/cloud/accessapproval_v1/services/access_approval/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-access-approval/tests/unit/gapic/accessapproval_v1/test_access_approval.py b/packages/google-cloud-access-approval/tests/unit/gapic/accessapproval_v1/test_access_approval.py index 7d6505888086..5a67a5e2ccd4 100644 --- a/packages/google-cloud-access-approval/tests/unit/gapic/accessapproval_v1/test_access_approval.py +++ b/packages/google-cloud-access-approval/tests/unit/gapic/accessapproval_v1/test_access_approval.py @@ -250,20 +250,20 @@ def test_access_approval_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, @@ -322,7 +322,7 @@ def test_access_approval_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 @@ -417,7 +417,7 @@ def test_access_approval_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, @@ -448,7 +448,7 @@ def test_access_approval_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", @@ -481,9 +481,10 @@ def test_access_approval_client_client_options_from_dict(): ) -def test_list_approval_requests( - transport: str = "grpc", request_type=accessapproval.ListApprovalRequestsMessage -): +@pytest.mark.parametrize( + "request_type", [accessapproval.ListApprovalRequestsMessage, dict,] +) +def test_list_approval_requests(request_type, transport: str = "grpc"): client = AccessApprovalClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -512,10 +513,6 @@ def test_list_approval_requests( assert response.next_page_token == "next_page_token_value" -def test_list_approval_requests_from_dict(): - test_list_approval_requests(request_type=dict) - - def test_list_approval_requests_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. @@ -706,8 +703,10 @@ async def test_list_approval_requests_flattened_error_async(): ) -def test_list_approval_requests_pager(): - client = AccessApprovalClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_approval_requests_pager(transport_name: str = "grpc"): + client = AccessApprovalClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -752,8 +751,10 @@ def test_list_approval_requests_pager(): assert all(isinstance(i, accessapproval.ApprovalRequest) for i in results) -def test_list_approval_requests_pages(): - client = AccessApprovalClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_approval_requests_pages(transport_name: str = "grpc"): + client = AccessApprovalClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -876,9 +877,10 @@ async def test_list_approval_requests_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_approval_request( - transport: str = "grpc", request_type=accessapproval.GetApprovalRequestMessage -): +@pytest.mark.parametrize( + "request_type", [accessapproval.GetApprovalRequestMessage, dict,] +) +def test_get_approval_request(request_type, transport: str = "grpc"): client = AccessApprovalClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -912,10 +914,6 @@ def test_get_approval_request( assert response.requested_resource_name == "requested_resource_name_value" -def test_get_approval_request_from_dict(): - test_get_approval_request(request_type=dict) - - def test_get_approval_request_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. @@ -1108,9 +1106,10 @@ async def test_get_approval_request_flattened_error_async(): ) -def test_approve_approval_request( - transport: str = "grpc", request_type=accessapproval.ApproveApprovalRequestMessage -): +@pytest.mark.parametrize( + "request_type", [accessapproval.ApproveApprovalRequestMessage, dict,] +) +def test_approve_approval_request(request_type, transport: str = "grpc"): client = AccessApprovalClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1144,10 +1143,6 @@ def test_approve_approval_request( assert response.requested_resource_name == "requested_resource_name_value" -def test_approve_approval_request_from_dict(): - test_approve_approval_request(request_type=dict) - - def test_approve_approval_request_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. @@ -1264,9 +1259,10 @@ async def test_approve_approval_request_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_dismiss_approval_request( - transport: str = "grpc", request_type=accessapproval.DismissApprovalRequestMessage -): +@pytest.mark.parametrize( + "request_type", [accessapproval.DismissApprovalRequestMessage, dict,] +) +def test_dismiss_approval_request(request_type, transport: str = "grpc"): client = AccessApprovalClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1300,10 +1296,6 @@ def test_dismiss_approval_request( assert response.requested_resource_name == "requested_resource_name_value" -def test_dismiss_approval_request_from_dict(): - test_dismiss_approval_request(request_type=dict) - - def test_dismiss_approval_request_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. @@ -1420,10 +1412,10 @@ async def test_dismiss_approval_request_field_headers_async(): assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] -def test_get_access_approval_settings( - transport: str = "grpc", - request_type=accessapproval.GetAccessApprovalSettingsMessage, -): +@pytest.mark.parametrize( + "request_type", [accessapproval.GetAccessApprovalSettingsMessage, dict,] +) +def test_get_access_approval_settings(request_type, transport: str = "grpc"): client = AccessApprovalClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1456,10 +1448,6 @@ def test_get_access_approval_settings( assert response.enrolled_ancestor is True -def test_get_access_approval_settings_from_dict(): - test_get_access_approval_settings(request_type=dict) - - def test_get_access_approval_settings_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. @@ -1654,10 +1642,10 @@ async def test_get_access_approval_settings_flattened_error_async(): ) -def test_update_access_approval_settings( - transport: str = "grpc", - request_type=accessapproval.UpdateAccessApprovalSettingsMessage, -): +@pytest.mark.parametrize( + "request_type", [accessapproval.UpdateAccessApprovalSettingsMessage, dict,] +) +def test_update_access_approval_settings(request_type, transport: str = "grpc"): client = AccessApprovalClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1690,10 +1678,6 @@ def test_update_access_approval_settings( assert response.enrolled_ancestor is True -def test_update_access_approval_settings_from_dict(): - test_update_access_approval_settings(request_type=dict) - - def test_update_access_approval_settings_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. @@ -1908,10 +1892,10 @@ async def test_update_access_approval_settings_flattened_error_async(): ) -def test_delete_access_approval_settings( - transport: str = "grpc", - request_type=accessapproval.DeleteAccessApprovalSettingsMessage, -): +@pytest.mark.parametrize( + "request_type", [accessapproval.DeleteAccessApprovalSettingsMessage, dict,] +) +def test_delete_access_approval_settings(request_type, transport: str = "grpc"): client = AccessApprovalClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1937,10 +1921,6 @@ def test_delete_access_approval_settings( assert response is None -def test_delete_access_approval_settings_from_dict(): - test_delete_access_approval_settings(request_type=dict) - - def test_delete_access_approval_settings_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. @@ -2618,7 +2598,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(