From e2a00aecb1a87d768e1dff74397581919132abfa Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Wed, 14 Nov 2018 05:20:33 -0800 Subject: [PATCH] [CHANGE ME] Re-generated pubsub to pick up changes in the API or client library generator. --- .../cloud/pubsub_v1/gapic/publisher_client.py | 17 +- .../pubsub_v1/gapic/subscriber_client.py | 17 +- .../transports/publisher_grpc_transport.py | 11 ++ .../transports/subscriber_grpc_transport.py | 11 ++ .../unit/gapic/v1/test_publisher_client_v1.py | 101 ++++++++-- .../gapic/v1/test_subscriber_client_v1.py | 181 ++++++++++++++---- 6 files changed, 272 insertions(+), 66 deletions(-) diff --git a/pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py b/pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py index 71e093f22042..9e57c5f4789d 100644 --- a/pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py +++ b/pubsub/google/cloud/pubsub_v1/gapic/publisher_client.py @@ -103,7 +103,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=publisher_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -136,13 +136,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 = publisher_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/pubsub/google/cloud/pubsub_v1/gapic/subscriber_client.py b/pubsub/google/cloud/pubsub_v1/gapic/subscriber_client.py index 0afc9299dd16..7f50e15e8a9c 100644 --- a/pubsub/google/cloud/pubsub_v1/gapic/subscriber_client.py +++ b/pubsub/google/cloud/pubsub_v1/gapic/subscriber_client.py @@ -124,7 +124,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=subscriber_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -157,13 +157,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 = subscriber_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/pubsub/google/cloud/pubsub_v1/gapic/transports/publisher_grpc_transport.py b/pubsub/google/cloud/pubsub_v1/gapic/transports/publisher_grpc_transport.py index 7ce2bca1a552..3353208636bb 100644 --- a/pubsub/google/cloud/pubsub_v1/gapic/transports/publisher_grpc_transport.py +++ b/pubsub/google/cloud/pubsub_v1/gapic/transports/publisher_grpc_transport.py @@ -66,6 +66,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 = { @@ -96,6 +98,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_topic(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/pubsub/google/cloud/pubsub_v1/gapic/transports/subscriber_grpc_transport.py b/pubsub/google/cloud/pubsub_v1/gapic/transports/subscriber_grpc_transport.py index 1455d6c476b4..c2682b5a8f63 100644 --- a/pubsub/google/cloud/pubsub_v1/gapic/transports/subscriber_grpc_transport.py +++ b/pubsub/google/cloud/pubsub_v1/gapic/transports/subscriber_grpc_transport.py @@ -66,6 +66,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 = { @@ -96,6 +98,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_subscription(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/pubsub/tests/unit/gapic/v1/test_publisher_client_v1.py b/pubsub/tests/unit/gapic/v1/test_publisher_client_v1.py index befea7775a4f..feff5f1df72f 100644 --- a/pubsub/tests/unit/gapic/v1/test_publisher_client_v1.py +++ b/pubsub/tests/unit/gapic/v1/test_publisher_client_v1.py @@ -15,6 +15,7 @@ # limitations under the License. """Unit tests.""" +import mock import pytest from google.cloud.pubsub_v1.gapic import publisher_client @@ -73,7 +74,10 @@ def test_create_topic(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request name = client.topic_path('[PROJECT]', '[TOPIC]') @@ -89,7 +93,10 @@ def test_create_topic(self): def test_create_topic_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request name = client.topic_path('[PROJECT]', '[TOPIC]') @@ -105,7 +112,10 @@ def test_update_topic(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request topic = {} @@ -123,7 +133,10 @@ def test_update_topic(self): def test_update_topic_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request topic = {} @@ -141,7 +154,10 @@ def test_publish(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request topic = client.topic_path('[PROJECT]', '[TOPIC]') @@ -161,7 +177,10 @@ def test_publish(self): def test_publish_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request topic = client.topic_path('[PROJECT]', '[TOPIC]') @@ -180,7 +199,10 @@ def test_get_topic(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request topic = client.topic_path('[PROJECT]', '[TOPIC]') @@ -196,7 +218,10 @@ def test_get_topic(self): def test_get_topic_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request topic = client.topic_path('[PROJECT]', '[TOPIC]') @@ -217,7 +242,10 @@ def test_list_topics(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request project = client.project_path('[PROJECT]') @@ -235,7 +263,10 @@ def test_list_topics(self): def test_list_topics_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request project = client.project_path('[PROJECT]') @@ -258,7 +289,10 @@ def test_list_topic_subscriptions(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request topic = client.topic_path('[PROJECT]', '[TOPIC]') @@ -277,7 +311,10 @@ def test_list_topic_subscriptions(self): def test_list_topic_subscriptions_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request topic = client.topic_path('[PROJECT]', '[TOPIC]') @@ -288,7 +325,10 @@ def test_list_topic_subscriptions_exception(self): def test_delete_topic(self): channel = ChannelStub() - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request topic = client.topic_path('[PROJECT]', '[TOPIC]') @@ -303,7 +343,10 @@ def test_delete_topic(self): def test_delete_topic_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request topic = client.topic_path('[PROJECT]', '[TOPIC]') @@ -320,7 +363,10 @@ def test_set_iam_policy(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request resource = client.topic_path('[PROJECT]', '[TOPIC]') @@ -338,7 +384,10 @@ def test_set_iam_policy(self): def test_set_iam_policy_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request resource = client.topic_path('[PROJECT]', '[TOPIC]') @@ -356,7 +405,10 @@ def test_get_iam_policy(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request resource = client.topic_path('[PROJECT]', '[TOPIC]') @@ -373,7 +425,10 @@ def test_get_iam_policy(self): def test_get_iam_policy_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request resource = client.topic_path('[PROJECT]', '[TOPIC]') @@ -389,7 +444,10 @@ def test_test_iam_permissions(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup Request resource = client.topic_path('[PROJECT]', '[TOPIC]') @@ -407,7 +465,10 @@ def test_test_iam_permissions(self): def test_test_iam_permissions_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = publisher_client.PublisherClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = publisher_client.PublisherClient() # Setup request resource = client.topic_path('[PROJECT]', '[TOPIC]') diff --git a/pubsub/tests/unit/gapic/v1/test_subscriber_client_v1.py b/pubsub/tests/unit/gapic/v1/test_subscriber_client_v1.py index 5e1ddc2059e3..aad07e34e45b 100644 --- a/pubsub/tests/unit/gapic/v1/test_subscriber_client_v1.py +++ b/pubsub/tests/unit/gapic/v1/test_subscriber_client_v1.py @@ -15,6 +15,7 @@ # limitations under the License. """Unit tests.""" +import mock import pytest from google.cloud.pubsub_v1.gapic import subscriber_client @@ -88,7 +89,10 @@ def test_create_subscription(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request name = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -105,7 +109,10 @@ def test_create_subscription(self): def test_create_subscription_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request name = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -130,7 +137,10 @@ def test_get_subscription(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -147,7 +157,10 @@ def test_get_subscription(self): def test_get_subscription_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -171,7 +184,10 @@ def test_update_subscription(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request ack_deadline_seconds = 42 @@ -192,7 +208,10 @@ def test_update_subscription(self): def test_update_subscription_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request ack_deadline_seconds = 42 @@ -218,7 +237,10 @@ def test_list_subscriptions(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request project = client.project_path('[PROJECT]') @@ -236,7 +258,10 @@ def test_list_subscriptions(self): def test_list_subscriptions_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request project = client.project_path('[PROJECT]') @@ -247,7 +272,10 @@ def test_list_subscriptions_exception(self): def test_delete_subscription(self): channel = ChannelStub() - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -263,7 +291,10 @@ def test_delete_subscription(self): def test_delete_subscription_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -273,7 +304,10 @@ def test_delete_subscription_exception(self): def test_modify_ack_deadline(self): channel = ChannelStub() - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -293,7 +327,10 @@ def test_modify_ack_deadline(self): def test_modify_ack_deadline_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -306,7 +343,10 @@ def test_modify_ack_deadline_exception(self): def test_acknowledge(self): channel = ChannelStub() - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -323,7 +363,10 @@ def test_acknowledge(self): def test_acknowledge_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -339,7 +382,10 @@ def test_pull(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -357,7 +403,10 @@ def test_pull(self): def test_pull_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -376,7 +425,10 @@ def test_streaming_pull(self): # Mock the API response channel = ChannelStub(responses=[iter([expected_response])]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -402,7 +454,10 @@ def test_streaming_pull(self): def test_streaming_pull_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -420,7 +475,10 @@ def test_streaming_pull_exception(self): def test_modify_push_config(self): channel = ChannelStub() - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -437,7 +495,10 @@ def test_modify_push_config(self): def test_modify_push_config_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -460,7 +521,10 @@ def test_list_snapshots(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request project = client.project_path('[PROJECT]') @@ -478,7 +542,10 @@ def test_list_snapshots(self): def test_list_snapshots_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request project = client.project_path('[PROJECT]') @@ -496,7 +563,10 @@ def test_create_snapshot(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request name = client.snapshot_path('[PROJECT]', '[SNAPSHOT]') @@ -514,7 +584,10 @@ def test_create_snapshot(self): def test_create_snapshot_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request name = client.snapshot_path('[PROJECT]', '[SNAPSHOT]') @@ -532,7 +605,10 @@ def test_update_snapshot(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request seconds = 123456 @@ -554,7 +630,10 @@ def test_update_snapshot(self): def test_update_snapshot_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request seconds = 123456 @@ -569,7 +648,10 @@ def test_update_snapshot_exception(self): def test_delete_snapshot(self): channel = ChannelStub() - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request snapshot = client.snapshot_path('[PROJECT]', '[SNAPSHOT]') @@ -584,7 +666,10 @@ def test_delete_snapshot(self): def test_delete_snapshot_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request snapshot = client.snapshot_path('[PROJECT]', '[SNAPSHOT]') @@ -599,7 +684,10 @@ def test_seek(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -615,7 +703,10 @@ def test_seek(self): def test_seek_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request subscription = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -632,7 +723,10 @@ def test_set_iam_policy(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request resource = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -650,7 +744,10 @@ def test_set_iam_policy(self): def test_set_iam_policy_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request resource = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -668,7 +765,10 @@ def test_get_iam_policy(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request resource = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -685,7 +785,10 @@ def test_get_iam_policy(self): def test_get_iam_policy_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request resource = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -701,7 +804,10 @@ def test_test_iam_permissions(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup Request resource = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]') @@ -719,7 +825,10 @@ def test_test_iam_permissions(self): def test_test_iam_permissions_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = subscriber_client.SubscriberClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = subscriber_client.SubscriberClient() # Setup request resource = client.subscription_path('[PROJECT]', '[SUBSCRIPTION]')