From 74e3f654addb8a5b364d421b7d62130e72473bcb Mon Sep 17 00:00:00 2001 From: yoshi-automation Date: Wed, 14 Nov 2018 05:25:05 -0800 Subject: [PATCH] [CHANGE ME] Re-generated tasks to pick up changes in the API or client library generator. --- .../tasks_v2beta2/gapic/cloud_tasks_client.py | 17 +- .../google/cloud/tasks_v2beta2/gapic/enums.py | 144 ------------- .../transports/cloud_tasks_grpc_transport.py | 11 + .../tasks_v2beta3/gapic/cloud_tasks_client.py | 17 +- .../google/cloud/tasks_v2beta3/gapic/enums.py | 144 ------------- .../transports/cloud_tasks_grpc_transport.py | 11 + .../test_cloud_tasks_client_v2beta2.py | 201 ++++++++++++++---- .../test_cloud_tasks_client_v2beta3.py | 161 +++++++++++--- 8 files changed, 336 insertions(+), 370 deletions(-) diff --git a/tasks/google/cloud/tasks_v2beta2/gapic/cloud_tasks_client.py b/tasks/google/cloud/tasks_v2beta2/gapic/cloud_tasks_client.py index 4f8d8ac95ed6..3199c1a954bc 100644 --- a/tasks/google/cloud/tasks_v2beta2/gapic/cloud_tasks_client.py +++ b/tasks/google/cloud/tasks_v2beta2/gapic/cloud_tasks_client.py @@ -123,7 +123,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=cloud_tasks_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -156,13 +156,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 = cloud_tasks_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/tasks/google/cloud/tasks_v2beta2/gapic/enums.py b/tasks/google/cloud/tasks_v2beta2/gapic/enums.py index 41a40a78fb15..8bfbd09cf76b 100644 --- a/tasks/google/cloud/tasks_v2beta2/gapic/enums.py +++ b/tasks/google/cloud/tasks_v2beta2/gapic/enums.py @@ -38,150 +38,6 @@ class HttpMethod(enum.IntEnum): DELETE = 5 -class Code(enum.IntEnum): - """ - The canonical error codes for Google APIs. - - Sometimes multiple error codes may apply. Services should return the - most specific error code that applies. For example, prefer - ``OUT_OF_RANGE`` over ``FAILED_PRECONDITION`` if both codes apply. - Similarly prefer ``NOT_FOUND`` or ``ALREADY_EXISTS`` over - ``FAILED_PRECONDITION``. - - Attributes: - OK (int): Not an error; returned on success - - HTTP Mapping: 200 OK - CANCELLED (int): The operation was cancelled, typically by the caller. - - HTTP Mapping: 499 Client Closed Request - UNKNOWN (int): Unknown error. For example, this error may be returned when a ``Status`` - value received from another address space belongs to an error space that - is not known in this address space. Also errors raised by APIs that do - not return enough error information may be converted to this error. - - HTTP Mapping: 500 Internal Server Error - INVALID_ARGUMENT (int): The client specified an invalid argument. Note that this differs from - ``FAILED_PRECONDITION``. ``INVALID_ARGUMENT`` indicates arguments that - are problematic regardless of the state of the system (e.g., a malformed - file name). - - HTTP Mapping: 400 Bad Request - DEADLINE_EXCEEDED (int): The deadline expired before the operation could complete. For operations - that change the state of the system, this error may be returned - even if the operation has completed successfully. For example, a - successful response from a server could have been delayed long - enough for the deadline to expire. - - HTTP Mapping: 504 Gateway Timeout - NOT_FOUND (int): Some requested entity (e.g., file or directory) was not found. - - Note to server developers: if a request is denied for an entire class of - users, such as gradual feature rollout or undocumented whitelist, - ``NOT_FOUND`` may be used. If a request is denied for some users within - a class of users, such as user-based access control, - ``PERMISSION_DENIED`` must be used. - - HTTP Mapping: 404 Not Found - ALREADY_EXISTS (int): The entity that a client attempted to create (e.g., file or directory) - already exists. - - HTTP Mapping: 409 Conflict - PERMISSION_DENIED (int): The caller does not have permission to execute the specified operation. - ``PERMISSION_DENIED`` must not be used for rejections caused by - exhausting some resource (use ``RESOURCE_EXHAUSTED`` instead for those - errors). ``PERMISSION_DENIED`` must not be used if the caller can not be - identified (use ``UNAUTHENTICATED`` instead for those errors). This - error code does not imply the request is valid or the requested entity - exists or satisfies other pre-conditions. - - HTTP Mapping: 403 Forbidden - UNAUTHENTICATED (int): The request does not have valid authentication credentials for the - operation. - - HTTP Mapping: 401 Unauthorized - RESOURCE_EXHAUSTED (int): Some resource has been exhausted, perhaps a per-user quota, or - perhaps the entire file system is out of space. - - HTTP Mapping: 429 Too Many Requests - FAILED_PRECONDITION (int): The operation was rejected because the system is not in a state required - for the operation's execution. For example, the directory to be deleted - is non-empty, an rmdir operation is applied to a non-directory, etc. - - Service implementors can use the following guidelines to decide between - ``FAILED_PRECONDITION``, ``ABORTED``, and ``UNAVAILABLE``: (a) Use - ``UNAVAILABLE`` if the client can retry just the failing call. (b) Use - ``ABORTED`` if the client should retry at a higher level (e.g., when a - client-specified test-and-set fails, indicating the client should - restart a read-modify-write sequence). (c) Use ``FAILED_PRECONDITION`` - if the client should not retry until the system state has been - explicitly fixed. E.g., if an "rmdir" fails because the directory is - non-empty, ``FAILED_PRECONDITION`` should be returned since the client - should not retry unless the files are deleted from the directory. - - HTTP Mapping: 400 Bad Request - ABORTED (int): The operation was aborted, typically due to a concurrency issue such as - a sequencer check failure or transaction abort. - - See the guidelines above for deciding between ``FAILED_PRECONDITION``, - ``ABORTED``, and ``UNAVAILABLE``. - - HTTP Mapping: 409 Conflict - OUT_OF_RANGE (int): The operation was attempted past the valid range. E.g., seeking or - reading past end-of-file. - - Unlike ``INVALID_ARGUMENT``, this error indicates a problem that may be - fixed if the system state changes. For example, a 32-bit file system - will generate ``INVALID_ARGUMENT`` if asked to read at an offset that is - not in the range [0,2^32-1], but it will generate ``OUT_OF_RANGE`` if - asked to read from an offset past the current file size. - - There is a fair bit of overlap between ``FAILED_PRECONDITION`` and - ``OUT_OF_RANGE``. We recommend using ``OUT_OF_RANGE`` (the more specific - error) when it applies so that callers who are iterating through a space - can easily look for an ``OUT_OF_RANGE`` error to detect when they are - done. - - HTTP Mapping: 400 Bad Request - UNIMPLEMENTED (int): The operation is not implemented or is not supported/enabled in this - service. - - HTTP Mapping: 501 Not Implemented - INTERNAL (int): Internal errors. This means that some invariants expected by the - underlying system have been broken. This error code is reserved - for serious errors. - - HTTP Mapping: 500 Internal Server Error - UNAVAILABLE (int): The service is currently unavailable. This is most likely a transient - condition, which can be corrected by retrying with a backoff. - - See the guidelines above for deciding between ``FAILED_PRECONDITION``, - ``ABORTED``, and ``UNAVAILABLE``. - - HTTP Mapping: 503 Service Unavailable - DATA_LOSS (int): Unrecoverable data loss or corruption. - - HTTP Mapping: 500 Internal Server Error - """ - OK = 0 - CANCELLED = 1 - UNKNOWN = 2 - INVALID_ARGUMENT = 3 - DEADLINE_EXCEEDED = 4 - NOT_FOUND = 5 - ALREADY_EXISTS = 6 - PERMISSION_DENIED = 7 - UNAUTHENTICATED = 16 - RESOURCE_EXHAUSTED = 8 - FAILED_PRECONDITION = 9 - ABORTED = 10 - OUT_OF_RANGE = 11 - UNIMPLEMENTED = 12 - INTERNAL = 13 - UNAVAILABLE = 14 - DATA_LOSS = 15 - - class Queue(object): class State(enum.IntEnum): """ diff --git a/tasks/google/cloud/tasks_v2beta2/gapic/transports/cloud_tasks_grpc_transport.py b/tasks/google/cloud/tasks_v2beta2/gapic/transports/cloud_tasks_grpc_transport.py index 8e507172484a..48e9819bd635 100644 --- a/tasks/google/cloud/tasks_v2beta2/gapic/transports/cloud_tasks_grpc_transport.py +++ b/tasks/google/cloud/tasks_v2beta2/gapic/transports/cloud_tasks_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 list_queues(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/tasks/google/cloud/tasks_v2beta3/gapic/cloud_tasks_client.py b/tasks/google/cloud/tasks_v2beta3/gapic/cloud_tasks_client.py index e62e2eb70cee..94ab7786b4ea 100644 --- a/tasks/google/cloud/tasks_v2beta3/gapic/cloud_tasks_client.py +++ b/tasks/google/cloud/tasks_v2beta3/gapic/cloud_tasks_client.py @@ -121,7 +121,7 @@ def __init__(self, transport=None, channel=None, credentials=None, - client_config=cloud_tasks_client_config.config, + client_config=None, client_info=None): """Constructor. @@ -154,13 +154,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 = cloud_tasks_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/tasks/google/cloud/tasks_v2beta3/gapic/enums.py b/tasks/google/cloud/tasks_v2beta3/gapic/enums.py index ffcd4c8a67e8..1651d5a0cec5 100644 --- a/tasks/google/cloud/tasks_v2beta3/gapic/enums.py +++ b/tasks/google/cloud/tasks_v2beta3/gapic/enums.py @@ -38,150 +38,6 @@ class HttpMethod(enum.IntEnum): DELETE = 5 -class Code(enum.IntEnum): - """ - The canonical error codes for Google APIs. - - Sometimes multiple error codes may apply. Services should return the - most specific error code that applies. For example, prefer - ``OUT_OF_RANGE`` over ``FAILED_PRECONDITION`` if both codes apply. - Similarly prefer ``NOT_FOUND`` or ``ALREADY_EXISTS`` over - ``FAILED_PRECONDITION``. - - Attributes: - OK (int): Not an error; returned on success - - HTTP Mapping: 200 OK - CANCELLED (int): The operation was cancelled, typically by the caller. - - HTTP Mapping: 499 Client Closed Request - UNKNOWN (int): Unknown error. For example, this error may be returned when a ``Status`` - value received from another address space belongs to an error space that - is not known in this address space. Also errors raised by APIs that do - not return enough error information may be converted to this error. - - HTTP Mapping: 500 Internal Server Error - INVALID_ARGUMENT (int): The client specified an invalid argument. Note that this differs from - ``FAILED_PRECONDITION``. ``INVALID_ARGUMENT`` indicates arguments that - are problematic regardless of the state of the system (e.g., a malformed - file name). - - HTTP Mapping: 400 Bad Request - DEADLINE_EXCEEDED (int): The deadline expired before the operation could complete. For operations - that change the state of the system, this error may be returned - even if the operation has completed successfully. For example, a - successful response from a server could have been delayed long - enough for the deadline to expire. - - HTTP Mapping: 504 Gateway Timeout - NOT_FOUND (int): Some requested entity (e.g., file or directory) was not found. - - Note to server developers: if a request is denied for an entire class of - users, such as gradual feature rollout or undocumented whitelist, - ``NOT_FOUND`` may be used. If a request is denied for some users within - a class of users, such as user-based access control, - ``PERMISSION_DENIED`` must be used. - - HTTP Mapping: 404 Not Found - ALREADY_EXISTS (int): The entity that a client attempted to create (e.g., file or directory) - already exists. - - HTTP Mapping: 409 Conflict - PERMISSION_DENIED (int): The caller does not have permission to execute the specified operation. - ``PERMISSION_DENIED`` must not be used for rejections caused by - exhausting some resource (use ``RESOURCE_EXHAUSTED`` instead for those - errors). ``PERMISSION_DENIED`` must not be used if the caller can not be - identified (use ``UNAUTHENTICATED`` instead for those errors). This - error code does not imply the request is valid or the requested entity - exists or satisfies other pre-conditions. - - HTTP Mapping: 403 Forbidden - UNAUTHENTICATED (int): The request does not have valid authentication credentials for the - operation. - - HTTP Mapping: 401 Unauthorized - RESOURCE_EXHAUSTED (int): Some resource has been exhausted, perhaps a per-user quota, or - perhaps the entire file system is out of space. - - HTTP Mapping: 429 Too Many Requests - FAILED_PRECONDITION (int): The operation was rejected because the system is not in a state required - for the operation's execution. For example, the directory to be deleted - is non-empty, an rmdir operation is applied to a non-directory, etc. - - Service implementors can use the following guidelines to decide between - ``FAILED_PRECONDITION``, ``ABORTED``, and ``UNAVAILABLE``: (a) Use - ``UNAVAILABLE`` if the client can retry just the failing call. (b) Use - ``ABORTED`` if the client should retry at a higher level (e.g., when a - client-specified test-and-set fails, indicating the client should - restart a read-modify-write sequence). (c) Use ``FAILED_PRECONDITION`` - if the client should not retry until the system state has been - explicitly fixed. E.g., if an "rmdir" fails because the directory is - non-empty, ``FAILED_PRECONDITION`` should be returned since the client - should not retry unless the files are deleted from the directory. - - HTTP Mapping: 400 Bad Request - ABORTED (int): The operation was aborted, typically due to a concurrency issue such as - a sequencer check failure or transaction abort. - - See the guidelines above for deciding between ``FAILED_PRECONDITION``, - ``ABORTED``, and ``UNAVAILABLE``. - - HTTP Mapping: 409 Conflict - OUT_OF_RANGE (int): The operation was attempted past the valid range. E.g., seeking or - reading past end-of-file. - - Unlike ``INVALID_ARGUMENT``, this error indicates a problem that may be - fixed if the system state changes. For example, a 32-bit file system - will generate ``INVALID_ARGUMENT`` if asked to read at an offset that is - not in the range [0,2^32-1], but it will generate ``OUT_OF_RANGE`` if - asked to read from an offset past the current file size. - - There is a fair bit of overlap between ``FAILED_PRECONDITION`` and - ``OUT_OF_RANGE``. We recommend using ``OUT_OF_RANGE`` (the more specific - error) when it applies so that callers who are iterating through a space - can easily look for an ``OUT_OF_RANGE`` error to detect when they are - done. - - HTTP Mapping: 400 Bad Request - UNIMPLEMENTED (int): The operation is not implemented or is not supported/enabled in this - service. - - HTTP Mapping: 501 Not Implemented - INTERNAL (int): Internal errors. This means that some invariants expected by the - underlying system have been broken. This error code is reserved - for serious errors. - - HTTP Mapping: 500 Internal Server Error - UNAVAILABLE (int): The service is currently unavailable. This is most likely a transient - condition, which can be corrected by retrying with a backoff. - - See the guidelines above for deciding between ``FAILED_PRECONDITION``, - ``ABORTED``, and ``UNAVAILABLE``. - - HTTP Mapping: 503 Service Unavailable - DATA_LOSS (int): Unrecoverable data loss or corruption. - - HTTP Mapping: 500 Internal Server Error - """ - OK = 0 - CANCELLED = 1 - UNKNOWN = 2 - INVALID_ARGUMENT = 3 - DEADLINE_EXCEEDED = 4 - NOT_FOUND = 5 - ALREADY_EXISTS = 6 - PERMISSION_DENIED = 7 - UNAUTHENTICATED = 16 - RESOURCE_EXHAUSTED = 8 - FAILED_PRECONDITION = 9 - ABORTED = 10 - OUT_OF_RANGE = 11 - UNIMPLEMENTED = 12 - INTERNAL = 13 - UNAVAILABLE = 14 - DATA_LOSS = 15 - - class Queue(object): class State(enum.IntEnum): """ diff --git a/tasks/google/cloud/tasks_v2beta3/gapic/transports/cloud_tasks_grpc_transport.py b/tasks/google/cloud/tasks_v2beta3/gapic/transports/cloud_tasks_grpc_transport.py index 6ed8ec46e0fc..6efcb26ec89d 100644 --- a/tasks/google/cloud/tasks_v2beta3/gapic/transports/cloud_tasks_grpc_transport.py +++ b/tasks/google/cloud/tasks_v2beta3/gapic/transports/cloud_tasks_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 list_queues(self): """Return the gRPC stub for {$apiMethod.name}. diff --git a/tasks/tests/unit/gapic/v2beta2/test_cloud_tasks_client_v2beta2.py b/tasks/tests/unit/gapic/v2beta2/test_cloud_tasks_client_v2beta2.py index 59407a23f742..2e2d6d62561f 100644 --- a/tasks/tests/unit/gapic/v2beta2/test_cloud_tasks_client_v2beta2.py +++ b/tasks/tests/unit/gapic/v2beta2/test_cloud_tasks_client_v2beta2.py @@ -15,6 +15,7 @@ # limitations under the License. """Unit tests.""" +import mock import pytest from google.cloud import tasks_v2beta2 @@ -82,7 +83,10 @@ def test_list_queues(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request parent = client.location_path('[PROJECT]', '[LOCATION]') @@ -100,7 +104,10 @@ def test_list_queues(self): def test_list_queues_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request parent = client.location_path('[PROJECT]', '[LOCATION]') @@ -117,7 +124,10 @@ def test_get_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -133,7 +143,10 @@ def test_get_queue(self): def test_get_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -149,7 +162,10 @@ def test_create_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request parent = client.location_path('[PROJECT]', '[LOCATION]') @@ -167,7 +183,10 @@ def test_create_queue(self): def test_create_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request parent = client.location_path('[PROJECT]', '[LOCATION]') @@ -184,7 +203,10 @@ def test_update_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request queue = {} @@ -200,7 +222,10 @@ def test_update_queue(self): def test_update_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request queue = {} @@ -210,7 +235,10 @@ def test_update_queue_exception(self): def test_delete_queue(self): channel = ChannelStub() - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -225,7 +253,10 @@ def test_delete_queue(self): def test_delete_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -241,7 +272,10 @@ def test_purge_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -257,7 +291,10 @@ def test_purge_queue(self): def test_purge_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -273,7 +310,10 @@ def test_pause_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -289,7 +329,10 @@ def test_pause_queue(self): def test_pause_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -305,7 +348,10 @@ def test_resume_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -321,7 +367,10 @@ def test_resume_queue(self): def test_resume_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -338,7 +387,10 @@ def test_get_iam_policy(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -355,7 +407,10 @@ def test_get_iam_policy(self): def test_get_iam_policy_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -372,7 +427,10 @@ def test_set_iam_policy(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -390,7 +448,10 @@ def test_set_iam_policy(self): def test_set_iam_policy_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -407,7 +468,10 @@ def test_test_iam_permissions(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -425,7 +489,10 @@ def test_test_iam_permissions(self): def test_test_iam_permissions_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -448,7 +515,10 @@ def test_list_tasks(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -466,7 +536,10 @@ def test_list_tasks(self): def test_list_tasks_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -483,7 +556,10 @@ def test_get_task(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -499,7 +575,10 @@ def test_get_task(self): def test_get_task_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -515,7 +594,10 @@ def test_create_task(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -533,7 +615,10 @@ def test_create_task(self): def test_create_task_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -544,7 +629,10 @@ def test_create_task_exception(self): def test_delete_task(self): channel = ChannelStub() - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -559,7 +647,10 @@ def test_delete_task(self): def test_delete_task_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -575,7 +666,10 @@ def test_lease_tasks(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -593,7 +687,10 @@ def test_lease_tasks(self): def test_lease_tasks_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -604,7 +701,10 @@ def test_lease_tasks_exception(self): def test_acknowledge_task(self): channel = ChannelStub() - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -621,7 +721,10 @@ def test_acknowledge_task(self): def test_acknowledge_task_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -638,7 +741,10 @@ def test_renew_lease(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -659,7 +765,10 @@ def test_renew_lease(self): def test_renew_lease_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -677,7 +786,10 @@ def test_cancel_lease(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -695,7 +807,10 @@ def test_cancel_lease(self): def test_cancel_lease_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -712,7 +827,10 @@ def test_run_task(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup Request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -728,7 +846,10 @@ def test_run_task(self): def test_run_task_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta2.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta2.CloudTasksClient() # Setup request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') diff --git a/tasks/tests/unit/gapic/v2beta3/test_cloud_tasks_client_v2beta3.py b/tasks/tests/unit/gapic/v2beta3/test_cloud_tasks_client_v2beta3.py index 05c6cff8fd0b..5dd598600bde 100644 --- a/tasks/tests/unit/gapic/v2beta3/test_cloud_tasks_client_v2beta3.py +++ b/tasks/tests/unit/gapic/v2beta3/test_cloud_tasks_client_v2beta3.py @@ -15,6 +15,7 @@ # limitations under the License. """Unit tests.""" +import mock import pytest from google.cloud import tasks_v2beta3 @@ -80,7 +81,10 @@ def test_list_queues(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request parent = client.location_path('[PROJECT]', '[LOCATION]') @@ -98,7 +102,10 @@ def test_list_queues(self): def test_list_queues_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request parent = client.location_path('[PROJECT]', '[LOCATION]') @@ -115,7 +122,10 @@ def test_get_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -131,7 +141,10 @@ def test_get_queue(self): def test_get_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -147,7 +160,10 @@ def test_create_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request parent = client.location_path('[PROJECT]', '[LOCATION]') @@ -165,7 +181,10 @@ def test_create_queue(self): def test_create_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request parent = client.location_path('[PROJECT]', '[LOCATION]') @@ -182,7 +201,10 @@ def test_update_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request queue = {} @@ -198,7 +220,10 @@ def test_update_queue(self): def test_update_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request queue = {} @@ -208,7 +233,10 @@ def test_update_queue_exception(self): def test_delete_queue(self): channel = ChannelStub() - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -223,7 +251,10 @@ def test_delete_queue(self): def test_delete_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -239,7 +270,10 @@ def test_purge_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -255,7 +289,10 @@ def test_purge_queue(self): def test_purge_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -271,7 +308,10 @@ def test_pause_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -287,7 +327,10 @@ def test_pause_queue(self): def test_pause_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -303,7 +346,10 @@ def test_resume_queue(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -319,7 +365,10 @@ def test_resume_queue(self): def test_resume_queue_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -336,7 +385,10 @@ def test_get_iam_policy(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -353,7 +405,10 @@ def test_get_iam_policy(self): def test_get_iam_policy_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -370,7 +425,10 @@ def test_set_iam_policy(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -388,7 +446,10 @@ def test_set_iam_policy(self): def test_set_iam_policy_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -405,7 +466,10 @@ def test_test_iam_permissions(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -423,7 +487,10 @@ def test_test_iam_permissions(self): def test_test_iam_permissions_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -446,7 +513,10 @@ def test_list_tasks(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -464,7 +534,10 @@ def test_list_tasks(self): def test_list_tasks_exception(self): channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -487,7 +560,10 @@ def test_get_task(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -503,7 +579,10 @@ def test_get_task(self): def test_get_task_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -525,7 +604,10 @@ def test_create_task(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -543,7 +625,10 @@ def test_create_task(self): def test_create_task_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') @@ -554,7 +639,10 @@ def test_create_task_exception(self): def test_delete_task(self): channel = ChannelStub() - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -569,7 +657,10 @@ def test_delete_task(self): def test_delete_task_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -591,7 +682,10 @@ def test_run_task(self): # Mock the API response channel = ChannelStub(responses=[expected_response]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup Request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') @@ -607,7 +701,10 @@ def test_run_task(self): def test_run_task_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - client = tasks_v2beta3.CloudTasksClient(channel=channel) + patch = mock.patch('google.api_core.grpc_helpers.create_channel') + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2beta3.CloudTasksClient() # Setup request name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]')