diff --git a/google/cloud/shell_v1/services/cloud_shell_service/transports/base.py b/google/cloud/shell_v1/services/cloud_shell_service/transports/base.py index 98643db..fece65e 100644 --- a/google/cloud/shell_v1/services/cloud_shell_service/transports/base.py +++ b/google/cloud/shell_v1/services/cloud_shell_service/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/tests/unit/gapic/shell_v1/test_cloud_shell_service.py b/tests/unit/gapic/shell_v1/test_cloud_shell_service.py index e318e72..a3198da 100644 --- a/tests/unit/gapic/shell_v1/test_cloud_shell_service.py +++ b/tests/unit/gapic/shell_v1/test_cloud_shell_service.py @@ -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, @@ -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 @@ -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, @@ -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", @@ -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, ) @@ -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. @@ -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, ) @@ -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. @@ -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, ) @@ -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. @@ -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, ) @@ -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. @@ -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, ) @@ -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. @@ -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(