diff --git a/dataproc/google/cloud/dataproc_v1/gapic/cluster_controller_client.py b/dataproc/google/cloud/dataproc_v1/gapic/cluster_controller_client.py index ac07b5c21294..b897102aab10 100644 --- a/dataproc/google/cloud/dataproc_v1/gapic/cluster_controller_client.py +++ b/dataproc/google/cloud/dataproc_v1/gapic/cluster_controller_client.py @@ -81,7 +81,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=cluster_controller_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -114,13 +114,20 @@ def __init__(self, your own client library. """ # Raise deprecation warnings for things we want to go away. - if client_config: - warnings.warn('The `client_config` argument is deprecated.', - PendingDeprecationWarning) + if client_config is not None: + warnings.warn( + 'The `client_config` argument is deprecated.', + PendingDeprecationWarning, + stacklevel=2) + else: + client_config = cluster_controller_client_config.config + if channel: warnings.warn( 'The `channel` argument is deprecated; use ' - '`transport` instead.', PendingDeprecationWarning) + '`transport` instead.', + PendingDeprecationWarning, + stacklevel=2) # Instantiate the transport. # The transport is responsible for handling serialization and diff --git a/dataproc/google/cloud/dataproc_v1/gapic/enums.py b/dataproc/google/cloud/dataproc_v1/gapic/enums.py index 4cfcd1d34905..3b091b2d5d2a 100644 --- a/dataproc/google/cloud/dataproc_v1/gapic/enums.py +++ b/dataproc/google/cloud/dataproc_v1/gapic/enums.py @@ -18,23 +18,6 @@ import enum -class ClusterOperationStatus(object): - class State(enum.IntEnum): - """ - The operation state. - - Attributes: - UNKNOWN (int): Unused. - PENDING (int): The operation has been created. - RUNNING (int): The operation is running. - DONE (int): The operation is done; either cancelled or completed. - """ - UNKNOWN = 0 - PENDING = 1 - RUNNING = 2 - DONE = 3 - - class ClusterStatus(object): class State(enum.IntEnum): """ diff --git a/dataproc/google/cloud/dataproc_v1/gapic/job_controller_client.py b/dataproc/google/cloud/dataproc_v1/gapic/job_controller_client.py index 728c29cf1e9b..5e9fecc2ddbf 100644 --- a/dataproc/google/cloud/dataproc_v1/gapic/job_controller_client.py +++ b/dataproc/google/cloud/dataproc_v1/gapic/job_controller_client.py @@ -78,7 +78,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=job_controller_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -111,13 +111,20 @@ def __init__(self, your own client library. """ # Raise deprecation warnings for things we want to go away. - if client_config: - warnings.warn('The `client_config` argument is deprecated.', - PendingDeprecationWarning) + if client_config is not None: + warnings.warn( + 'The `client_config` argument is deprecated.', + PendingDeprecationWarning, + stacklevel=2) + else: + client_config = job_controller_client_config.config + if channel: warnings.warn( 'The `channel` argument is deprecated; use ' - '`transport` instead.', PendingDeprecationWarning) + '`transport` instead.', + PendingDeprecationWarning, + stacklevel=2) # Instantiate the transport. # The transport is responsible for handling serialization and diff --git a/dataproc/google/cloud/dataproc_v1/gapic/transports/cluster_controller_grpc_transport.py b/dataproc/google/cloud/dataproc_v1/gapic/transports/cluster_controller_grpc_transport.py index 7cdd05a987a8..c9ce91b99ee0 100644 --- a/dataproc/google/cloud/dataproc_v1/gapic/transports/cluster_controller_grpc_transport.py +++ b/dataproc/google/cloud/dataproc_v1/gapic/transports/cluster_controller_grpc_transport.py @@ -63,6 +63,8 @@ def __init__(self, credentials=credentials, ) + self._channel = channel + # gRPC uses objects called "stubs" that are bound to the # channel and provide a basic method for each RPC. self._stubs = { @@ -99,6 +101,15 @@ def create_channel(cls, scopes=cls._OAUTH_SCOPES, ) + @property + def channel(self): + """The gRPC channel used by the transport. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return self._channel + @property def create_cluster(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/dataproc/google/cloud/dataproc_v1/gapic/transports/job_controller_grpc_transport.py b/dataproc/google/cloud/dataproc_v1/gapic/transports/job_controller_grpc_transport.py index 4985993d21e0..77a8e35d2b9e 100644 --- a/dataproc/google/cloud/dataproc_v1/gapic/transports/job_controller_grpc_transport.py +++ b/dataproc/google/cloud/dataproc_v1/gapic/transports/job_controller_grpc_transport.py @@ -62,6 +62,8 @@ def __init__(self, credentials=credentials, ) + self._channel = channel + # gRPC uses objects called "stubs" that are bound to the # channel and provide a basic method for each RPC. self._stubs = { @@ -91,6 +93,15 @@ def create_channel(cls, scopes=cls._OAUTH_SCOPES, ) + @property + def channel(self): + """The gRPC channel used by the transport. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return self._channel + @property def submit_job(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py b/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py index 2b51643aa46e..55e9b377282c 100644 --- a/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py +++ b/dataproc/google/cloud/dataproc_v1beta2/gapic/cluster_controller_client.py @@ -82,7 +82,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=cluster_controller_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -115,13 +115,20 @@ def __init__(self, your own client library. """ # Raise deprecation warnings for things we want to go away. - if client_config: - warnings.warn('The `client_config` argument is deprecated.', - PendingDeprecationWarning) + if client_config is not None: + warnings.warn( + 'The `client_config` argument is deprecated.', + PendingDeprecationWarning, + stacklevel=2) + else: + client_config = cluster_controller_client_config.config + if channel: warnings.warn( 'The `channel` argument is deprecated; use ' - '`transport` instead.', PendingDeprecationWarning) + '`transport` instead.', + PendingDeprecationWarning, + stacklevel=2) # Instantiate the transport. # The transport is responsible for handling serialization and diff --git a/dataproc/google/cloud/dataproc_v1beta2/gapic/enums.py b/dataproc/google/cloud/dataproc_v1beta2/gapic/enums.py index c1a4de2b21df..f0c10cc2db16 100644 --- a/dataproc/google/cloud/dataproc_v1beta2/gapic/enums.py +++ b/dataproc/google/cloud/dataproc_v1beta2/gapic/enums.py @@ -191,23 +191,6 @@ class JobStateMatcher(enum.IntEnum): NON_ACTIVE = 2 -class ClusterOperationStatus(object): - class State(enum.IntEnum): - """ - The operation state. - - Attributes: - UNKNOWN (int): Unused. - PENDING (int): The operation has been created. - RUNNING (int): The operation is running. - DONE (int): The operation is done; either cancelled or completed. - """ - UNKNOWN = 0 - PENDING = 1 - RUNNING = 2 - DONE = 3 - - class WorkflowMetadata(object): class State(enum.IntEnum): """ diff --git a/dataproc/google/cloud/dataproc_v1beta2/gapic/job_controller_client.py b/dataproc/google/cloud/dataproc_v1beta2/gapic/job_controller_client.py index 0e70dfe5e4bb..6f4f2c360a84 100644 --- a/dataproc/google/cloud/dataproc_v1beta2/gapic/job_controller_client.py +++ b/dataproc/google/cloud/dataproc_v1beta2/gapic/job_controller_client.py @@ -79,7 +79,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=job_controller_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -112,13 +112,20 @@ def __init__(self, your own client library. """ # Raise deprecation warnings for things we want to go away. - if client_config: - warnings.warn('The `client_config` argument is deprecated.', - PendingDeprecationWarning) + if client_config is not None: + warnings.warn( + 'The `client_config` argument is deprecated.', + PendingDeprecationWarning, + stacklevel=2) + else: + client_config = job_controller_client_config.config + if channel: warnings.warn( 'The `channel` argument is deprecated; use ' - '`transport` instead.', PendingDeprecationWarning) + '`transport` instead.', + PendingDeprecationWarning, + stacklevel=2) # Instantiate the transport. # The transport is responsible for handling serialization and diff --git a/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/cluster_controller_grpc_transport.py b/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/cluster_controller_grpc_transport.py index 10a2d0e3c1f7..22bb9da80558 100644 --- a/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/cluster_controller_grpc_transport.py +++ b/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/cluster_controller_grpc_transport.py @@ -63,6 +63,8 @@ def __init__(self, credentials=credentials, ) + self._channel = channel + # gRPC uses objects called "stubs" that are bound to the # channel and provide a basic method for each RPC. self._stubs = { @@ -99,6 +101,15 @@ def create_channel(cls, scopes=cls._OAUTH_SCOPES, ) + @property + def channel(self): + """The gRPC channel used by the transport. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return self._channel + @property def create_cluster(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/job_controller_grpc_transport.py b/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/job_controller_grpc_transport.py index 9d2ab28d3920..ddb242ede88e 100644 --- a/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/job_controller_grpc_transport.py +++ b/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/job_controller_grpc_transport.py @@ -62,6 +62,8 @@ def __init__(self, credentials=credentials, ) + self._channel = channel + # gRPC uses objects called "stubs" that are bound to the # channel and provide a basic method for each RPC. self._stubs = { @@ -91,6 +93,15 @@ def create_channel(cls, scopes=cls._OAUTH_SCOPES, ) + @property + def channel(self): + """The gRPC channel used by the transport. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return self._channel + @property def submit_job(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/workflow_template_service_grpc_transport.py b/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/workflow_template_service_grpc_transport.py index e3da3a473cba..a2f2d2fbffce 100644 --- a/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/workflow_template_service_grpc_transport.py +++ b/dataproc/google/cloud/dataproc_v1beta2/gapic/transports/workflow_template_service_grpc_transport.py @@ -63,6 +63,8 @@ def __init__(self, credentials=credentials, ) + self._channel = channel + # gRPC uses objects called "stubs" that are bound to the # channel and provide a basic method for each RPC. self._stubs = { @@ -99,6 +101,15 @@ def create_channel(cls, scopes=cls._OAUTH_SCOPES, ) + @property + def channel(self): + """The gRPC channel used by the transport. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return self._channel + @property def create_workflow_template(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/dataproc/google/cloud/dataproc_v1beta2/gapic/workflow_template_service_client.py b/dataproc/google/cloud/dataproc_v1beta2/gapic/workflow_template_service_client.py index 4cb746a65464..e46a5d2ac25d 100644 --- a/dataproc/google/cloud/dataproc_v1beta2/gapic/workflow_template_service_client.py +++ b/dataproc/google/cloud/dataproc_v1beta2/gapic/workflow_template_service_client.py @@ -106,7 +106,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=workflow_template_service_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -139,13 +139,20 @@ def __init__(self, your own client library. """ # Raise deprecation warnings for things we want to go away. - if client_config: - warnings.warn('The `client_config` argument is deprecated.', - PendingDeprecationWarning) + if client_config is not None: + warnings.warn( + 'The `client_config` argument is deprecated.', + PendingDeprecationWarning, + stacklevel=2) + else: + client_config = workflow_template_service_client_config.config + if channel: warnings.warn( 'The `channel` argument is deprecated; use ' - '`transport` instead.', PendingDeprecationWarning) + '`transport` instead.', + PendingDeprecationWarning, + stacklevel=2) # Instantiate the transport. # The transport is responsible for handling serialization and diff --git a/dataproc/tests/unit/gapic/v1/test_cluster_controller_client_v1.py b/dataproc/tests/unit/gapic/v1/test_cluster_controller_client_v1.py index 789fdf51cf1e..02e6b0bba2e5 100644 --- a/dataproc/tests/unit/gapic/v1/test_cluster_controller_client_v1.py +++ b/dataproc/tests/unit/gapic/v1/test_cluster_controller_client_v1.py @@ -15,6 +15,7 @@ # limitations under the License. """Unit tests.""" +import mock import pytest from google.rpc import status_pb2 @@ -83,7 +84,10 @@ def test_create_cluster(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -109,7 +113,10 @@ def test_create_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -137,7 +144,10 @@ def test_update_cluster(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -170,7 +180,10 @@ def test_update_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -194,7 +207,10 @@ def test_delete_cluster(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -220,7 +236,10 @@ def test_delete_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -245,7 +264,10 @@ def test_get_cluster(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -264,7 +286,10 @@ def test_get_cluster(self): def test_get_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -288,7 +313,10 @@ def test_list_clusters(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -308,7 +336,10 @@ def test_list_clusters(self): def test_list_clusters_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -328,7 +359,10 @@ def test_diagnose_cluster(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -354,7 +388,10 @@ def test_diagnose_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' diff --git a/dataproc/tests/unit/gapic/v1/test_job_controller_client_v1.py b/dataproc/tests/unit/gapic/v1/test_job_controller_client_v1.py index d738bbe29b6f..87ad50f949fe 100644 --- a/dataproc/tests/unit/gapic/v1/test_job_controller_client_v1.py +++ b/dataproc/tests/unit/gapic/v1/test_job_controller_client_v1.py @@ -15,6 +15,7 @@ # limitations under the License. """Unit tests.""" +import mock import pytest from google.cloud import dataproc_v1 @@ -75,7 +76,10 @@ def test_submit_job(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -94,7 +98,10 @@ def test_submit_job(self): def test_submit_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -116,7 +123,10 @@ def test_get_job(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -135,7 +145,10 @@ def test_get_job(self): def test_get_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -155,7 +168,10 @@ def test_list_jobs(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -175,7 +191,10 @@ def test_list_jobs(self): def test_list_jobs_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -197,7 +216,10 @@ def test_update_job(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -223,7 +245,10 @@ def test_update_job(self): def test_update_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -247,7 +272,10 @@ def test_cancel_job(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -266,7 +294,10 @@ def test_cancel_job(self): def test_cancel_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -278,7 +309,10 @@ def test_cancel_job_exception(self): def test_delete_job(self): channel = ChannelStub() - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -296,7 +330,10 @@ def test_delete_job(self): def test_delete_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1.JobControllerClient() # Setup request project_id = 'projectId-1969970175' diff --git a/dataproc/tests/unit/gapic/v1beta2/test_cluster_controller_client_v1beta2.py b/dataproc/tests/unit/gapic/v1beta2/test_cluster_controller_client_v1beta2.py index bd219ce68142..df756855bb95 100644 --- a/dataproc/tests/unit/gapic/v1beta2/test_cluster_controller_client_v1beta2.py +++ b/dataproc/tests/unit/gapic/v1beta2/test_cluster_controller_client_v1beta2.py @@ -15,6 +15,7 @@ # limitations under the License. """Unit tests.""" +import mock import pytest from google.rpc import status_pb2 @@ -83,7 +84,10 @@ def test_create_cluster(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -109,7 +113,10 @@ def test_create_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -137,7 +144,10 @@ def test_update_cluster(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -170,7 +180,10 @@ def test_update_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -194,7 +207,10 @@ def test_delete_cluster(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -220,7 +236,10 @@ def test_delete_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -245,7 +264,10 @@ def test_get_cluster(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -264,7 +286,10 @@ def test_get_cluster(self): def test_get_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -288,7 +313,10 @@ def test_list_clusters(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -308,7 +336,10 @@ def test_list_clusters(self): def test_list_clusters_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -328,7 +359,10 @@ def test_diagnose_cluster(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -354,7 +388,10 @@ def test_diagnose_cluster_exception(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.ClusterControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.ClusterControllerClient() # Setup Request project_id = 'projectId-1969970175' diff --git a/dataproc/tests/unit/gapic/v1beta2/test_job_controller_client_v1beta2.py b/dataproc/tests/unit/gapic/v1beta2/test_job_controller_client_v1beta2.py index a248ee097365..c3bf4d995121 100644 --- a/dataproc/tests/unit/gapic/v1beta2/test_job_controller_client_v1beta2.py +++ b/dataproc/tests/unit/gapic/v1beta2/test_job_controller_client_v1beta2.py @@ -15,6 +15,7 @@ # limitations under the License. """Unit tests.""" +import mock import pytest from google.cloud import dataproc_v1beta2 @@ -75,7 +76,10 @@ def test_submit_job(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -94,7 +98,10 @@ def test_submit_job(self): def test_submit_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -116,7 +123,10 @@ def test_get_job(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -135,7 +145,10 @@ def test_get_job(self): def test_get_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -155,7 +168,10 @@ def test_list_jobs(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -175,7 +191,10 @@ def test_list_jobs(self): def test_list_jobs_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -197,7 +216,10 @@ def test_update_job(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -223,7 +245,10 @@ def test_update_job(self): def test_update_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -247,7 +272,10 @@ def test_cancel_job(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -266,7 +294,10 @@ def test_cancel_job(self): def test_cancel_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup request project_id = 'projectId-1969970175' @@ -278,7 +309,10 @@ def test_cancel_job_exception(self): def test_delete_job(self): channel = ChannelStub() - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup Request project_id = 'projectId-1969970175' @@ -296,7 +330,10 @@ def test_delete_job(self): def test_delete_job_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.JobControllerClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.JobControllerClient() # Setup request project_id = 'projectId-1969970175' diff --git a/dataproc/tests/unit/gapic/v1beta2/test_workflow_template_service_client_v1beta2.py b/dataproc/tests/unit/gapic/v1beta2/test_workflow_template_service_client_v1beta2.py index ac460952c5a7..ab3de19666fd 100644 --- a/dataproc/tests/unit/gapic/v1beta2/test_workflow_template_service_client_v1beta2.py +++ b/dataproc/tests/unit/gapic/v1beta2/test_workflow_template_service_client_v1beta2.py @@ -15,6 +15,7 @@ # limitations under the License. """Unit tests.""" +import mock import pytest from google.rpc import status_pb2 @@ -76,8 +77,10 @@ def test_create_workflow_template(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup Request parent = client.region_path('[PROJECT]', '[REGION]') @@ -95,8 +98,10 @@ def test_create_workflow_template(self): def test_create_workflow_template_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup request parent = client.region_path('[PROJECT]', '[REGION]') @@ -116,8 +121,10 @@ def test_get_workflow_template(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup Request name = client.workflow_template_path('[PROJECT]', '[REGION]', @@ -135,8 +142,10 @@ def test_get_workflow_template(self): def test_get_workflow_template_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup request name = client.workflow_template_path('[PROJECT]', '[REGION]', @@ -155,8 +164,10 @@ def test_instantiate_workflow_template(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup Request name = client.workflow_template_path('[PROJECT]', '[REGION]', @@ -182,8 +193,10 @@ def test_instantiate_workflow_template_exception(self): # Mock the API response channel = ChannelStub(responses=[operation]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup Request name = client.workflow_template_path('[PROJECT]', '[REGION]', @@ -204,8 +217,10 @@ def test_update_workflow_template(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup Request template = {} @@ -222,8 +237,10 @@ def test_update_workflow_template(self): def test_update_workflow_template_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup request template = {} @@ -245,8 +262,10 @@ def test_list_workflow_templates(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup Request parent = client.region_path('[PROJECT]', '[REGION]') @@ -265,8 +284,10 @@ def test_list_workflow_templates(self): def test_list_workflow_templates_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup request parent = client.region_path('[PROJECT]', '[REGION]') @@ -277,8 +298,10 @@ def test_list_workflow_templates_exception(self): def test_delete_workflow_template(self): channel = ChannelStub() - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup Request name = client.workflow_template_path('[PROJECT]', '[REGION]', @@ -295,8 +318,10 @@ def test_delete_workflow_template(self): def test_delete_workflow_template_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = dataproc_v1beta2.WorkflowTemplateServiceClient( - channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = dataproc_v1beta2.WorkflowTemplateServiceClient() # Setup request name = client.workflow_template_path('[PROJECT]', '[REGION]',