From b9e14d35ca92ec579982096b2cf7a4ea0bb286cd Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Mon, 28 Mar 2022 23:38:47 +0000 Subject: [PATCH] chore(python): use black==22.3.0 Source-Link: https://github.com/googleapis/synthtool/commit/6fab84af09f2cf89a031fd8671d1def6b2931b11 Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 13 +- .../pubsub_v1/publisher/_sequencer/base.py | 12 +- .../publisher/_sequencer/ordered_sequencer.py | 72 +- .../_sequencer/unordered_sequencer.py | 34 +- google/cloud/pubsub_v1/publisher/client.py | 25 +- .../cloud/pubsub_v1/publisher/exceptions.py | 8 +- .../subscriber/_protocol/dispatcher.py | 4 +- .../subscriber/_protocol/heartbeater.py | 3 +- .../subscriber/_protocol/histogram.py | 3 +- .../subscriber/_protocol/messages_on_hold.py | 5 +- .../_protocol/streaming_pull_manager.py | 8 +- .../services/publisher/async_client.py | 97 +- google/pubsub_v1/services/publisher/client.py | 164 ++- .../services/publisher/transports/base.py | 6 +- .../services/publisher/transports/grpc.py | 3 +- .../services/schema_service/async_client.py | 66 +- .../services/schema_service/client.py | 115 +- .../schema_service/transports/base.py | 30 +- .../schema_service/transports/grpc.py | 3 +- .../services/subscriber/async_client.py | 133 +- .../pubsub_v1/services/subscriber/client.py | 200 ++- .../services/subscriber/transports/base.py | 6 +- .../services/subscriber/transports/grpc.py | 3 +- google/pubsub_v1/types/pubsub.py | 628 ++++++-- google/pubsub_v1/types/schema.py | 124 +- noxfile.py | 12 +- samples/snippets/noxfile.py | 2 +- tests/system.py | 2 +- tests/unit/gapic/pubsub_v1/test_publisher.py | 1099 ++++++++++---- .../gapic/pubsub_v1/test_schema_service.py | 552 +++++-- tests/unit/gapic/pubsub_v1/test_subscriber.py | 1281 ++++++++++++----- .../sequencer/test_ordered_sequencer.py | 2 +- .../sequencer/test_unordered_sequencer.py | 2 +- .../publisher/test_publisher_client.py | 2 +- .../pubsub_v1/subscriber/test_dispatcher.py | 16 +- 36 files changed, 3618 insertions(+), 1119 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7cc..87dd00611 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,4 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:7cffbc10910c3ab1b852c05114a08d374c195a81cdec1d4a67a1d129331d0bfe diff --git a/docs/conf.py b/docs/conf.py index 34fa14a84..9245a8edf 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -314,7 +314,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (root_doc, "google-cloud-pubsub", "google-cloud-pubsub Documentation", [author], 1,) + ( + root_doc, + "google-cloud-pubsub", + "google-cloud-pubsub Documentation", + [author], + 1, + ) ] # If true, show URL addresses after external links. @@ -355,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/pubsub_v1/publisher/_sequencer/base.py b/google/cloud/pubsub_v1/publisher/_sequencer/base.py index 7a0c28e45..58ec5a571 100644 --- a/google/cloud/pubsub_v1/publisher/_sequencer/base.py +++ b/google/cloud/pubsub_v1/publisher/_sequencer/base.py @@ -27,21 +27,21 @@ class Sequencer(metaclass=abc.ABCMeta): """The base class for sequencers for Pub/Sub publishing. A sequencer - sequences messages to be published. + sequences messages to be published. """ @abc.abstractmethod def is_finished(self) -> bool: # pragma: NO COVER - """ Whether the sequencer is finished and should be cleaned up. + """Whether the sequencer is finished and should be cleaned up. - Returns: - bool: Whether the sequencer is finished and should be cleaned up. + Returns: + bool: Whether the sequencer is finished and should be cleaned up. """ raise NotImplementedError @abc.abstractmethod def unpause(self) -> None: # pragma: NO COVER - """ Unpauses this sequencer. + """Unpauses this sequencer. Raises: RuntimeError: @@ -56,7 +56,7 @@ def publish( retry: "OptionalRetry" = gapic_v1.method.DEFAULT, timeout: gapic_types.TimeoutType = gapic_v1.method.DEFAULT, ) -> "futures.Future": # pragma: NO COVER - """ Publish message for this ordering key. + """Publish message for this ordering key. Args: message: diff --git a/google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py b/google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py index 4d44b1a4f..30c76a44f 100644 --- a/google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py +++ b/google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py @@ -76,21 +76,21 @@ class _OrderedSequencerStatus(str, enum.Enum): class OrderedSequencer(sequencer_base.Sequencer): - """ Sequences messages into batches ordered by an ordering key for one topic. + """Sequences messages into batches ordered by an ordering key for one topic. - A sequencer always has at least one batch in it, unless paused or stopped. - When no batches remain, the |publishes_done_callback| is called so the - client can perform cleanup. + A sequencer always has at least one batch in it, unless paused or stopped. + When no batches remain, the |publishes_done_callback| is called so the + client can perform cleanup. - Public methods are thread-safe. + Public methods are thread-safe. - Args: - client: - The publisher client used to create this sequencer. - topic: - The topic. The format for this is ``projects/{project}/topics/{topic}``. - ordering_key: - The ordering key for this sequencer. + Args: + client: + The publisher client used to create this sequencer. + topic: + The topic. The format for this is ``projects/{project}/topics/{topic}``. + ordering_key: + The ordering key for this sequencer. """ def __init__(self, client: "PublisherClient", topic: str, ordering_key: str): @@ -107,23 +107,23 @@ def __init__(self, client: "PublisherClient", topic: str, ordering_key: str): self._state = _OrderedSequencerStatus.ACCEPTING_MESSAGES def is_finished(self) -> bool: - """ Whether the sequencer is finished and should be cleaned up. + """Whether the sequencer is finished and should be cleaned up. - Returns: - Whether the sequencer is finished and should be cleaned up. + Returns: + Whether the sequencer is finished and should be cleaned up. """ with self._state_lock: return self._state == _OrderedSequencerStatus.FINISHED def stop(self) -> None: - """ Permanently stop this sequencer. + """Permanently stop this sequencer. - This differs from pausing, which may be resumed. Immediately commits - the first batch and cancels the rest. + This differs from pausing, which may be resumed. Immediately commits + the first batch and cancels the rest. - Raises: - RuntimeError: - If called after stop() has already been called. + Raises: + RuntimeError: + If called after stop() has already been called. """ with self._state_lock: if self._state == _OrderedSequencerStatus.STOPPED: @@ -143,13 +143,13 @@ def stop(self) -> None: batch.cancel(batch_base.BatchCancellationReason.CLIENT_STOPPED) def commit(self) -> None: - """ Commit the first batch, if unpaused. + """Commit the first batch, if unpaused. - If paused or no batches exist, this method does nothing. + If paused or no batches exist, this method does nothing. - Raises: - RuntimeError: - If called after stop() has already been called. + Raises: + RuntimeError: + If called after stop() has already been called. """ with self._state_lock: if self._state == _OrderedSequencerStatus.STOPPED: @@ -161,11 +161,11 @@ def commit(self) -> None: self._ordered_batches[0].commit() def _batch_done_callback(self, success: bool) -> None: - """ Deal with completion of a batch. + """Deal with completion of a batch. - Called when a batch has finished publishing, with either a success - or a failure. (Temporary failures are retried infinitely when - ordering keys are enabled.) + Called when a batch has finished publishing, with either a success + or a failure. (Temporary failures are retried infinitely when + ordering keys are enabled.) """ ensure_cleanup_and_commit_timer_runs = False with self._state_lock: @@ -209,10 +209,10 @@ def _batch_done_callback(self, success: bool) -> None: self._client.ensure_cleanup_and_commit_timer_runs() def _pause(self) -> None: - """ Pause this sequencer: set state to paused, cancel all batches, and - clear the list of ordered batches. + """Pause this sequencer: set state to paused, cancel all batches, and + clear the list of ordered batches. - _state_lock must be taken before calling this method. + _state_lock must be taken before calling this method. """ assert ( self._state != _OrderedSequencerStatus.FINISHED @@ -225,7 +225,7 @@ def _pause(self) -> None: self._ordered_batches.clear() def unpause(self) -> None: - """ Unpause this sequencer. + """Unpause this sequencer. Raises: RuntimeError: @@ -241,7 +241,7 @@ def _create_batch( commit_retry: "OptionalRetry" = gapic_v1.method.DEFAULT, commit_timeout: "types.OptionalTimeout" = gapic_v1.method.DEFAULT, ) -> "_batch.thread.Batch": - """ Create a new batch using the client's batch class and other stored + """Create a new batch using the client's batch class and other stored settings. Args: @@ -266,7 +266,7 @@ def publish( retry: "OptionalRetry" = gapic_v1.method.DEFAULT, timeout: "types.OptionalTimeout" = gapic_v1.method.DEFAULT, ) -> futures.Future: - """ Publish message for this ordering key. + """Publish message for this ordering key. Args: message: diff --git a/google/cloud/pubsub_v1/publisher/_sequencer/unordered_sequencer.py b/google/cloud/pubsub_v1/publisher/_sequencer/unordered_sequencer.py index 7f2f13610..7d57aa821 100644 --- a/google/cloud/pubsub_v1/publisher/_sequencer/unordered_sequencer.py +++ b/google/cloud/pubsub_v1/publisher/_sequencer/unordered_sequencer.py @@ -30,9 +30,9 @@ class UnorderedSequencer(base.Sequencer): - """ Sequences messages into batches for one topic without any ordering. + """Sequences messages into batches for one topic without any ordering. - Public methods are NOT thread-safe. + Public methods are NOT thread-safe. """ def __init__(self, client: "PublisherClient", topic: str): @@ -42,10 +42,10 @@ def __init__(self, client: "PublisherClient", topic: str): self._stopped = False def is_finished(self) -> bool: - """ Whether the sequencer is finished and should be cleaned up. + """Whether the sequencer is finished and should be cleaned up. - Returns: - Whether the sequencer is finished and should be cleaned up. + Returns: + Whether the sequencer is finished and should be cleaned up. """ # TODO: Implement. Not implementing yet because of possible performance # impact due to extra locking required. This does mean that @@ -54,13 +54,13 @@ def is_finished(self) -> bool: return False def stop(self) -> None: - """ Stop the sequencer. + """Stop the sequencer. - Subsequent publishes will fail. + Subsequent publishes will fail. - Raises: - RuntimeError: - If called after stop() has already been called. + Raises: + RuntimeError: + If called after stop() has already been called. """ if self._stopped: raise RuntimeError("Unordered sequencer already stopped.") @@ -68,11 +68,11 @@ def stop(self) -> None: self._stopped = True def commit(self) -> None: - """ Commit the batch. + """Commit the batch. - Raises: - RuntimeError: - If called after stop() has already been called. + Raises: + RuntimeError: + If called after stop() has already been called. """ if self._stopped: raise RuntimeError("Unordered sequencer already stopped.") @@ -86,7 +86,7 @@ def commit(self) -> None: self._current_batch = None def unpause(self) -> typing.NoReturn: - """ Not relevant for this class. """ + """Not relevant for this class.""" raise NotImplementedError def _create_batch( @@ -94,7 +94,7 @@ def _create_batch( commit_retry: "OptionalRetry" = gapic_v1.method.DEFAULT, commit_timeout: "types.OptionalTimeout" = gapic_v1.method.DEFAULT, ) -> "_batch.thread.Batch": - """ Create a new batch using the client's batch class and other stored + """Create a new batch using the client's batch class and other stored settings. Args: @@ -119,7 +119,7 @@ def publish( retry: "OptionalRetry" = gapic_v1.method.DEFAULT, timeout: "types.OptionalTimeout" = gapic_v1.method.DEFAULT, ) -> "futures.Future": - """ Batch message into existing or new batch. + """Batch message into existing or new batch. Args: message: diff --git a/google/cloud/pubsub_v1/publisher/client.py b/google/cloud/pubsub_v1/publisher/client.py index 43305afcc..e3266e57f 100644 --- a/google/cloud/pubsub_v1/publisher/client.py +++ b/google/cloud/pubsub_v1/publisher/client.py @@ -215,8 +215,8 @@ def api(self): return super() def _get_or_create_sequencer(self, topic: str, ordering_key: str) -> SequencerType: - """ Get an existing sequencer or create a new one given the (topic, - ordering_key) pair. + """Get an existing sequencer or create a new one given the (topic, + ordering_key) pair. """ sequencer_key = (topic, ordering_key) sequencer = self._sequencers.get(sequencer_key) @@ -232,7 +232,7 @@ def _get_or_create_sequencer(self, topic: str, ordering_key: str) -> SequencerTy return sequencer def resume_publish(self, topic: str, ordering_key: str) -> None: - """ Resume publish on an ordering key that has had unrecoverable errors. + """Resume publish on an ordering key that has had unrecoverable errors. Args: topic: The topic to publish messages to. @@ -403,9 +403,9 @@ def on_publish_done(future): # use the default retry for the publish GRPC method as a base transport = self._transport base_retry = transport._wrapped_methods[transport.publish]._retry - retry = base_retry.with_deadline(2.0 ** 32) + retry = base_retry.with_deadline(2.0**32) else: - retry = retry.with_deadline(2.0 ** 32) + retry = retry.with_deadline(2.0**32) # Delegate the publishing to the sequencer. sequencer = self._get_or_create_sequencer(topic, ordering_key) @@ -419,18 +419,18 @@ def on_publish_done(future): return future def ensure_cleanup_and_commit_timer_runs(self) -> None: - """ Ensure a cleanup/commit timer thread is running. + """Ensure a cleanup/commit timer thread is running. - If a cleanup/commit timer thread is already running, this does nothing. + If a cleanup/commit timer thread is already running, this does nothing. """ with self._batch_lock: self._ensure_commit_timer_runs_no_lock() def _ensure_commit_timer_runs_no_lock(self) -> None: - """ Ensure a commit timer thread is running, without taking - _batch_lock. + """Ensure a commit timer thread is running, without taking + _batch_lock. - _batch_lock must be held before calling this method. + _batch_lock must be held before calling this method. """ if not self._commit_thread and self.batch_settings.max_latency < float("inf"): self._start_commit_thread() @@ -448,8 +448,7 @@ def _start_commit_thread(self) -> None: self._commit_thread.start() def _wait_and_commit_sequencers(self) -> None: - """ Wait up to the batching timeout, and commit all sequencers. - """ + """Wait up to the batching timeout, and commit all sequencers.""" # Sleep for however long we should be waiting. time.sleep(self.batch_settings.max_latency) _LOGGER.debug("Commit thread is waking up") @@ -461,7 +460,7 @@ def _wait_and_commit_sequencers(self) -> None: self._commit_thread = None def _commit_sequencers(self) -> None: - """ Clean up finished sequencers and commit the rest. """ + """Clean up finished sequencers and commit the rest.""" finished_sequencer_keys = [ key for key, sequencer in self._sequencers.items() diff --git a/google/cloud/pubsub_v1/publisher/exceptions.py b/google/cloud/pubsub_v1/publisher/exceptions.py index ff0f0713d..f2b65299e 100644 --- a/google/cloud/pubsub_v1/publisher/exceptions.py +++ b/google/cloud/pubsub_v1/publisher/exceptions.py @@ -27,10 +27,10 @@ class MessageTooLargeError(ValueError): class PublishToPausedOrderingKeyException(Exception): - """ Publish attempted to paused ordering key. To resume publishing, call - the resumePublish method on the publisher Client object with this - ordering key. Ordering keys are paused if an unrecoverable error - occurred during publish of a batch for that key. + """Publish attempted to paused ordering key. To resume publishing, call + the resumePublish method on the publisher Client object with this + ordering key. Ordering keys are paused if an unrecoverable error + occurred during publish of a batch for that key. """ def __init__(self, ordering_key: str): diff --git a/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py b/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py index 6ab5165d1..916161616 100644 --- a/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py +++ b/google/cloud/pubsub_v1/subscriber/_protocol/dispatcher.py @@ -208,7 +208,9 @@ def _start_retry_thread(self, thread_name, thread_target): # https://github.com/googleapis/python-pubsub/issues/395#issuecomment-829910303 # https://github.com/googleapis/python-pubsub/issues/395#issuecomment-830092418 retry_thread = threading.Thread( - name=thread_name, target=thread_target, daemon=True, + name=thread_name, + target=thread_target, + daemon=True, ) # The thread finishes when the requests succeed or eventually fail with # a back-end timeout error or other permanent failure. diff --git a/google/cloud/pubsub_v1/subscriber/_protocol/heartbeater.py b/google/cloud/pubsub_v1/subscriber/_protocol/heartbeater.py index 0ab03ddf9..7fa964ff6 100644 --- a/google/cloud/pubsub_v1/subscriber/_protocol/heartbeater.py +++ b/google/cloud/pubsub_v1/subscriber/_protocol/heartbeater.py @@ -42,8 +42,7 @@ def __init__(self, manager: "StreamingPullManager", period: int = _DEFAULT_PERIO self._period = period def heartbeat(self) -> None: - """Periodically send streaming pull heartbeats. - """ + """Periodically send streaming pull heartbeats.""" while not self._stop_event.is_set(): if self._manager.heartbeat(): _LOGGER.debug("Sent heartbeat.") diff --git a/google/cloud/pubsub_v1/subscriber/_protocol/histogram.py b/google/cloud/pubsub_v1/subscriber/_protocol/histogram.py index 7ffa4b3a0..d922bbf68 100644 --- a/google/cloud/pubsub_v1/subscriber/_protocol/histogram.py +++ b/google/cloud/pubsub_v1/subscriber/_protocol/histogram.py @@ -72,8 +72,7 @@ def __len__(self) -> int: return self._len def __contains__(self, needle: int) -> bool: - """Return ``True`` if needle is present in the histogram, ``False`` otherwise. - """ + """Return ``True`` if needle is present in the histogram, ``False`` otherwise.""" return needle in self._data def __repr__(self): diff --git a/google/cloud/pubsub_v1/subscriber/_protocol/messages_on_hold.py b/google/cloud/pubsub_v1/subscriber/_protocol/messages_on_hold.py index 82d5ca376..5c3cc1a75 100644 --- a/google/cloud/pubsub_v1/subscriber/_protocol/messages_on_hold.py +++ b/google/cloud/pubsub_v1/subscriber/_protocol/messages_on_hold.py @@ -21,8 +21,7 @@ class MessagesOnHold(object): - """Tracks messages on hold by ordering key. Not thread-safe. - """ + """Tracks messages on hold by ordering key. Not thread-safe.""" def __init__(self): self._size = 0 @@ -58,7 +57,7 @@ def size(self) -> int: return self._size def get(self) -> Optional["subscriber.message.Message"]: - """ Gets a message from the on-hold queue. A message with an ordering + """Gets a message from the on-hold queue. A message with an ordering key wont be returned if there's another message with the same key in flight. diff --git a/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py b/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py index 4d9097ff9..9fb489967 100644 --- a/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py +++ b/google/cloud/pubsub_v1/subscriber/_protocol/streaming_pull_manager.py @@ -126,7 +126,9 @@ def _wrap_callback_errors( on_callback_error(exc) -def _get_status(exc: exceptions.GoogleAPICallError,) -> Optional["status_pb2.Status"]: +def _get_status( + exc: exceptions.GoogleAPICallError, +) -> Optional["status_pb2.Status"]: if not exc.response: _LOGGER.debug("No response obj in errored RPC call.") return None @@ -140,7 +142,9 @@ def _get_status(exc: exceptions.GoogleAPICallError,) -> Optional["status_pb2.Sta return None -def _get_ack_errors(exc: exceptions.GoogleAPICallError,) -> Optional[Dict[str, str]]: +def _get_ack_errors( + exc: exceptions.GoogleAPICallError, +) -> Optional[Dict[str, str]]: status = _get_status(exc) if not status: _LOGGER.debug("Unable to get status of errored RPC.") diff --git a/google/pubsub_v1/services/publisher/async_client.py b/google/pubsub_v1/services/publisher/async_client.py index b818e6cbb..1262e6abd 100644 --- a/google/pubsub_v1/services/publisher/async_client.py +++ b/google/pubsub_v1/services/publisher/async_client.py @@ -308,7 +308,12 @@ def sample_create_topic(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -390,7 +395,12 @@ def sample_update_topic(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -504,7 +514,12 @@ def sample_publish(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -603,7 +618,12 @@ def sample_get_topic(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -707,12 +727,20 @@ def sample_list_topics(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListTopicsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -821,12 +849,20 @@ def sample_list_topic_subscriptions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListTopicSubscriptionsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -939,12 +975,20 @@ def sample_list_topic_snapshots(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListTopicSnapshotsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1043,7 +1087,10 @@ def sample_delete_topic(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def detach_subscription( @@ -1126,7 +1173,12 @@ def sample_detach_subscription(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1235,7 +1287,12 @@ async def set_iam_policy( ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1345,7 +1402,12 @@ async def get_iam_policy( ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1400,7 +1462,12 @@ async def test_iam_permissions( ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/pubsub_v1/services/publisher/client.py b/google/pubsub_v1/services/publisher/client.py index e4eb074c5..7e9bdeb83 100644 --- a/google/pubsub_v1/services/publisher/client.py +++ b/google/pubsub_v1/services/publisher/client.py @@ -61,7 +61,10 @@ class PublisherClientMeta(type): _transport_registry["grpc"] = PublisherGrpcTransport _transport_registry["grpc_asyncio"] = PublisherGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[PublisherTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[PublisherTransport]: """Returns an appropriate transport class. @@ -182,10 +185,14 @@ def transport(self) -> PublisherTransport: return self._transport @staticmethod - def schema_path(project: str, schema: str,) -> str: + def schema_path( + project: str, + schema: str, + ) -> str: """Returns a fully-qualified schema string.""" return "projects/{project}/schemas/{schema}".format( - project=project, schema=schema, + project=project, + schema=schema, ) @staticmethod @@ -195,10 +202,14 @@ def parse_schema_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def subscription_path(project: str, subscription: str,) -> str: + def subscription_path( + project: str, + subscription: str, + ) -> str: """Returns a fully-qualified subscription string.""" return "projects/{project}/subscriptions/{subscription}".format( - project=project, subscription=subscription, + project=project, + subscription=subscription, ) @staticmethod @@ -210,9 +221,15 @@ def parse_subscription_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def topic_path(project: str, topic: str,) -> str: + def topic_path( + project: str, + topic: str, + ) -> str: """Returns a fully-qualified topic string.""" - return "projects/{project}/topics/{topic}".format(project=project, topic=topic,) + return "projects/{project}/topics/{topic}".format( + project=project, + topic=topic, + ) @staticmethod def parse_topic_path(path: str) -> Dict[str, str]: @@ -221,7 +238,9 @@ def parse_topic_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -234,9 +253,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -245,9 +268,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -256,9 +283,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -267,10 +298,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -548,7 +583,12 @@ def sample_create_topic(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -623,7 +663,12 @@ def sample_update_topic(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -723,7 +768,12 @@ def sample_publish(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -812,7 +862,12 @@ def sample_get_topic(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -906,12 +961,20 @@ def sample_list_topics(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListTopicsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1010,12 +1073,20 @@ def sample_list_topic_subscriptions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListTopicSubscriptionsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1118,12 +1189,20 @@ def sample_list_topic_snapshots(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListTopicSnapshotsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1214,7 +1293,10 @@ def sample_delete_topic(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def detach_subscription( @@ -1290,7 +1372,12 @@ def sample_detach_subscription(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1416,7 +1503,12 @@ def set_iam_policy( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1530,7 +1622,12 @@ def get_iam_policy( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1586,7 +1683,12 @@ def test_iam_permissions( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/pubsub_v1/services/publisher/transports/base.py b/google/pubsub_v1/services/publisher/transports/base.py index a3ea34af6..7b3d2a6d2 100644 --- a/google/pubsub_v1/services/publisher/transports/base.py +++ b/google/pubsub_v1/services/publisher/transports/base.py @@ -271,9 +271,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/pubsub_v1/services/publisher/transports/grpc.py b/google/pubsub_v1/services/publisher/transports/grpc.py index f4f9831c9..a8b1db159 100644 --- a/google/pubsub_v1/services/publisher/transports/grpc.py +++ b/google/pubsub_v1/services/publisher/transports/grpc.py @@ -230,8 +230,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/pubsub_v1/services/schema_service/async_client.py b/google/pubsub_v1/services/schema_service/async_client.py index 17c2bdaa6..f57b64e38 100644 --- a/google/pubsub_v1/services/schema_service/async_client.py +++ b/google/pubsub_v1/services/schema_service/async_client.py @@ -318,7 +318,12 @@ def sample_create_schema(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -405,7 +410,12 @@ def sample_get_schema(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -498,12 +508,20 @@ def sample_list_schemas(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListSchemasAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -586,7 +604,10 @@ def sample_delete_schema(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def validate_schema( @@ -688,7 +709,12 @@ def sample_validate_schema(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -757,7 +783,12 @@ def sample_validate_message(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -865,7 +896,12 @@ async def set_iam_policy( ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -974,7 +1010,12 @@ async def get_iam_policy( ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1028,7 +1069,12 @@ async def test_iam_permissions( ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/pubsub_v1/services/schema_service/client.py b/google/pubsub_v1/services/schema_service/client.py index 825aa3998..b150b2681 100644 --- a/google/pubsub_v1/services/schema_service/client.py +++ b/google/pubsub_v1/services/schema_service/client.py @@ -56,7 +56,10 @@ class SchemaServiceClientMeta(type): _transport_registry["grpc"] = SchemaServiceGrpcTransport _transport_registry["grpc_asyncio"] = SchemaServiceGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[SchemaServiceTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[SchemaServiceTransport]: """Returns an appropriate transport class. Args: @@ -161,10 +164,14 @@ def transport(self) -> SchemaServiceTransport: return self._transport @staticmethod - def schema_path(project: str, schema: str,) -> str: + def schema_path( + project: str, + schema: str, + ) -> str: """Returns a fully-qualified schema string.""" return "projects/{project}/schemas/{schema}".format( - project=project, schema=schema, + project=project, + schema=schema, ) @staticmethod @@ -174,7 +181,9 @@ def parse_schema_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -187,9 +196,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -198,9 +211,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -209,9 +226,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -220,10 +241,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -510,7 +535,12 @@ def sample_create_schema(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -597,7 +627,12 @@ def sample_get_schema(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -690,12 +725,20 @@ def sample_list_schemas(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListSchemasPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -778,7 +821,10 @@ def sample_delete_schema(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def validate_schema( @@ -880,7 +926,12 @@ def sample_validate_schema(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -950,7 +1001,12 @@ def sample_validate_message(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1071,7 +1127,12 @@ def set_iam_policy( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1180,7 +1241,12 @@ def get_iam_policy( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1234,7 +1300,12 @@ def test_iam_permissions( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/pubsub_v1/services/schema_service/transports/base.py b/google/pubsub_v1/services/schema_service/transports/base.py index 97b85afa7..58a2e1265 100644 --- a/google/pubsub_v1/services/schema_service/transports/base.py +++ b/google/pubsub_v1/services/schema_service/transports/base.py @@ -128,31 +128,43 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_schema: gapic_v1.method.wrap_method( - self.create_schema, default_timeout=None, client_info=client_info, + self.create_schema, + default_timeout=None, + client_info=client_info, ), self.get_schema: gapic_v1.method.wrap_method( - self.get_schema, default_timeout=None, client_info=client_info, + self.get_schema, + default_timeout=None, + client_info=client_info, ), self.list_schemas: gapic_v1.method.wrap_method( - self.list_schemas, default_timeout=None, client_info=client_info, + self.list_schemas, + default_timeout=None, + client_info=client_info, ), self.delete_schema: gapic_v1.method.wrap_method( - self.delete_schema, default_timeout=None, client_info=client_info, + self.delete_schema, + default_timeout=None, + client_info=client_info, ), self.validate_schema: gapic_v1.method.wrap_method( - self.validate_schema, default_timeout=None, client_info=client_info, + self.validate_schema, + default_timeout=None, + client_info=client_info, ), self.validate_message: gapic_v1.method.wrap_method( - self.validate_message, default_timeout=None, client_info=client_info, + self.validate_message, + default_timeout=None, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/pubsub_v1/services/schema_service/transports/grpc.py b/google/pubsub_v1/services/schema_service/transports/grpc.py index 1aadad53d..c8bf265f9 100644 --- a/google/pubsub_v1/services/schema_service/transports/grpc.py +++ b/google/pubsub_v1/services/schema_service/transports/grpc.py @@ -230,8 +230,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/pubsub_v1/services/subscriber/async_client.py b/google/pubsub_v1/services/subscriber/async_client.py index 265c7dc75..3acfac4e0 100644 --- a/google/pubsub_v1/services/subscriber/async_client.py +++ b/google/pubsub_v1/services/subscriber/async_client.py @@ -390,7 +390,12 @@ def sample_create_subscription(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -491,7 +496,12 @@ def sample_get_subscription(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -575,7 +585,12 @@ def sample_update_subscription(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -679,12 +694,20 @@ def sample_list_subscriptions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListSubscriptionsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -784,7 +807,10 @@ def sample_delete_subscription(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def modify_ack_deadline( @@ -910,7 +936,10 @@ def sample_modify_ack_deadline(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def acknowledge( @@ -1021,7 +1050,10 @@ def sample_acknowledge(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def pull( @@ -1160,7 +1192,12 @@ def sample_pull(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1256,7 +1293,12 @@ def request_generator(): ) # Send the request. - response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + requests, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1371,7 +1413,10 @@ def sample_modify_push_config(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def get_snapshot( @@ -1480,7 +1525,12 @@ def sample_get_snapshot(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1589,12 +1639,20 @@ def sample_list_snapshots(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListSnapshotsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1741,7 +1799,12 @@ def sample_create_snapshot(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1831,7 +1894,12 @@ def sample_update_snapshot(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1932,7 +2000,10 @@ def sample_delete_snapshot(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def seek( @@ -2017,7 +2088,12 @@ def sample_seek(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2125,7 +2201,12 @@ async def set_iam_policy( ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2234,7 +2315,12 @@ async def get_iam_policy( ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2288,7 +2374,12 @@ async def test_iam_permissions( ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/pubsub_v1/services/subscriber/client.py b/google/pubsub_v1/services/subscriber/client.py index 01499a881..e208327a2 100644 --- a/google/pubsub_v1/services/subscriber/client.py +++ b/google/pubsub_v1/services/subscriber/client.py @@ -61,7 +61,10 @@ class SubscriberClientMeta(type): _transport_registry["grpc"] = SubscriberGrpcTransport _transport_registry["grpc_asyncio"] = SubscriberGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[SubscriberTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[SubscriberTransport]: """Returns an appropriate transport class. @@ -184,10 +187,14 @@ def transport(self) -> SubscriberTransport: return self._transport @staticmethod - def snapshot_path(project: str, snapshot: str,) -> str: + def snapshot_path( + project: str, + snapshot: str, + ) -> str: """Returns a fully-qualified snapshot string.""" return "projects/{project}/snapshots/{snapshot}".format( - project=project, snapshot=snapshot, + project=project, + snapshot=snapshot, ) @staticmethod @@ -197,10 +204,14 @@ def parse_snapshot_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def subscription_path(project: str, subscription: str,) -> str: + def subscription_path( + project: str, + subscription: str, + ) -> str: """Returns a fully-qualified subscription string.""" return "projects/{project}/subscriptions/{subscription}".format( - project=project, subscription=subscription, + project=project, + subscription=subscription, ) @staticmethod @@ -212,9 +223,15 @@ def parse_subscription_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def topic_path(project: str, topic: str,) -> str: + def topic_path( + project: str, + topic: str, + ) -> str: """Returns a fully-qualified topic string.""" - return "projects/{project}/topics/{topic}".format(project=project, topic=topic,) + return "projects/{project}/topics/{topic}".format( + project=project, + topic=topic, + ) @staticmethod def parse_topic_path(path: str) -> Dict[str, str]: @@ -223,7 +240,9 @@ def parse_topic_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -236,9 +255,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -247,9 +270,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -258,9 +285,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -269,10 +300,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -618,7 +653,12 @@ def sample_create_subscription(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -709,7 +749,12 @@ def sample_get_subscription(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -786,7 +831,12 @@ def sample_update_subscription(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -880,12 +930,20 @@ def sample_list_subscriptions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListSubscriptionsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -977,7 +1035,10 @@ def sample_delete_subscription(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def modify_ack_deadline( @@ -1095,7 +1156,10 @@ def sample_modify_ack_deadline(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def acknowledge( @@ -1198,7 +1262,10 @@ def sample_acknowledge(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def pull( @@ -1327,7 +1394,12 @@ def sample_pull(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1412,7 +1484,12 @@ def request_generator(): rpc = self._transport._wrapped_methods[self._transport.streaming_pull] # Send the request. - response = rpc(requests, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + requests, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1519,7 +1596,10 @@ def sample_modify_push_config(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def get_snapshot( @@ -1618,7 +1698,12 @@ def sample_get_snapshot(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1717,12 +1802,20 @@ def sample_list_snapshots(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListSnapshotsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1861,7 +1954,12 @@ def sample_create_snapshot(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1944,7 +2042,12 @@ def sample_update_snapshot(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2037,7 +2140,10 @@ def sample_delete_snapshot(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def seek( @@ -2113,7 +2219,12 @@ def sample_seek(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2238,7 +2349,12 @@ def set_iam_policy( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2351,7 +2467,12 @@ def get_iam_policy( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2406,7 +2527,12 @@ def test_iam_permissions( ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response diff --git a/google/pubsub_v1/services/subscriber/transports/base.py b/google/pubsub_v1/services/subscriber/transports/base.py index 3cd6e7972..835e1984e 100644 --- a/google/pubsub_v1/services/subscriber/transports/base.py +++ b/google/pubsub_v1/services/subscriber/transports/base.py @@ -373,9 +373,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() diff --git a/google/pubsub_v1/services/subscriber/transports/grpc.py b/google/pubsub_v1/services/subscriber/transports/grpc.py index de7ff05c3..d7f755f7e 100644 --- a/google/pubsub_v1/services/subscriber/transports/grpc.py +++ b/google/pubsub_v1/services/subscriber/transports/grpc.py @@ -232,8 +232,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property diff --git a/google/pubsub_v1/types/pubsub.py b/google/pubsub_v1/types/pubsub.py index 3b79e8eca..c344dbe3d 100644 --- a/google/pubsub_v1/types/pubsub.py +++ b/google/pubsub_v1/types/pubsub.py @@ -88,7 +88,10 @@ class MessageStoragePolicy(proto.Message): not a valid configuration. """ - allowed_persistence_regions = proto.RepeatedField(proto.STRING, number=1,) + allowed_persistence_regions = proto.RepeatedField( + proto.STRING, + number=1, + ) class SchemaSettings(proto.Message): @@ -105,8 +108,15 @@ class SchemaSettings(proto.Message): The encoding of messages validated against ``schema``. """ - schema = proto.Field(proto.STRING, number=1,) - encoding = proto.Field(proto.ENUM, number=2, enum=gp_schema.Encoding,) + schema = proto.Field( + proto.STRING, + number=1, + ) + encoding = proto.Field( + proto.ENUM, + number=2, + enum=gp_schema.Encoding, + ) class Topic(proto.Message): @@ -157,16 +167,37 @@ class Topic(proto.Message): days or less than 10 minutes. """ - name = proto.Field(proto.STRING, number=1,) - labels = proto.MapField(proto.STRING, proto.STRING, number=2,) + name = proto.Field( + proto.STRING, + number=1, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) message_storage_policy = proto.Field( - proto.MESSAGE, number=3, message="MessageStoragePolicy", + proto.MESSAGE, + number=3, + message="MessageStoragePolicy", + ) + kms_key_name = proto.Field( + proto.STRING, + number=5, + ) + schema_settings = proto.Field( + proto.MESSAGE, + number=6, + message="SchemaSettings", + ) + satisfies_pzs = proto.Field( + proto.BOOL, + number=7, ) - kms_key_name = proto.Field(proto.STRING, number=5,) - schema_settings = proto.Field(proto.MESSAGE, number=6, message="SchemaSettings",) - satisfies_pzs = proto.Field(proto.BOOL, number=7,) message_retention_duration = proto.Field( - proto.MESSAGE, number=8, message=duration_pb2.Duration, + proto.MESSAGE, + number=8, + message=duration_pb2.Duration, ) @@ -213,13 +244,28 @@ class PubsubMessage(proto.Message): same ``ordering_key`` value. """ - data = proto.Field(proto.BYTES, number=1,) - attributes = proto.MapField(proto.STRING, proto.STRING, number=2,) - message_id = proto.Field(proto.STRING, number=3,) + data = proto.Field( + proto.BYTES, + number=1, + ) + attributes = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) + message_id = proto.Field( + proto.STRING, + number=3, + ) publish_time = proto.Field( - proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + ordering_key = proto.Field( + proto.STRING, + number=5, ) - ordering_key = proto.Field(proto.STRING, number=5,) class GetTopicRequest(proto.Message): @@ -231,7 +277,10 @@ class GetTopicRequest(proto.Message): ``projects/{project}/topics/{topic}``. """ - topic = proto.Field(proto.STRING, number=1,) + topic = proto.Field( + proto.STRING, + number=1, + ) class UpdateTopicRequest(proto.Message): @@ -249,9 +298,15 @@ class UpdateTopicRequest(proto.Message): policy configured at the project or organization level. """ - topic = proto.Field(proto.MESSAGE, number=1, message="Topic",) + topic = proto.Field( + proto.MESSAGE, + number=1, + message="Topic", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -266,8 +321,15 @@ class PublishRequest(proto.Message): Required. The messages to publish. """ - topic = proto.Field(proto.STRING, number=1,) - messages = proto.RepeatedField(proto.MESSAGE, number=2, message="PubsubMessage",) + topic = proto.Field( + proto.STRING, + number=1, + ) + messages = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="PubsubMessage", + ) class PublishResponse(proto.Message): @@ -281,7 +343,10 @@ class PublishResponse(proto.Message): within the topic. """ - message_ids = proto.RepeatedField(proto.STRING, number=1,) + message_ids = proto.RepeatedField( + proto.STRING, + number=1, + ) class ListTopicsRequest(proto.Message): @@ -300,9 +365,18 @@ class ListTopicsRequest(proto.Message): next page of data. """ - project = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + project = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListTopicsResponse(proto.Message): @@ -321,8 +395,15 @@ class ListTopicsResponse(proto.Message): def raw_page(self): return self - topics = proto.RepeatedField(proto.MESSAGE, number=1, message="Topic",) - next_page_token = proto.Field(proto.STRING, number=2,) + topics = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Topic", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class ListTopicSubscriptionsRequest(proto.Message): @@ -343,9 +424,18 @@ class ListTopicSubscriptionsRequest(proto.Message): that the system should return the next page of data. """ - topic = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + topic = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListTopicSubscriptionsResponse(proto.Message): @@ -365,8 +455,14 @@ class ListTopicSubscriptionsResponse(proto.Message): def raw_page(self): return self - subscriptions = proto.RepeatedField(proto.STRING, number=1,) - next_page_token = proto.Field(proto.STRING, number=2,) + subscriptions = proto.RepeatedField( + proto.STRING, + number=1, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class ListTopicSnapshotsRequest(proto.Message): @@ -385,9 +481,18 @@ class ListTopicSnapshotsRequest(proto.Message): that the system should return the next page of data. """ - topic = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + topic = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListTopicSnapshotsResponse(proto.Message): @@ -407,8 +512,14 @@ class ListTopicSnapshotsResponse(proto.Message): def raw_page(self): return self - snapshots = proto.RepeatedField(proto.STRING, number=1,) - next_page_token = proto.Field(proto.STRING, number=2,) + snapshots = proto.RepeatedField( + proto.STRING, + number=1, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class DeleteTopicRequest(proto.Message): @@ -420,7 +531,10 @@ class DeleteTopicRequest(proto.Message): ``projects/{project}/topics/{topic}``. """ - topic = proto.Field(proto.STRING, number=1,) + topic = proto.Field( + proto.STRING, + number=1, + ) class DetachSubscriptionRequest(proto.Message): @@ -432,7 +546,10 @@ class DetachSubscriptionRequest(proto.Message): ``projects/{project}/subscriptions/{subscription}``. """ - subscription = proto.Field(proto.STRING, number=1,) + subscription = proto.Field( + proto.STRING, + number=1, + ) class DetachSubscriptionResponse(proto.Message): @@ -585,28 +702,72 @@ class Subscription(proto.Message): server; it is ignored if it is set in any requests. """ - name = proto.Field(proto.STRING, number=1,) - topic = proto.Field(proto.STRING, number=2,) - push_config = proto.Field(proto.MESSAGE, number=4, message="PushConfig",) - ack_deadline_seconds = proto.Field(proto.INT32, number=5,) - retain_acked_messages = proto.Field(proto.BOOL, number=7,) + name = proto.Field( + proto.STRING, + number=1, + ) + topic = proto.Field( + proto.STRING, + number=2, + ) + push_config = proto.Field( + proto.MESSAGE, + number=4, + message="PushConfig", + ) + ack_deadline_seconds = proto.Field( + proto.INT32, + number=5, + ) + retain_acked_messages = proto.Field( + proto.BOOL, + number=7, + ) message_retention_duration = proto.Field( - proto.MESSAGE, number=8, message=duration_pb2.Duration, + proto.MESSAGE, + number=8, + message=duration_pb2.Duration, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=9, + ) + enable_message_ordering = proto.Field( + proto.BOOL, + number=10, ) - labels = proto.MapField(proto.STRING, proto.STRING, number=9,) - enable_message_ordering = proto.Field(proto.BOOL, number=10,) expiration_policy = proto.Field( - proto.MESSAGE, number=11, message="ExpirationPolicy", + proto.MESSAGE, + number=11, + message="ExpirationPolicy", + ) + filter = proto.Field( + proto.STRING, + number=12, ) - filter = proto.Field(proto.STRING, number=12,) dead_letter_policy = proto.Field( - proto.MESSAGE, number=13, message="DeadLetterPolicy", + proto.MESSAGE, + number=13, + message="DeadLetterPolicy", + ) + retry_policy = proto.Field( + proto.MESSAGE, + number=14, + message="RetryPolicy", + ) + detached = proto.Field( + proto.BOOL, + number=15, + ) + enable_exactly_once_delivery = proto.Field( + proto.BOOL, + number=16, ) - retry_policy = proto.Field(proto.MESSAGE, number=14, message="RetryPolicy",) - detached = proto.Field(proto.BOOL, number=15,) - enable_exactly_once_delivery = proto.Field(proto.BOOL, number=16,) topic_message_retention_duration = proto.Field( - proto.MESSAGE, number=17, message=duration_pb2.Duration, + proto.MESSAGE, + number=17, + message=duration_pb2.Duration, ) @@ -638,10 +799,14 @@ class RetryPolicy(proto.Message): """ minimum_backoff = proto.Field( - proto.MESSAGE, number=1, message=duration_pb2.Duration, + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, ) maximum_backoff = proto.Field( - proto.MESSAGE, number=2, message=duration_pb2.Duration, + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, ) @@ -684,8 +849,14 @@ class DeadLetterPolicy(proto.Message): If this parameter is 0, a default value of 5 is used. """ - dead_letter_topic = proto.Field(proto.STRING, number=1,) - max_delivery_attempts = proto.Field(proto.INT32, number=2,) + dead_letter_topic = proto.Field( + proto.STRING, + number=1, + ) + max_delivery_attempts = proto.Field( + proto.INT32, + number=2, + ) class ExpirationPolicy(proto.Message): @@ -703,7 +874,11 @@ class ExpirationPolicy(proto.Message): associated resource never expires. """ - ttl = proto.Field(proto.MESSAGE, number=1, message=duration_pb2.Duration,) + ttl = proto.Field( + proto.MESSAGE, + number=1, + message=duration_pb2.Duration, + ) class PushConfig(proto.Message): @@ -779,13 +954,29 @@ class OidcToken(proto.Message): will be used. """ - service_account_email = proto.Field(proto.STRING, number=1,) - audience = proto.Field(proto.STRING, number=2,) - - push_endpoint = proto.Field(proto.STRING, number=1,) - attributes = proto.MapField(proto.STRING, proto.STRING, number=2,) + service_account_email = proto.Field( + proto.STRING, + number=1, + ) + audience = proto.Field( + proto.STRING, + number=2, + ) + + push_endpoint = proto.Field( + proto.STRING, + number=1, + ) + attributes = proto.MapField( + proto.STRING, + proto.STRING, + number=2, + ) oidc_token = proto.Field( - proto.MESSAGE, number=3, oneof="authentication_method", message=OidcToken, + proto.MESSAGE, + number=3, + oneof="authentication_method", + message=OidcToken, ) @@ -819,9 +1010,19 @@ class ReceivedMessage(proto.Message): will be 0. """ - ack_id = proto.Field(proto.STRING, number=1,) - message = proto.Field(proto.MESSAGE, number=2, message="PubsubMessage",) - delivery_attempt = proto.Field(proto.INT32, number=3,) + ack_id = proto.Field( + proto.STRING, + number=1, + ) + message = proto.Field( + proto.MESSAGE, + number=2, + message="PubsubMessage", + ) + delivery_attempt = proto.Field( + proto.INT32, + number=3, + ) class GetSubscriptionRequest(proto.Message): @@ -833,7 +1034,10 @@ class GetSubscriptionRequest(proto.Message): ``projects/{project}/subscriptions/{sub}``. """ - subscription = proto.Field(proto.STRING, number=1,) + subscription = proto.Field( + proto.STRING, + number=1, + ) class UpdateSubscriptionRequest(proto.Message): @@ -848,9 +1052,15 @@ class UpdateSubscriptionRequest(proto.Message): specified and non-empty. """ - subscription = proto.Field(proto.MESSAGE, number=1, message="Subscription",) + subscription = proto.Field( + proto.MESSAGE, + number=1, + message="Subscription", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -870,9 +1080,18 @@ class ListSubscriptionsRequest(proto.Message): the system should return the next page of data. """ - project = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + project = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListSubscriptionsResponse(proto.Message): @@ -892,9 +1111,14 @@ def raw_page(self): return self subscriptions = proto.RepeatedField( - proto.MESSAGE, number=1, message="Subscription", + proto.MESSAGE, + number=1, + message="Subscription", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, ) - next_page_token = proto.Field(proto.STRING, number=2,) class DeleteSubscriptionRequest(proto.Message): @@ -906,7 +1130,10 @@ class DeleteSubscriptionRequest(proto.Message): ``projects/{project}/subscriptions/{sub}``. """ - subscription = proto.Field(proto.STRING, number=1,) + subscription = proto.Field( + proto.STRING, + number=1, + ) class ModifyPushConfigRequest(proto.Message): @@ -926,8 +1153,15 @@ class ModifyPushConfigRequest(proto.Message): not called. """ - subscription = proto.Field(proto.STRING, number=1,) - push_config = proto.Field(proto.MESSAGE, number=2, message="PushConfig",) + subscription = proto.Field( + proto.STRING, + number=1, + ) + push_config = proto.Field( + proto.MESSAGE, + number=2, + message="PushConfig", + ) class PullRequest(proto.Message): @@ -954,9 +1188,18 @@ class PullRequest(proto.Message): than the number specified. """ - subscription = proto.Field(proto.STRING, number=1,) - return_immediately = proto.Field(proto.BOOL, number=2,) - max_messages = proto.Field(proto.INT32, number=3,) + subscription = proto.Field( + proto.STRING, + number=1, + ) + return_immediately = proto.Field( + proto.BOOL, + number=2, + ) + max_messages = proto.Field( + proto.INT32, + number=3, + ) class PullResponse(proto.Message): @@ -972,7 +1215,9 @@ class PullResponse(proto.Message): """ received_messages = proto.RepeatedField( - proto.MESSAGE, number=1, message="ReceivedMessage", + proto.MESSAGE, + number=1, + message="ReceivedMessage", ) @@ -998,9 +1243,18 @@ class ModifyAckDeadlineRequest(proto.Message): seconds (10 minutes). """ - subscription = proto.Field(proto.STRING, number=1,) - ack_ids = proto.RepeatedField(proto.STRING, number=4,) - ack_deadline_seconds = proto.Field(proto.INT32, number=3,) + subscription = proto.Field( + proto.STRING, + number=1, + ) + ack_ids = proto.RepeatedField( + proto.STRING, + number=4, + ) + ack_deadline_seconds = proto.Field( + proto.INT32, + number=3, + ) class AcknowledgeRequest(proto.Message): @@ -1017,8 +1271,14 @@ class AcknowledgeRequest(proto.Message): ``Pull`` response. Must not be empty. """ - subscription = proto.Field(proto.STRING, number=1,) - ack_ids = proto.RepeatedField(proto.STRING, number=2,) + subscription = proto.Field( + proto.STRING, + number=1, + ) + ack_ids = proto.RepeatedField( + proto.STRING, + number=2, + ) class StreamingPullRequest(proto.Message): @@ -1105,14 +1365,38 @@ class StreamingPullRequest(proto.Message): ``INVALID_ARGUMENT``. """ - subscription = proto.Field(proto.STRING, number=1,) - ack_ids = proto.RepeatedField(proto.STRING, number=2,) - modify_deadline_seconds = proto.RepeatedField(proto.INT32, number=3,) - modify_deadline_ack_ids = proto.RepeatedField(proto.STRING, number=4,) - stream_ack_deadline_seconds = proto.Field(proto.INT32, number=5,) - client_id = proto.Field(proto.STRING, number=6,) - max_outstanding_messages = proto.Field(proto.INT64, number=7,) - max_outstanding_bytes = proto.Field(proto.INT64, number=8,) + subscription = proto.Field( + proto.STRING, + number=1, + ) + ack_ids = proto.RepeatedField( + proto.STRING, + number=2, + ) + modify_deadline_seconds = proto.RepeatedField( + proto.INT32, + number=3, + ) + modify_deadline_ack_ids = proto.RepeatedField( + proto.STRING, + number=4, + ) + stream_ack_deadline_seconds = proto.Field( + proto.INT32, + number=5, + ) + client_id = proto.Field( + proto.STRING, + number=6, + ) + max_outstanding_messages = proto.Field( + proto.INT64, + number=7, + ) + max_outstanding_bytes = proto.Field( + proto.INT64, + number=8, + ) class StreamingPullResponse(proto.Message): @@ -1149,9 +1433,18 @@ class AcknowledgeConfirmation(proto.Message): order. """ - ack_ids = proto.RepeatedField(proto.STRING, number=1,) - invalid_ack_ids = proto.RepeatedField(proto.STRING, number=2,) - unordered_ack_ids = proto.RepeatedField(proto.STRING, number=3,) + ack_ids = proto.RepeatedField( + proto.STRING, + number=1, + ) + invalid_ack_ids = proto.RepeatedField( + proto.STRING, + number=2, + ) + unordered_ack_ids = proto.RepeatedField( + proto.STRING, + number=3, + ) class ModifyAckDeadlineConfirmation(proto.Message): r"""Acknowledgement IDs sent in one or more previous requests to @@ -1166,8 +1459,14 @@ class ModifyAckDeadlineConfirmation(proto.Message): expired. """ - ack_ids = proto.RepeatedField(proto.STRING, number=1,) - invalid_ack_ids = proto.RepeatedField(proto.STRING, number=2,) + ack_ids = proto.RepeatedField( + proto.STRING, + number=1, + ) + invalid_ack_ids = proto.RepeatedField( + proto.STRING, + number=2, + ) class SubscriptionProperties(proto.Message): r"""Subscription properties sent as part of the response. @@ -1181,20 +1480,34 @@ class SubscriptionProperties(proto.Message): subscription. """ - exactly_once_delivery_enabled = proto.Field(proto.BOOL, number=1,) - message_ordering_enabled = proto.Field(proto.BOOL, number=2,) + exactly_once_delivery_enabled = proto.Field( + proto.BOOL, + number=1, + ) + message_ordering_enabled = proto.Field( + proto.BOOL, + number=2, + ) received_messages = proto.RepeatedField( - proto.MESSAGE, number=1, message="ReceivedMessage", + proto.MESSAGE, + number=1, + message="ReceivedMessage", ) acknowledge_confirmation = proto.Field( - proto.MESSAGE, number=5, message=AcknowledgeConfirmation, + proto.MESSAGE, + number=5, + message=AcknowledgeConfirmation, ) modify_ack_deadline_confirmation = proto.Field( - proto.MESSAGE, number=3, message=ModifyAckDeadlineConfirmation, + proto.MESSAGE, + number=3, + message=ModifyAckDeadlineConfirmation, ) subscription_properties = proto.Field( - proto.MESSAGE, number=4, message=SubscriptionProperties, + proto.MESSAGE, + number=4, + message=SubscriptionProperties, ) @@ -1226,9 +1539,19 @@ class CreateSnapshotRequest(proto.Message): Creating and managing labels. """ - name = proto.Field(proto.STRING, number=1,) - subscription = proto.Field(proto.STRING, number=2,) - labels = proto.MapField(proto.STRING, proto.STRING, number=3,) + name = proto.Field( + proto.STRING, + number=1, + ) + subscription = proto.Field( + proto.STRING, + number=2, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) class UpdateSnapshotRequest(proto.Message): @@ -1243,9 +1566,15 @@ class UpdateSnapshotRequest(proto.Message): and non-empty. """ - snapshot = proto.Field(proto.MESSAGE, number=1, message="Snapshot",) + snapshot = proto.Field( + proto.MESSAGE, + number=1, + message="Snapshot", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -1281,10 +1610,24 @@ class Snapshot(proto.Message): (https://cloud.google.com/pubsub/docs/labels). """ - name = proto.Field(proto.STRING, number=1,) - topic = proto.Field(proto.STRING, number=2,) - expire_time = proto.Field(proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp,) - labels = proto.MapField(proto.STRING, proto.STRING, number=4,) + name = proto.Field( + proto.STRING, + number=1, + ) + topic = proto.Field( + proto.STRING, + number=2, + ) + expire_time = proto.Field( + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + labels = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) class GetSnapshotRequest(proto.Message): @@ -1296,7 +1639,10 @@ class GetSnapshotRequest(proto.Message): ``projects/{project}/snapshots/{snap}``. """ - snapshot = proto.Field(proto.STRING, number=1,) + snapshot = proto.Field( + proto.STRING, + number=1, + ) class ListSnapshotsRequest(proto.Message): @@ -1315,9 +1661,18 @@ class ListSnapshotsRequest(proto.Message): the next page of data. """ - project = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + project = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListSnapshotsResponse(proto.Message): @@ -1336,8 +1691,15 @@ class ListSnapshotsResponse(proto.Message): def raw_page(self): return self - snapshots = proto.RepeatedField(proto.MESSAGE, number=1, message="Snapshot",) - next_page_token = proto.Field(proto.STRING, number=2,) + snapshots = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Snapshot", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class DeleteSnapshotRequest(proto.Message): @@ -1349,7 +1711,10 @@ class DeleteSnapshotRequest(proto.Message): ``projects/{project}/snapshots/{snap}``. """ - snapshot = proto.Field(proto.STRING, number=1,) + snapshot = proto.Field( + proto.STRING, + number=1, + ) class SeekRequest(proto.Message): @@ -1389,16 +1754,25 @@ class SeekRequest(proto.Message): This field is a member of `oneof`_ ``target``. """ - subscription = proto.Field(proto.STRING, number=1,) + subscription = proto.Field( + proto.STRING, + number=1, + ) time = proto.Field( - proto.MESSAGE, number=2, oneof="target", message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + oneof="target", + message=timestamp_pb2.Timestamp, + ) + snapshot = proto.Field( + proto.STRING, + number=3, + oneof="target", ) - snapshot = proto.Field(proto.STRING, number=3, oneof="target",) class SeekResponse(proto.Message): - r"""Response for the ``Seek`` method (this response is empty). - """ + r"""Response for the ``Seek`` method (this response is empty).""" __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/pubsub_v1/types/schema.py b/google/pubsub_v1/types/schema.py index b0a4d4e0a..59fe3aa3e 100644 --- a/google/pubsub_v1/types/schema.py +++ b/google/pubsub_v1/types/schema.py @@ -72,9 +72,19 @@ class Type(proto.Enum): PROTOCOL_BUFFER = 1 AVRO = 2 - name = proto.Field(proto.STRING, number=1,) - type_ = proto.Field(proto.ENUM, number=2, enum=Type,) - definition = proto.Field(proto.STRING, number=3,) + name = proto.Field( + proto.STRING, + number=1, + ) + type_ = proto.Field( + proto.ENUM, + number=2, + enum=Type, + ) + definition = proto.Field( + proto.STRING, + number=3, + ) class CreateSchemaRequest(proto.Message): @@ -99,9 +109,19 @@ class CreateSchemaRequest(proto.Message): for resource name constraints. """ - parent = proto.Field(proto.STRING, number=1,) - schema = proto.Field(proto.MESSAGE, number=2, message="Schema",) - schema_id = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + schema = proto.Field( + proto.MESSAGE, + number=2, + message="Schema", + ) + schema_id = proto.Field( + proto.STRING, + number=3, + ) class GetSchemaRequest(proto.Message): @@ -117,8 +137,15 @@ class GetSchemaRequest(proto.Message): ``definition``. Set to ``FULL`` to retrieve all fields. """ - name = proto.Field(proto.STRING, number=1,) - view = proto.Field(proto.ENUM, number=2, enum="SchemaView",) + name = proto.Field( + proto.STRING, + number=1, + ) + view = proto.Field( + proto.ENUM, + number=2, + enum="SchemaView", + ) class ListSchemasRequest(proto.Message): @@ -141,10 +168,23 @@ class ListSchemasRequest(proto.Message): next page of data. """ - parent = proto.Field(proto.STRING, number=1,) - view = proto.Field(proto.ENUM, number=2, enum="SchemaView",) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + view = proto.Field( + proto.ENUM, + number=2, + enum="SchemaView", + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListSchemasResponse(proto.Message): @@ -163,8 +203,15 @@ class ListSchemasResponse(proto.Message): def raw_page(self): return self - schemas = proto.RepeatedField(proto.MESSAGE, number=1, message="Schema",) - next_page_token = proto.Field(proto.STRING, number=2,) + schemas = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Schema", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class DeleteSchemaRequest(proto.Message): @@ -176,7 +223,10 @@ class DeleteSchemaRequest(proto.Message): ``projects/{project}/schemas/{schema}``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ValidateSchemaRequest(proto.Message): @@ -190,13 +240,19 @@ class ValidateSchemaRequest(proto.Message): Required. The schema object to validate. """ - parent = proto.Field(proto.STRING, number=1,) - schema = proto.Field(proto.MESSAGE, number=2, message="Schema",) + parent = proto.Field( + proto.STRING, + number=1, + ) + schema = proto.Field( + proto.MESSAGE, + number=2, + message="Schema", + ) class ValidateSchemaResponse(proto.Message): - r"""Response for the ``ValidateSchema`` method. Empty for now. - """ + r"""Response for the ``ValidateSchema`` method. Empty for now.""" class ValidateMessageRequest(proto.Message): @@ -229,18 +285,34 @@ class ValidateMessageRequest(proto.Message): The encoding expected for messages """ - parent = proto.Field(proto.STRING, number=1,) - name = proto.Field(proto.STRING, number=2, oneof="schema_spec",) + parent = proto.Field( + proto.STRING, + number=1, + ) + name = proto.Field( + proto.STRING, + number=2, + oneof="schema_spec", + ) schema = proto.Field( - proto.MESSAGE, number=3, oneof="schema_spec", message="Schema", + proto.MESSAGE, + number=3, + oneof="schema_spec", + message="Schema", + ) + message = proto.Field( + proto.BYTES, + number=4, + ) + encoding = proto.Field( + proto.ENUM, + number=5, + enum="Encoding", ) - message = proto.Field(proto.BYTES, number=4,) - encoding = proto.Field(proto.ENUM, number=5, enum="Encoding",) class ValidateMessageResponse(proto.Message): - r"""Response for the ``ValidateMessage`` method. Empty for now. - """ + r"""Response for the ``ValidateMessage`` method. Empty for now.""" __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index e9fea8af8..a97d5ffb4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -24,7 +24,7 @@ import nox -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] MYPY_VERSION = "mypy==0.910" @@ -66,7 +66,8 @@ def mypy(session): # Version 2.1.1 of google-api-core version is the first type-checked release. # Version 2.2.0 of google-cloud-core version is the first type-checked release. session.install( - "google-api-core[grpc]>=2.1.1", "google-cloud-core>=2.2.0", + "google-api-core[grpc]>=2.1.1", + "google-cloud-core>=2.2.0", ) # TODO: Only check the hand-written layer, the generated code does not pass @@ -106,7 +107,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *BLACK_PATHS, ) session.run("flake8", "google", "tests") @@ -116,7 +119,8 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *BLACK_PATHS, ) diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 4c808af73..949e0fde9 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -29,7 +29,7 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" # Copy `noxfile_config.py` to your directory and modify it instead. diff --git a/tests/system.py b/tests/system.py index 1cf67ed96..aa6ca486f 100644 --- a/tests/system.py +++ b/tests/system.py @@ -104,7 +104,7 @@ def test_publish_large_messages(publisher, topic_path, cleanup): # cases well. # Mind that the total PublishRequest size must still be smaller than # 10 * 1024 * 1024 bytes in order to not exceed the max request body size limit. - msg_data = b"x" * (2 * 10 ** 6) + msg_data = b"x" * (2 * 10**6) publisher.batch_settings = types.BatchSettings( max_bytes=11 * 1000 * 1000, # more than the server limit of 10 ** 7 diff --git a/tests/unit/gapic/pubsub_v1/test_publisher.py b/tests/unit/gapic/pubsub_v1/test_publisher.py index 065b6277e..36527c10d 100644 --- a/tests/unit/gapic/pubsub_v1/test_publisher.py +++ b/tests/unit/gapic/pubsub_v1/test_publisher.py @@ -86,7 +86,13 @@ def test__get_default_mtls_endpoint(): assert PublisherClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [PublisherClient, PublisherAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + PublisherClient, + PublisherAsyncClient, + ], +) def test_publisher_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -126,7 +132,13 @@ def test_publisher_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [PublisherClient, PublisherAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + PublisherClient, + PublisherAsyncClient, + ], +) def test_publisher_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -479,7 +491,9 @@ def test_publisher_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -612,10 +626,17 @@ def test_publisher_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [pubsub.Topic, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.Topic, + dict, + ], +) def test_create_topic(request_type, transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -626,7 +647,9 @@ def test_create_topic(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.create_topic), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = pubsub.Topic( - name="name_value", kms_key_name="kms_key_name_value", satisfies_pzs=True, + name="name_value", + kms_key_name="kms_key_name_value", + satisfies_pzs=True, ) response = client.create_topic(request) @@ -646,7 +669,8 @@ def test_create_topic_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -662,7 +686,8 @@ async def test_create_topic_async( transport: str = "grpc_asyncio", request_type=pubsub.Topic ): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -699,7 +724,9 @@ async def test_create_topic_async_from_dict(): def test_create_topic_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -719,12 +746,17 @@ def test_create_topic_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_topic_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -744,11 +776,16 @@ async def test_create_topic_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_create_topic_flattened(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_topic), "__call__") as call: @@ -756,7 +793,9 @@ def test_create_topic_flattened(): call.return_value = pubsub.Topic() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.create_topic(name="name_value",) + client.create_topic( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -768,19 +807,24 @@ def test_create_topic_flattened(): def test_create_topic_flattened_error(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.create_topic( - pubsub.Topic(), name="name_value", + pubsub.Topic(), + name="name_value", ) @pytest.mark.asyncio async def test_create_topic_flattened_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_topic), "__call__") as call: @@ -790,7 +834,9 @@ async def test_create_topic_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(pubsub.Topic()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.create_topic(name="name_value",) + response = await client.create_topic( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -803,20 +849,30 @@ async def test_create_topic_flattened_async(): @pytest.mark.asyncio async def test_create_topic_flattened_error_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.create_topic( - pubsub.Topic(), name="name_value", + pubsub.Topic(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [pubsub.UpdateTopicRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.UpdateTopicRequest, + dict, + ], +) def test_update_topic(request_type, transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -827,7 +883,9 @@ def test_update_topic(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.update_topic), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = pubsub.Topic( - name="name_value", kms_key_name="kms_key_name_value", satisfies_pzs=True, + name="name_value", + kms_key_name="kms_key_name_value", + satisfies_pzs=True, ) response = client.update_topic(request) @@ -847,7 +905,8 @@ def test_update_topic_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -863,7 +922,8 @@ async def test_update_topic_async( transport: str = "grpc_asyncio", request_type=pubsub.UpdateTopicRequest ): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -900,7 +960,9 @@ async def test_update_topic_async_from_dict(): def test_update_topic_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -920,12 +982,17 @@ def test_update_topic_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic.name=topic.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic.name=topic.name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_topic_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -945,13 +1012,23 @@ async def test_update_topic_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic.name=topic.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic.name=topic.name/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [pubsub.PublishRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.PublishRequest, + dict, + ], +) def test_publish(request_type, transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -961,7 +1038,9 @@ def test_publish(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.publish), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = pubsub.PublishResponse(message_ids=["message_ids_value"],) + call.return_value = pubsub.PublishResponse( + message_ids=["message_ids_value"], + ) response = client.publish(request) # Establish that the underlying gRPC stub method was called. @@ -978,7 +1057,8 @@ def test_publish_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -994,7 +1074,8 @@ async def test_publish_async( transport: str = "grpc_asyncio", request_type=pubsub.PublishRequest ): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1005,7 +1086,9 @@ async def test_publish_async( with mock.patch.object(type(client.transport.publish), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - pubsub.PublishResponse(message_ids=["message_ids_value"],) + pubsub.PublishResponse( + message_ids=["message_ids_value"], + ) ) response = await client.publish(request) @@ -1025,7 +1108,9 @@ async def test_publish_async_from_dict(): def test_publish_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1045,12 +1130,17 @@ def test_publish_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_publish_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1072,11 +1162,16 @@ async def test_publish_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] def test_publish_flattened(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.publish), "__call__") as call: @@ -1085,7 +1180,8 @@ def test_publish_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.publish( - topic="topic_value", messages=[pubsub.PubsubMessage(data=b"data_blob")], + topic="topic_value", + messages=[pubsub.PubsubMessage(data=b"data_blob")], ) # Establish that the underlying call was made with the expected @@ -1101,7 +1197,9 @@ def test_publish_flattened(): def test_publish_flattened_error(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1115,7 +1213,9 @@ def test_publish_flattened_error(): @pytest.mark.asyncio async def test_publish_flattened_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.publish), "__call__") as call: @@ -1128,7 +1228,8 @@ async def test_publish_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.publish( - topic="topic_value", messages=[pubsub.PubsubMessage(data=b"data_blob")], + topic="topic_value", + messages=[pubsub.PubsubMessage(data=b"data_blob")], ) # Establish that the underlying call was made with the expected @@ -1145,7 +1246,9 @@ async def test_publish_flattened_async(): @pytest.mark.asyncio async def test_publish_flattened_error_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1157,10 +1260,17 @@ async def test_publish_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [pubsub.GetTopicRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.GetTopicRequest, + dict, + ], +) def test_get_topic(request_type, transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1171,7 +1281,9 @@ def test_get_topic(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.get_topic), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = pubsub.Topic( - name="name_value", kms_key_name="kms_key_name_value", satisfies_pzs=True, + name="name_value", + kms_key_name="kms_key_name_value", + satisfies_pzs=True, ) response = client.get_topic(request) @@ -1191,7 +1303,8 @@ def test_get_topic_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1207,7 +1320,8 @@ async def test_get_topic_async( transport: str = "grpc_asyncio", request_type=pubsub.GetTopicRequest ): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1244,7 +1358,9 @@ async def test_get_topic_async_from_dict(): def test_get_topic_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1264,12 +1380,17 @@ def test_get_topic_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_topic_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1289,11 +1410,16 @@ async def test_get_topic_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] def test_get_topic_flattened(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_topic), "__call__") as call: @@ -1301,7 +1427,9 @@ def test_get_topic_flattened(): call.return_value = pubsub.Topic() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_topic(topic="topic_value",) + client.get_topic( + topic="topic_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1313,19 +1441,24 @@ def test_get_topic_flattened(): def test_get_topic_flattened_error(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_topic( - pubsub.GetTopicRequest(), topic="topic_value", + pubsub.GetTopicRequest(), + topic="topic_value", ) @pytest.mark.asyncio async def test_get_topic_flattened_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_topic), "__call__") as call: @@ -1335,7 +1468,9 @@ async def test_get_topic_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(pubsub.Topic()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_topic(topic="topic_value",) + response = await client.get_topic( + topic="topic_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1348,20 +1483,30 @@ async def test_get_topic_flattened_async(): @pytest.mark.asyncio async def test_get_topic_flattened_error_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_topic( - pubsub.GetTopicRequest(), topic="topic_value", + pubsub.GetTopicRequest(), + topic="topic_value", ) -@pytest.mark.parametrize("request_type", [pubsub.ListTopicsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.ListTopicsRequest, + dict, + ], +) def test_list_topics(request_type, transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1390,7 +1535,8 @@ def test_list_topics_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1406,7 +1552,8 @@ async def test_list_topics_async( transport: str = "grpc_asyncio", request_type=pubsub.ListTopicsRequest ): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1417,7 +1564,9 @@ async def test_list_topics_async( with mock.patch.object(type(client.transport.list_topics), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - pubsub.ListTopicsResponse(next_page_token="next_page_token_value",) + pubsub.ListTopicsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_topics(request) @@ -1437,7 +1586,9 @@ async def test_list_topics_async_from_dict(): def test_list_topics_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1457,12 +1608,17 @@ def test_list_topics_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "project=project/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "project=project/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_topics_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1484,11 +1640,16 @@ async def test_list_topics_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "project=project/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "project=project/value", + ) in kw["metadata"] def test_list_topics_flattened(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_topics), "__call__") as call: @@ -1496,7 +1657,9 @@ def test_list_topics_flattened(): call.return_value = pubsub.ListTopicsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_topics(project="project_value",) + client.list_topics( + project="project_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1508,19 +1671,24 @@ def test_list_topics_flattened(): def test_list_topics_flattened_error(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_topics( - pubsub.ListTopicsRequest(), project="project_value", + pubsub.ListTopicsRequest(), + project="project_value", ) @pytest.mark.asyncio async def test_list_topics_flattened_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_topics), "__call__") as call: @@ -1532,7 +1700,9 @@ async def test_list_topics_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_topics(project="project_value",) + response = await client.list_topics( + project="project_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1545,19 +1715,23 @@ async def test_list_topics_flattened_async(): @pytest.mark.asyncio async def test_list_topics_flattened_error_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_topics( - pubsub.ListTopicsRequest(), project="project_value", + pubsub.ListTopicsRequest(), + project="project_value", ) def test_list_topics_pager(transport_name: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1565,12 +1739,29 @@ def test_list_topics_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicsResponse( - topics=[pubsub.Topic(), pubsub.Topic(), pubsub.Topic(),], + topics=[ + pubsub.Topic(), + pubsub.Topic(), + pubsub.Topic(), + ], next_page_token="abc", ), - pubsub.ListTopicsResponse(topics=[], next_page_token="def",), - pubsub.ListTopicsResponse(topics=[pubsub.Topic(),], next_page_token="ghi",), - pubsub.ListTopicsResponse(topics=[pubsub.Topic(), pubsub.Topic(),],), + pubsub.ListTopicsResponse( + topics=[], + next_page_token="def", + ), + pubsub.ListTopicsResponse( + topics=[ + pubsub.Topic(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicsResponse( + topics=[ + pubsub.Topic(), + pubsub.Topic(), + ], + ), RuntimeError, ) @@ -1589,7 +1780,8 @@ def test_list_topics_pager(transport_name: str = "grpc"): def test_list_topics_pages(transport_name: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1597,12 +1789,29 @@ def test_list_topics_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicsResponse( - topics=[pubsub.Topic(), pubsub.Topic(), pubsub.Topic(),], + topics=[ + pubsub.Topic(), + pubsub.Topic(), + pubsub.Topic(), + ], next_page_token="abc", ), - pubsub.ListTopicsResponse(topics=[], next_page_token="def",), - pubsub.ListTopicsResponse(topics=[pubsub.Topic(),], next_page_token="ghi",), - pubsub.ListTopicsResponse(topics=[pubsub.Topic(), pubsub.Topic(),],), + pubsub.ListTopicsResponse( + topics=[], + next_page_token="def", + ), + pubsub.ListTopicsResponse( + topics=[ + pubsub.Topic(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicsResponse( + topics=[ + pubsub.Topic(), + pubsub.Topic(), + ], + ), RuntimeError, ) pages = list(client.list_topics(request={}).pages) @@ -1612,7 +1821,9 @@ def test_list_topics_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_topics_async_pager(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1621,15 +1832,34 @@ async def test_list_topics_async_pager(): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicsResponse( - topics=[pubsub.Topic(), pubsub.Topic(), pubsub.Topic(),], + topics=[ + pubsub.Topic(), + pubsub.Topic(), + pubsub.Topic(), + ], next_page_token="abc", ), - pubsub.ListTopicsResponse(topics=[], next_page_token="def",), - pubsub.ListTopicsResponse(topics=[pubsub.Topic(),], next_page_token="ghi",), - pubsub.ListTopicsResponse(topics=[pubsub.Topic(), pubsub.Topic(),],), + pubsub.ListTopicsResponse( + topics=[], + next_page_token="def", + ), + pubsub.ListTopicsResponse( + topics=[ + pubsub.Topic(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicsResponse( + topics=[ + pubsub.Topic(), + pubsub.Topic(), + ], + ), RuntimeError, ) - async_pager = await client.list_topics(request={},) + async_pager = await client.list_topics( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1641,7 +1871,9 @@ async def test_list_topics_async_pager(): @pytest.mark.asyncio async def test_list_topics_async_pages(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1650,12 +1882,29 @@ async def test_list_topics_async_pages(): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicsResponse( - topics=[pubsub.Topic(), pubsub.Topic(), pubsub.Topic(),], + topics=[ + pubsub.Topic(), + pubsub.Topic(), + pubsub.Topic(), + ], next_page_token="abc", ), - pubsub.ListTopicsResponse(topics=[], next_page_token="def",), - pubsub.ListTopicsResponse(topics=[pubsub.Topic(),], next_page_token="ghi",), - pubsub.ListTopicsResponse(topics=[pubsub.Topic(), pubsub.Topic(),],), + pubsub.ListTopicsResponse( + topics=[], + next_page_token="def", + ), + pubsub.ListTopicsResponse( + topics=[ + pubsub.Topic(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicsResponse( + topics=[ + pubsub.Topic(), + pubsub.Topic(), + ], + ), RuntimeError, ) pages = [] @@ -1665,10 +1914,17 @@ async def test_list_topics_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [pubsub.ListTopicSubscriptionsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.ListTopicSubscriptionsRequest, + dict, + ], +) def test_list_topic_subscriptions(request_type, transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1701,7 +1957,8 @@ def test_list_topic_subscriptions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1719,7 +1976,8 @@ async def test_list_topic_subscriptions_async( transport: str = "grpc_asyncio", request_type=pubsub.ListTopicSubscriptionsRequest ): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1756,7 +2014,9 @@ async def test_list_topic_subscriptions_async_from_dict(): def test_list_topic_subscriptions_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1778,12 +2038,17 @@ def test_list_topic_subscriptions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_topic_subscriptions_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1807,11 +2072,16 @@ async def test_list_topic_subscriptions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] def test_list_topic_subscriptions_flattened(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1821,7 +2091,9 @@ def test_list_topic_subscriptions_flattened(): call.return_value = pubsub.ListTopicSubscriptionsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_topic_subscriptions(topic="topic_value",) + client.list_topic_subscriptions( + topic="topic_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1833,19 +2105,24 @@ def test_list_topic_subscriptions_flattened(): def test_list_topic_subscriptions_flattened_error(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_topic_subscriptions( - pubsub.ListTopicSubscriptionsRequest(), topic="topic_value", + pubsub.ListTopicSubscriptionsRequest(), + topic="topic_value", ) @pytest.mark.asyncio async def test_list_topic_subscriptions_flattened_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1859,7 +2136,9 @@ async def test_list_topic_subscriptions_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_topic_subscriptions(topic="topic_value",) + response = await client.list_topic_subscriptions( + topic="topic_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1872,19 +2151,23 @@ async def test_list_topic_subscriptions_flattened_async(): @pytest.mark.asyncio async def test_list_topic_subscriptions_flattened_error_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_topic_subscriptions( - pubsub.ListTopicSubscriptionsRequest(), topic="topic_value", + pubsub.ListTopicSubscriptionsRequest(), + topic="topic_value", ) def test_list_topic_subscriptions_pager(transport_name: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1894,15 +2177,29 @@ def test_list_topic_subscriptions_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicSubscriptionsResponse( - subscriptions=[str(), str(), str(),], next_page_token="abc", + subscriptions=[ + str(), + str(), + str(), + ], + next_page_token="abc", + ), + pubsub.ListTopicSubscriptionsResponse( + subscriptions=[], + next_page_token="def", ), pubsub.ListTopicSubscriptionsResponse( - subscriptions=[], next_page_token="def", + subscriptions=[ + str(), + ], + next_page_token="ghi", ), pubsub.ListTopicSubscriptionsResponse( - subscriptions=[str(),], next_page_token="ghi", + subscriptions=[ + str(), + str(), + ], ), - pubsub.ListTopicSubscriptionsResponse(subscriptions=[str(), str(),],), RuntimeError, ) @@ -1921,7 +2218,8 @@ def test_list_topic_subscriptions_pager(transport_name: str = "grpc"): def test_list_topic_subscriptions_pages(transport_name: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1931,15 +2229,29 @@ def test_list_topic_subscriptions_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicSubscriptionsResponse( - subscriptions=[str(), str(), str(),], next_page_token="abc", + subscriptions=[ + str(), + str(), + str(), + ], + next_page_token="abc", ), pubsub.ListTopicSubscriptionsResponse( - subscriptions=[], next_page_token="def", + subscriptions=[], + next_page_token="def", ), pubsub.ListTopicSubscriptionsResponse( - subscriptions=[str(),], next_page_token="ghi", + subscriptions=[ + str(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicSubscriptionsResponse( + subscriptions=[ + str(), + str(), + ], ), - pubsub.ListTopicSubscriptionsResponse(subscriptions=[str(), str(),],), RuntimeError, ) pages = list(client.list_topic_subscriptions(request={}).pages) @@ -1949,7 +2261,9 @@ def test_list_topic_subscriptions_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_topic_subscriptions_async_pager(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1960,18 +2274,34 @@ async def test_list_topic_subscriptions_async_pager(): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicSubscriptionsResponse( - subscriptions=[str(), str(), str(),], next_page_token="abc", + subscriptions=[ + str(), + str(), + str(), + ], + next_page_token="abc", ), pubsub.ListTopicSubscriptionsResponse( - subscriptions=[], next_page_token="def", + subscriptions=[], + next_page_token="def", ), pubsub.ListTopicSubscriptionsResponse( - subscriptions=[str(),], next_page_token="ghi", + subscriptions=[ + str(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicSubscriptionsResponse( + subscriptions=[ + str(), + str(), + ], ), - pubsub.ListTopicSubscriptionsResponse(subscriptions=[str(), str(),],), RuntimeError, ) - async_pager = await client.list_topic_subscriptions(request={},) + async_pager = await client.list_topic_subscriptions( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1983,7 +2313,9 @@ async def test_list_topic_subscriptions_async_pager(): @pytest.mark.asyncio async def test_list_topic_subscriptions_async_pages(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1994,15 +2326,29 @@ async def test_list_topic_subscriptions_async_pages(): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicSubscriptionsResponse( - subscriptions=[str(), str(), str(),], next_page_token="abc", + subscriptions=[ + str(), + str(), + str(), + ], + next_page_token="abc", ), pubsub.ListTopicSubscriptionsResponse( - subscriptions=[], next_page_token="def", + subscriptions=[], + next_page_token="def", ), pubsub.ListTopicSubscriptionsResponse( - subscriptions=[str(),], next_page_token="ghi", + subscriptions=[ + str(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicSubscriptionsResponse( + subscriptions=[ + str(), + str(), + ], ), - pubsub.ListTopicSubscriptionsResponse(subscriptions=[str(), str(),],), RuntimeError, ) pages = [] @@ -2012,10 +2358,17 @@ async def test_list_topic_subscriptions_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [pubsub.ListTopicSnapshotsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.ListTopicSnapshotsRequest, + dict, + ], +) def test_list_topic_snapshots(request_type, transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2028,7 +2381,8 @@ def test_list_topic_snapshots(request_type, transport: str = "grpc"): ) as call: # Designate an appropriate return value for the call. call.return_value = pubsub.ListTopicSnapshotsResponse( - snapshots=["snapshots_value"], next_page_token="next_page_token_value", + snapshots=["snapshots_value"], + next_page_token="next_page_token_value", ) response = client.list_topic_snapshots(request) @@ -2047,7 +2401,8 @@ def test_list_topic_snapshots_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2065,7 +2420,8 @@ async def test_list_topic_snapshots_async( transport: str = "grpc_asyncio", request_type=pubsub.ListTopicSnapshotsRequest ): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2079,7 +2435,8 @@ async def test_list_topic_snapshots_async( # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( pubsub.ListTopicSnapshotsResponse( - snapshots=["snapshots_value"], next_page_token="next_page_token_value", + snapshots=["snapshots_value"], + next_page_token="next_page_token_value", ) ) response = await client.list_topic_snapshots(request) @@ -2101,7 +2458,9 @@ async def test_list_topic_snapshots_async_from_dict(): def test_list_topic_snapshots_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2123,12 +2482,17 @@ def test_list_topic_snapshots_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_topic_snapshots_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2152,11 +2516,16 @@ async def test_list_topic_snapshots_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] def test_list_topic_snapshots_flattened(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2166,7 +2535,9 @@ def test_list_topic_snapshots_flattened(): call.return_value = pubsub.ListTopicSnapshotsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_topic_snapshots(topic="topic_value",) + client.list_topic_snapshots( + topic="topic_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2178,19 +2549,24 @@ def test_list_topic_snapshots_flattened(): def test_list_topic_snapshots_flattened_error(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_topic_snapshots( - pubsub.ListTopicSnapshotsRequest(), topic="topic_value", + pubsub.ListTopicSnapshotsRequest(), + topic="topic_value", ) @pytest.mark.asyncio async def test_list_topic_snapshots_flattened_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2204,7 +2580,9 @@ async def test_list_topic_snapshots_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_topic_snapshots(topic="topic_value",) + response = await client.list_topic_snapshots( + topic="topic_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2217,19 +2595,23 @@ async def test_list_topic_snapshots_flattened_async(): @pytest.mark.asyncio async def test_list_topic_snapshots_flattened_error_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_topic_snapshots( - pubsub.ListTopicSnapshotsRequest(), topic="topic_value", + pubsub.ListTopicSnapshotsRequest(), + topic="topic_value", ) def test_list_topic_snapshots_pager(transport_name: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2239,13 +2621,29 @@ def test_list_topic_snapshots_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicSnapshotsResponse( - snapshots=[str(), str(), str(),], next_page_token="abc", + snapshots=[ + str(), + str(), + str(), + ], + next_page_token="abc", ), - pubsub.ListTopicSnapshotsResponse(snapshots=[], next_page_token="def",), pubsub.ListTopicSnapshotsResponse( - snapshots=[str(),], next_page_token="ghi", + snapshots=[], + next_page_token="def", + ), + pubsub.ListTopicSnapshotsResponse( + snapshots=[ + str(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicSnapshotsResponse( + snapshots=[ + str(), + str(), + ], ), - pubsub.ListTopicSnapshotsResponse(snapshots=[str(), str(),],), RuntimeError, ) @@ -2264,7 +2662,8 @@ def test_list_topic_snapshots_pager(transport_name: str = "grpc"): def test_list_topic_snapshots_pages(transport_name: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2274,13 +2673,29 @@ def test_list_topic_snapshots_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicSnapshotsResponse( - snapshots=[str(), str(), str(),], next_page_token="abc", + snapshots=[ + str(), + str(), + str(), + ], + next_page_token="abc", + ), + pubsub.ListTopicSnapshotsResponse( + snapshots=[], + next_page_token="def", ), - pubsub.ListTopicSnapshotsResponse(snapshots=[], next_page_token="def",), pubsub.ListTopicSnapshotsResponse( - snapshots=[str(),], next_page_token="ghi", + snapshots=[ + str(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicSnapshotsResponse( + snapshots=[ + str(), + str(), + ], ), - pubsub.ListTopicSnapshotsResponse(snapshots=[str(), str(),],), RuntimeError, ) pages = list(client.list_topic_snapshots(request={}).pages) @@ -2290,7 +2705,9 @@ def test_list_topic_snapshots_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_topic_snapshots_async_pager(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2301,16 +2718,34 @@ async def test_list_topic_snapshots_async_pager(): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicSnapshotsResponse( - snapshots=[str(), str(), str(),], next_page_token="abc", + snapshots=[ + str(), + str(), + str(), + ], + next_page_token="abc", ), - pubsub.ListTopicSnapshotsResponse(snapshots=[], next_page_token="def",), pubsub.ListTopicSnapshotsResponse( - snapshots=[str(),], next_page_token="ghi", + snapshots=[], + next_page_token="def", + ), + pubsub.ListTopicSnapshotsResponse( + snapshots=[ + str(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicSnapshotsResponse( + snapshots=[ + str(), + str(), + ], ), - pubsub.ListTopicSnapshotsResponse(snapshots=[str(), str(),],), RuntimeError, ) - async_pager = await client.list_topic_snapshots(request={},) + async_pager = await client.list_topic_snapshots( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -2322,7 +2757,9 @@ async def test_list_topic_snapshots_async_pager(): @pytest.mark.asyncio async def test_list_topic_snapshots_async_pages(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2333,13 +2770,29 @@ async def test_list_topic_snapshots_async_pages(): # Set the response to a series of pages. call.side_effect = ( pubsub.ListTopicSnapshotsResponse( - snapshots=[str(), str(), str(),], next_page_token="abc", + snapshots=[ + str(), + str(), + str(), + ], + next_page_token="abc", + ), + pubsub.ListTopicSnapshotsResponse( + snapshots=[], + next_page_token="def", ), - pubsub.ListTopicSnapshotsResponse(snapshots=[], next_page_token="def",), pubsub.ListTopicSnapshotsResponse( - snapshots=[str(),], next_page_token="ghi", + snapshots=[ + str(), + ], + next_page_token="ghi", + ), + pubsub.ListTopicSnapshotsResponse( + snapshots=[ + str(), + str(), + ], ), - pubsub.ListTopicSnapshotsResponse(snapshots=[str(), str(),],), RuntimeError, ) pages = [] @@ -2349,10 +2802,17 @@ async def test_list_topic_snapshots_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [pubsub.DeleteTopicRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.DeleteTopicRequest, + dict, + ], +) def test_delete_topic(request_type, transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2378,7 +2838,8 @@ def test_delete_topic_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2394,7 +2855,8 @@ async def test_delete_topic_async( transport: str = "grpc_asyncio", request_type=pubsub.DeleteTopicRequest ): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2422,7 +2884,9 @@ async def test_delete_topic_async_from_dict(): def test_delete_topic_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2442,12 +2906,17 @@ def test_delete_topic_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_topic_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2467,11 +2936,16 @@ async def test_delete_topic_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "topic=topic/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "topic=topic/value", + ) in kw["metadata"] def test_delete_topic_flattened(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_topic), "__call__") as call: @@ -2479,7 +2953,9 @@ def test_delete_topic_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_topic(topic="topic_value",) + client.delete_topic( + topic="topic_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2491,19 +2967,24 @@ def test_delete_topic_flattened(): def test_delete_topic_flattened_error(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_topic( - pubsub.DeleteTopicRequest(), topic="topic_value", + pubsub.DeleteTopicRequest(), + topic="topic_value", ) @pytest.mark.asyncio async def test_delete_topic_flattened_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_topic), "__call__") as call: @@ -2513,7 +2994,9 @@ async def test_delete_topic_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_topic(topic="topic_value",) + response = await client.delete_topic( + topic="topic_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2526,20 +3009,30 @@ async def test_delete_topic_flattened_async(): @pytest.mark.asyncio async def test_delete_topic_flattened_error_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_topic( - pubsub.DeleteTopicRequest(), topic="topic_value", + pubsub.DeleteTopicRequest(), + topic="topic_value", ) -@pytest.mark.parametrize("request_type", [pubsub.DetachSubscriptionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.DetachSubscriptionRequest, + dict, + ], +) def test_detach_subscription(request_type, transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2567,7 +3060,8 @@ def test_detach_subscription_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2585,7 +3079,8 @@ async def test_detach_subscription_async( transport: str = "grpc_asyncio", request_type=pubsub.DetachSubscriptionRequest ): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2617,7 +3112,9 @@ async def test_detach_subscription_async_from_dict(): def test_detach_subscription_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2639,14 +3136,17 @@ def test_detach_subscription_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_detach_subscription_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2670,9 +3170,10 @@ async def test_detach_subscription_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -2682,7 +3183,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -2702,7 +3204,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = PublisherClient(client_options=options, transport=transport,) + client = PublisherClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -2718,7 +3223,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = PublisherClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2748,7 +3254,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.PublisherGrpcTransport, transports.PublisherGrpcAsyncIOTransport,], + [ + transports.PublisherGrpcTransport, + transports.PublisherGrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -2760,8 +3269,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.PublisherGrpcTransport,) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.PublisherGrpcTransport, + ) def test_publisher_base_transport_error(): @@ -2817,7 +3331,8 @@ def test_publisher_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.PublisherTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2858,7 +3373,10 @@ def test_publisher_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.PublisherGrpcTransport, transports.PublisherGrpcAsyncIOTransport,], + [ + transports.PublisherGrpcTransport, + transports.PublisherGrpcAsyncIOTransport, + ], ) def test_publisher_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -2985,7 +3503,8 @@ def test_publisher_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.PublisherGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2997,7 +3516,8 @@ def test_publisher_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.PublisherGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -3104,7 +3624,8 @@ def test_schema_path(): project = "squid" schema = "clam" expected = "projects/{project}/schemas/{schema}".format( - project=project, schema=schema, + project=project, + schema=schema, ) actual = PublisherClient.schema_path(project, schema) assert expected == actual @@ -3126,7 +3647,8 @@ def test_subscription_path(): project = "oyster" subscription = "nudibranch" expected = "projects/{project}/subscriptions/{subscription}".format( - project=project, subscription=subscription, + project=project, + subscription=subscription, ) actual = PublisherClient.subscription_path(project, subscription) assert expected == actual @@ -3147,7 +3669,10 @@ def test_parse_subscription_path(): def test_topic_path(): project = "winkle" topic = "nautilus" - expected = "projects/{project}/topics/{topic}".format(project=project, topic=topic,) + expected = "projects/{project}/topics/{topic}".format( + project=project, + topic=topic, + ) actual = PublisherClient.topic_path(project, topic) assert expected == actual @@ -3186,7 +3711,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = PublisherClient.common_folder_path(folder) assert expected == actual @@ -3204,7 +3731,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = PublisherClient.common_organization_path(organization) assert expected == actual @@ -3222,7 +3751,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = PublisherClient.common_project_path(project) assert expected == actual @@ -3242,7 +3773,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = PublisherClient.common_location_path(project, location) assert expected == actual @@ -3267,7 +3799,8 @@ def test_client_with_default_client_info(): transports.PublisherTransport, "_prep_wrapped_messages" ) as prep: client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -3276,14 +3809,16 @@ def test_client_with_default_client_info(): ) as prep: transport_class = PublisherClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) def test_set_iam_policy(transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3293,7 +3828,10 @@ def test_set_iam_policy(transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) @@ -3314,7 +3852,8 @@ def test_set_iam_policy(transport: str = "grpc"): @pytest.mark.asyncio async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3325,7 +3864,10 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -3345,7 +3887,9 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): def test_set_iam_policy_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3365,12 +3909,17 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3390,11 +3939,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_set_iam_policy_from_dict(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -3411,7 +3965,9 @@ def test_set_iam_policy_from_dict(): @pytest.mark.asyncio async def test_set_iam_policy_from_dict_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -3428,7 +3984,8 @@ async def test_set_iam_policy_from_dict_async(): def test_get_iam_policy(transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3438,7 +3995,10 @@ def test_get_iam_policy(transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) @@ -3459,7 +4019,8 @@ def test_get_iam_policy(transport: str = "grpc"): @pytest.mark.asyncio async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3470,7 +4031,10 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -3490,7 +4054,9 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): def test_get_iam_policy_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3510,12 +4076,17 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3535,11 +4106,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_get_iam_policy_from_dict(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -3556,7 +4132,9 @@ def test_get_iam_policy_from_dict(): @pytest.mark.asyncio async def test_get_iam_policy_from_dict_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -3573,7 +4151,8 @@ async def test_get_iam_policy_from_dict_async(): def test_test_iam_permissions(transport: str = "grpc"): client = PublisherClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3606,7 +4185,8 @@ def test_test_iam_permissions(transport: str = "grpc"): @pytest.mark.asyncio async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3639,7 +4219,9 @@ async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): def test_test_iam_permissions_field_headers(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3661,12 +4243,17 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3690,11 +4277,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict(): - client = PublisherClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -3713,7 +4305,9 @@ def test_test_iam_permissions_from_dict(): @pytest.mark.asyncio async def test_test_iam_permissions_from_dict_async(): - client = PublisherAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = PublisherAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -3735,7 +4329,8 @@ async def test_test_iam_permissions_from_dict_async(): @pytest.mark.asyncio async def test_transport_close_async(): client = PublisherAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/pubsub_v1/test_schema_service.py b/tests/unit/gapic/pubsub_v1/test_schema_service.py index d166ce656..19a2f3ab8 100644 --- a/tests/unit/gapic/pubsub_v1/test_schema_service.py +++ b/tests/unit/gapic/pubsub_v1/test_schema_service.py @@ -89,7 +89,11 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize( - "client_class", [SchemaServiceClient, SchemaServiceAsyncClient,] + "client_class", + [ + SchemaServiceClient, + SchemaServiceAsyncClient, + ], ) def test_schema_service_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() @@ -131,7 +135,11 @@ def test_schema_service_client_service_account_always_use_jwt( @pytest.mark.parametrize( - "client_class", [SchemaServiceClient, SchemaServiceAsyncClient,] + "client_class", + [ + SchemaServiceClient, + SchemaServiceAsyncClient, + ], ) def test_schema_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -495,7 +503,9 @@ def test_schema_service_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -640,10 +650,17 @@ def test_schema_service_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [gp_schema.CreateSchemaRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + gp_schema.CreateSchemaRequest, + dict, + ], +) def test_create_schema(request_type, transport: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -676,7 +693,8 @@ def test_create_schema_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -692,7 +710,8 @@ async def test_create_schema_async( transport: str = "grpc_asyncio", request_type=gp_schema.CreateSchemaRequest ): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -729,7 +748,9 @@ async def test_create_schema_async_from_dict(): def test_create_schema_field_headers(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -749,7 +770,10 @@ def test_create_schema_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -776,11 +800,16 @@ async def test_create_schema_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_create_schema_flattened(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_schema), "__call__") as call: @@ -810,7 +839,9 @@ def test_create_schema_flattened(): def test_create_schema_flattened_error(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -875,10 +906,17 @@ async def test_create_schema_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [schema.GetSchemaRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + schema.GetSchemaRequest, + dict, + ], +) def test_get_schema(request_type, transport: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -911,7 +949,8 @@ def test_get_schema_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -927,7 +966,8 @@ async def test_get_schema_async( transport: str = "grpc_asyncio", request_type=schema.GetSchemaRequest ): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -964,7 +1004,9 @@ async def test_get_schema_async_from_dict(): def test_get_schema_field_headers(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -984,7 +1026,10 @@ def test_get_schema_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1011,11 +1056,16 @@ async def test_get_schema_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_get_schema_flattened(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_schema), "__call__") as call: @@ -1023,7 +1073,9 @@ def test_get_schema_flattened(): call.return_value = schema.Schema() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_schema(name="name_value",) + client.get_schema( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1035,13 +1087,16 @@ def test_get_schema_flattened(): def test_get_schema_flattened_error(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_schema( - schema.GetSchemaRequest(), name="name_value", + schema.GetSchemaRequest(), + name="name_value", ) @@ -1059,7 +1114,9 @@ async def test_get_schema_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(schema.Schema()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_schema(name="name_value",) + response = await client.get_schema( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1080,14 +1137,22 @@ async def test_get_schema_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.get_schema( - schema.GetSchemaRequest(), name="name_value", + schema.GetSchemaRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [schema.ListSchemasRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + schema.ListSchemasRequest, + dict, + ], +) def test_list_schemas(request_type, transport: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1116,7 +1181,8 @@ def test_list_schemas_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1132,7 +1198,8 @@ async def test_list_schemas_async( transport: str = "grpc_asyncio", request_type=schema.ListSchemasRequest ): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1143,7 +1210,9 @@ async def test_list_schemas_async( with mock.patch.object(type(client.transport.list_schemas), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - schema.ListSchemasResponse(next_page_token="next_page_token_value",) + schema.ListSchemasResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_schemas(request) @@ -1163,7 +1232,9 @@ async def test_list_schemas_async_from_dict(): def test_list_schemas_field_headers(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1183,7 +1254,10 @@ def test_list_schemas_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1212,11 +1286,16 @@ async def test_list_schemas_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_list_schemas_flattened(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_schemas), "__call__") as call: @@ -1224,7 +1303,9 @@ def test_list_schemas_flattened(): call.return_value = schema.ListSchemasResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_schemas(parent="parent_value",) + client.list_schemas( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1236,13 +1317,16 @@ def test_list_schemas_flattened(): def test_list_schemas_flattened_error(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_schemas( - schema.ListSchemasRequest(), parent="parent_value", + schema.ListSchemasRequest(), + parent="parent_value", ) @@ -1262,7 +1346,9 @@ async def test_list_schemas_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_schemas(parent="parent_value",) + response = await client.list_schemas( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1283,13 +1369,15 @@ async def test_list_schemas_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.list_schemas( - schema.ListSchemasRequest(), parent="parent_value", + schema.ListSchemasRequest(), + parent="parent_value", ) def test_list_schemas_pager(transport_name: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1297,14 +1385,29 @@ def test_list_schemas_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( schema.ListSchemasResponse( - schemas=[schema.Schema(), schema.Schema(), schema.Schema(),], + schemas=[ + schema.Schema(), + schema.Schema(), + schema.Schema(), + ], next_page_token="abc", ), - schema.ListSchemasResponse(schemas=[], next_page_token="def",), schema.ListSchemasResponse( - schemas=[schema.Schema(),], next_page_token="ghi", + schemas=[], + next_page_token="def", + ), + schema.ListSchemasResponse( + schemas=[ + schema.Schema(), + ], + next_page_token="ghi", + ), + schema.ListSchemasResponse( + schemas=[ + schema.Schema(), + schema.Schema(), + ], ), - schema.ListSchemasResponse(schemas=[schema.Schema(), schema.Schema(),],), RuntimeError, ) @@ -1323,7 +1426,8 @@ def test_list_schemas_pager(transport_name: str = "grpc"): def test_list_schemas_pages(transport_name: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1331,14 +1435,29 @@ def test_list_schemas_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( schema.ListSchemasResponse( - schemas=[schema.Schema(), schema.Schema(), schema.Schema(),], + schemas=[ + schema.Schema(), + schema.Schema(), + schema.Schema(), + ], next_page_token="abc", ), - schema.ListSchemasResponse(schemas=[], next_page_token="def",), schema.ListSchemasResponse( - schemas=[schema.Schema(),], next_page_token="ghi", + schemas=[], + next_page_token="def", + ), + schema.ListSchemasResponse( + schemas=[ + schema.Schema(), + ], + next_page_token="ghi", + ), + schema.ListSchemasResponse( + schemas=[ + schema.Schema(), + schema.Schema(), + ], ), - schema.ListSchemasResponse(schemas=[schema.Schema(), schema.Schema(),],), RuntimeError, ) pages = list(client.list_schemas(request={}).pages) @@ -1348,7 +1467,9 @@ def test_list_schemas_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_schemas_async_pager(): - client = SchemaServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = SchemaServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1357,17 +1478,34 @@ async def test_list_schemas_async_pager(): # Set the response to a series of pages. call.side_effect = ( schema.ListSchemasResponse( - schemas=[schema.Schema(), schema.Schema(), schema.Schema(),], + schemas=[ + schema.Schema(), + schema.Schema(), + schema.Schema(), + ], next_page_token="abc", ), - schema.ListSchemasResponse(schemas=[], next_page_token="def",), schema.ListSchemasResponse( - schemas=[schema.Schema(),], next_page_token="ghi", + schemas=[], + next_page_token="def", + ), + schema.ListSchemasResponse( + schemas=[ + schema.Schema(), + ], + next_page_token="ghi", + ), + schema.ListSchemasResponse( + schemas=[ + schema.Schema(), + schema.Schema(), + ], ), - schema.ListSchemasResponse(schemas=[schema.Schema(), schema.Schema(),],), RuntimeError, ) - async_pager = await client.list_schemas(request={},) + async_pager = await client.list_schemas( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1379,7 +1517,9 @@ async def test_list_schemas_async_pager(): @pytest.mark.asyncio async def test_list_schemas_async_pages(): - client = SchemaServiceAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = SchemaServiceAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1388,14 +1528,29 @@ async def test_list_schemas_async_pages(): # Set the response to a series of pages. call.side_effect = ( schema.ListSchemasResponse( - schemas=[schema.Schema(), schema.Schema(), schema.Schema(),], + schemas=[ + schema.Schema(), + schema.Schema(), + schema.Schema(), + ], next_page_token="abc", ), - schema.ListSchemasResponse(schemas=[], next_page_token="def",), schema.ListSchemasResponse( - schemas=[schema.Schema(),], next_page_token="ghi", + schemas=[], + next_page_token="def", + ), + schema.ListSchemasResponse( + schemas=[ + schema.Schema(), + ], + next_page_token="ghi", + ), + schema.ListSchemasResponse( + schemas=[ + schema.Schema(), + schema.Schema(), + ], ), - schema.ListSchemasResponse(schemas=[schema.Schema(), schema.Schema(),],), RuntimeError, ) pages = [] @@ -1405,10 +1560,17 @@ async def test_list_schemas_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [schema.DeleteSchemaRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + schema.DeleteSchemaRequest, + dict, + ], +) def test_delete_schema(request_type, transport: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1434,7 +1596,8 @@ def test_delete_schema_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1450,7 +1613,8 @@ async def test_delete_schema_async( transport: str = "grpc_asyncio", request_type=schema.DeleteSchemaRequest ): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1478,7 +1642,9 @@ async def test_delete_schema_async_from_dict(): def test_delete_schema_field_headers(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1498,7 +1664,10 @@ def test_delete_schema_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1525,11 +1694,16 @@ async def test_delete_schema_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_delete_schema_flattened(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_schema), "__call__") as call: @@ -1537,7 +1711,9 @@ def test_delete_schema_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_schema(name="name_value",) + client.delete_schema( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1549,13 +1725,16 @@ def test_delete_schema_flattened(): def test_delete_schema_flattened_error(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_schema( - schema.DeleteSchemaRequest(), name="name_value", + schema.DeleteSchemaRequest(), + name="name_value", ) @@ -1573,7 +1752,9 @@ async def test_delete_schema_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_schema(name="name_value",) + response = await client.delete_schema( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1594,14 +1775,22 @@ async def test_delete_schema_flattened_error_async(): # fields is an error. with pytest.raises(ValueError): await client.delete_schema( - schema.DeleteSchemaRequest(), name="name_value", + schema.DeleteSchemaRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [gp_schema.ValidateSchemaRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + gp_schema.ValidateSchemaRequest, + dict, + ], +) def test_validate_schema(request_type, transport: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1627,7 +1816,8 @@ def test_validate_schema_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1643,7 +1833,8 @@ async def test_validate_schema_async( transport: str = "grpc_asyncio", request_type=gp_schema.ValidateSchemaRequest ): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1673,7 +1864,9 @@ async def test_validate_schema_async_from_dict(): def test_validate_schema_field_headers(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1693,7 +1886,10 @@ def test_validate_schema_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1722,11 +1918,16 @@ async def test_validate_schema_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_validate_schema_flattened(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.validate_schema), "__call__") as call: @@ -1735,7 +1936,8 @@ def test_validate_schema_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.validate_schema( - parent="parent_value", schema=gp_schema.Schema(name="name_value"), + parent="parent_value", + schema=gp_schema.Schema(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1751,7 +1953,9 @@ def test_validate_schema_flattened(): def test_validate_schema_flattened_error(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1780,7 +1984,8 @@ async def test_validate_schema_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.validate_schema( - parent="parent_value", schema=gp_schema.Schema(name="name_value"), + parent="parent_value", + schema=gp_schema.Schema(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1811,10 +2016,17 @@ async def test_validate_schema_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [schema.ValidateMessageRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + schema.ValidateMessageRequest, + dict, + ], +) def test_validate_message(request_type, transport: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1840,7 +2052,8 @@ def test_validate_message_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1856,7 +2069,8 @@ async def test_validate_message_async( transport: str = "grpc_asyncio", request_type=schema.ValidateMessageRequest ): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1886,7 +2100,9 @@ async def test_validate_message_async_from_dict(): def test_validate_message_field_headers(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1906,7 +2122,10 @@ def test_validate_message_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -1935,7 +2154,10 @@ async def test_validate_message_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -1945,7 +2167,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -1965,7 +2188,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = SchemaServiceClient(client_options=options, transport=transport,) + client = SchemaServiceClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -1981,7 +2207,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SchemaServiceClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -2026,8 +2253,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.SchemaServiceGrpcTransport,) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.SchemaServiceGrpcTransport, + ) def test_schema_service_base_transport_error(): @@ -2080,7 +2312,8 @@ def test_schema_service_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SchemaServiceTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -2254,7 +2487,8 @@ def test_schema_service_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.SchemaServiceGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2266,7 +2500,8 @@ def test_schema_service_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.SchemaServiceGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -2379,7 +2614,8 @@ def test_schema_path(): project = "squid" schema = "clam" expected = "projects/{project}/schemas/{schema}".format( - project=project, schema=schema, + project=project, + schema=schema, ) actual = SchemaServiceClient.schema_path(project, schema) assert expected == actual @@ -2419,7 +2655,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "cuttlefish" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = SchemaServiceClient.common_folder_path(folder) assert expected == actual @@ -2437,7 +2675,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "winkle" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = SchemaServiceClient.common_organization_path(organization) assert expected == actual @@ -2455,7 +2695,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "scallop" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = SchemaServiceClient.common_project_path(project) assert expected == actual @@ -2475,7 +2717,8 @@ def test_common_location_path(): project = "squid" location = "clam" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = SchemaServiceClient.common_location_path(project, location) assert expected == actual @@ -2500,7 +2743,8 @@ def test_client_with_default_client_info(): transports.SchemaServiceTransport, "_prep_wrapped_messages" ) as prep: client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -2509,14 +2753,16 @@ def test_client_with_default_client_info(): ) as prep: transport_class = SchemaServiceClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) def test_set_iam_policy(transport: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2526,7 +2772,10 @@ def test_set_iam_policy(transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) @@ -2547,7 +2796,8 @@ def test_set_iam_policy(transport: str = "grpc"): @pytest.mark.asyncio async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2558,7 +2808,10 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -2578,7 +2831,9 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): def test_set_iam_policy_field_headers(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2598,7 +2853,10 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2625,11 +2883,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_set_iam_policy_from_dict(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2665,7 +2928,8 @@ async def test_set_iam_policy_from_dict_async(): def test_get_iam_policy(transport: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2675,7 +2939,10 @@ def test_get_iam_policy(transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) @@ -2696,7 +2963,8 @@ def test_get_iam_policy(transport: str = "grpc"): @pytest.mark.asyncio async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2707,7 +2975,10 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -2727,7 +2998,9 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): def test_get_iam_policy_field_headers(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2747,7 +3020,10 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2774,11 +3050,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_get_iam_policy_from_dict(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2814,7 +3095,8 @@ async def test_get_iam_policy_from_dict_async(): def test_test_iam_permissions(transport: str = "grpc"): client = SchemaServiceClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2847,7 +3129,8 @@ def test_test_iam_permissions(transport: str = "grpc"): @pytest.mark.asyncio async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2880,7 +3163,9 @@ async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): def test_test_iam_permissions_field_headers(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2902,7 +3187,10 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio @@ -2933,11 +3221,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict(): - client = SchemaServiceClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SchemaServiceClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -2980,7 +3273,8 @@ async def test_test_iam_permissions_from_dict_async(): @pytest.mark.asyncio async def test_transport_close_async(): client = SchemaServiceAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/pubsub_v1/test_subscriber.py b/tests/unit/gapic/pubsub_v1/test_subscriber.py index 1157ca1bd..0455855de 100644 --- a/tests/unit/gapic/pubsub_v1/test_subscriber.py +++ b/tests/unit/gapic/pubsub_v1/test_subscriber.py @@ -88,7 +88,13 @@ def test__get_default_mtls_endpoint(): assert SubscriberClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [SubscriberClient, SubscriberAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + SubscriberClient, + SubscriberAsyncClient, + ], +) def test_subscriber_client_from_service_account_info(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -128,7 +134,13 @@ def test_subscriber_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [SubscriberClient, SubscriberAsyncClient,]) +@pytest.mark.parametrize( + "client_class", + [ + SubscriberClient, + SubscriberAsyncClient, + ], +) def test_subscriber_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( @@ -483,7 +495,9 @@ def test_subscriber_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -616,10 +630,17 @@ def test_subscriber_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [pubsub.Subscription, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.Subscription, + dict, + ], +) def test_create_subscription(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -664,7 +685,8 @@ def test_create_subscription_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -682,7 +704,8 @@ async def test_create_subscription_async( transport: str = "grpc_asyncio", request_type=pubsub.Subscription ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -731,7 +754,9 @@ async def test_create_subscription_async_from_dict(): def test_create_subscription_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -753,12 +778,17 @@ def test_create_subscription_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_subscription_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -780,11 +810,16 @@ async def test_create_subscription_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_create_subscription_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -820,7 +855,9 @@ def test_create_subscription_flattened(): def test_create_subscription_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -836,7 +873,9 @@ def test_create_subscription_flattened_error(): @pytest.mark.asyncio async def test_create_subscription_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -875,7 +914,9 @@ async def test_create_subscription_flattened_async(): @pytest.mark.asyncio async def test_create_subscription_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -889,10 +930,17 @@ async def test_create_subscription_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [pubsub.GetSubscriptionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.GetSubscriptionRequest, + dict, + ], +) def test_get_subscription(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -935,7 +983,8 @@ def test_get_subscription_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -951,7 +1000,8 @@ async def test_get_subscription_async( transport: str = "grpc_asyncio", request_type=pubsub.GetSubscriptionRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -998,7 +1048,9 @@ async def test_get_subscription_async_from_dict(): def test_get_subscription_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1018,14 +1070,17 @@ def test_get_subscription_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_subscription_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1045,13 +1100,16 @@ async def test_get_subscription_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] def test_get_subscription_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_subscription), "__call__") as call: @@ -1059,7 +1117,9 @@ def test_get_subscription_flattened(): call.return_value = pubsub.Subscription() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_subscription(subscription="subscription_value",) + client.get_subscription( + subscription="subscription_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1071,19 +1131,24 @@ def test_get_subscription_flattened(): def test_get_subscription_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_subscription( - pubsub.GetSubscriptionRequest(), subscription="subscription_value", + pubsub.GetSubscriptionRequest(), + subscription="subscription_value", ) @pytest.mark.asyncio async def test_get_subscription_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_subscription), "__call__") as call: @@ -1093,7 +1158,9 @@ async def test_get_subscription_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(pubsub.Subscription()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_subscription(subscription="subscription_value",) + response = await client.get_subscription( + subscription="subscription_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1106,20 +1173,30 @@ async def test_get_subscription_flattened_async(): @pytest.mark.asyncio async def test_get_subscription_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_subscription( - pubsub.GetSubscriptionRequest(), subscription="subscription_value", + pubsub.GetSubscriptionRequest(), + subscription="subscription_value", ) -@pytest.mark.parametrize("request_type", [pubsub.UpdateSubscriptionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.UpdateSubscriptionRequest, + dict, + ], +) def test_update_subscription(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1164,7 +1241,8 @@ def test_update_subscription_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1182,7 +1260,8 @@ async def test_update_subscription_async( transport: str = "grpc_asyncio", request_type=pubsub.UpdateSubscriptionRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1231,7 +1310,9 @@ async def test_update_subscription_async_from_dict(): def test_update_subscription_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1261,7 +1342,9 @@ def test_update_subscription_field_headers(): @pytest.mark.asyncio async def test_update_subscription_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1289,10 +1372,17 @@ async def test_update_subscription_field_headers_async(): ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [pubsub.ListSubscriptionsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.ListSubscriptionsRequest, + dict, + ], +) def test_list_subscriptions(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1323,7 +1413,8 @@ def test_list_subscriptions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1341,7 +1432,8 @@ async def test_list_subscriptions_async( transport: str = "grpc_asyncio", request_type=pubsub.ListSubscriptionsRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1354,7 +1446,9 @@ async def test_list_subscriptions_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - pubsub.ListSubscriptionsResponse(next_page_token="next_page_token_value",) + pubsub.ListSubscriptionsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_subscriptions(request) @@ -1374,7 +1468,9 @@ async def test_list_subscriptions_async_from_dict(): def test_list_subscriptions_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1396,12 +1492,17 @@ def test_list_subscriptions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "project=project/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "project=project/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_subscriptions_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1425,11 +1526,16 @@ async def test_list_subscriptions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "project=project/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "project=project/value", + ) in kw["metadata"] def test_list_subscriptions_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1439,7 +1545,9 @@ def test_list_subscriptions_flattened(): call.return_value = pubsub.ListSubscriptionsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_subscriptions(project="project_value",) + client.list_subscriptions( + project="project_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1451,19 +1559,24 @@ def test_list_subscriptions_flattened(): def test_list_subscriptions_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_subscriptions( - pubsub.ListSubscriptionsRequest(), project="project_value", + pubsub.ListSubscriptionsRequest(), + project="project_value", ) @pytest.mark.asyncio async def test_list_subscriptions_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1477,7 +1590,9 @@ async def test_list_subscriptions_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_subscriptions(project="project_value",) + response = await client.list_subscriptions( + project="project_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1490,19 +1605,23 @@ async def test_list_subscriptions_flattened_async(): @pytest.mark.asyncio async def test_list_subscriptions_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_subscriptions( - pubsub.ListSubscriptionsRequest(), project="project_value", + pubsub.ListSubscriptionsRequest(), + project="project_value", ) def test_list_subscriptions_pager(transport_name: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1519,12 +1638,21 @@ def test_list_subscriptions_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - pubsub.ListSubscriptionsResponse(subscriptions=[], next_page_token="def",), pubsub.ListSubscriptionsResponse( - subscriptions=[pubsub.Subscription(),], next_page_token="ghi", + subscriptions=[], + next_page_token="def", + ), + pubsub.ListSubscriptionsResponse( + subscriptions=[ + pubsub.Subscription(), + ], + next_page_token="ghi", ), pubsub.ListSubscriptionsResponse( - subscriptions=[pubsub.Subscription(), pubsub.Subscription(),], + subscriptions=[ + pubsub.Subscription(), + pubsub.Subscription(), + ], ), RuntimeError, ) @@ -1544,7 +1672,8 @@ def test_list_subscriptions_pager(transport_name: str = "grpc"): def test_list_subscriptions_pages(transport_name: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1561,12 +1690,21 @@ def test_list_subscriptions_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - pubsub.ListSubscriptionsResponse(subscriptions=[], next_page_token="def",), pubsub.ListSubscriptionsResponse( - subscriptions=[pubsub.Subscription(),], next_page_token="ghi", + subscriptions=[], + next_page_token="def", + ), + pubsub.ListSubscriptionsResponse( + subscriptions=[ + pubsub.Subscription(), + ], + next_page_token="ghi", ), pubsub.ListSubscriptionsResponse( - subscriptions=[pubsub.Subscription(), pubsub.Subscription(),], + subscriptions=[ + pubsub.Subscription(), + pubsub.Subscription(), + ], ), RuntimeError, ) @@ -1577,7 +1715,9 @@ def test_list_subscriptions_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_subscriptions_async_pager(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1595,16 +1735,27 @@ async def test_list_subscriptions_async_pager(): ], next_page_token="abc", ), - pubsub.ListSubscriptionsResponse(subscriptions=[], next_page_token="def",), pubsub.ListSubscriptionsResponse( - subscriptions=[pubsub.Subscription(),], next_page_token="ghi", + subscriptions=[], + next_page_token="def", + ), + pubsub.ListSubscriptionsResponse( + subscriptions=[ + pubsub.Subscription(), + ], + next_page_token="ghi", ), pubsub.ListSubscriptionsResponse( - subscriptions=[pubsub.Subscription(), pubsub.Subscription(),], + subscriptions=[ + pubsub.Subscription(), + pubsub.Subscription(), + ], ), RuntimeError, ) - async_pager = await client.list_subscriptions(request={},) + async_pager = await client.list_subscriptions( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -1616,7 +1767,9 @@ async def test_list_subscriptions_async_pager(): @pytest.mark.asyncio async def test_list_subscriptions_async_pages(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1634,12 +1787,21 @@ async def test_list_subscriptions_async_pages(): ], next_page_token="abc", ), - pubsub.ListSubscriptionsResponse(subscriptions=[], next_page_token="def",), pubsub.ListSubscriptionsResponse( - subscriptions=[pubsub.Subscription(),], next_page_token="ghi", + subscriptions=[], + next_page_token="def", + ), + pubsub.ListSubscriptionsResponse( + subscriptions=[ + pubsub.Subscription(), + ], + next_page_token="ghi", ), pubsub.ListSubscriptionsResponse( - subscriptions=[pubsub.Subscription(), pubsub.Subscription(),], + subscriptions=[ + pubsub.Subscription(), + pubsub.Subscription(), + ], ), RuntimeError, ) @@ -1650,10 +1812,17 @@ async def test_list_subscriptions_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [pubsub.DeleteSubscriptionRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.DeleteSubscriptionRequest, + dict, + ], +) def test_delete_subscription(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1681,7 +1850,8 @@ def test_delete_subscription_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1699,7 +1869,8 @@ async def test_delete_subscription_async( transport: str = "grpc_asyncio", request_type=pubsub.DeleteSubscriptionRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1729,7 +1900,9 @@ async def test_delete_subscription_async_from_dict(): def test_delete_subscription_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1751,14 +1924,17 @@ def test_delete_subscription_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_subscription_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1780,13 +1956,16 @@ async def test_delete_subscription_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] def test_delete_subscription_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1796,7 +1975,9 @@ def test_delete_subscription_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_subscription(subscription="subscription_value",) + client.delete_subscription( + subscription="subscription_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1808,19 +1989,24 @@ def test_delete_subscription_flattened(): def test_delete_subscription_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_subscription( - pubsub.DeleteSubscriptionRequest(), subscription="subscription_value", + pubsub.DeleteSubscriptionRequest(), + subscription="subscription_value", ) @pytest.mark.asyncio async def test_delete_subscription_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1832,7 +2018,9 @@ async def test_delete_subscription_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_subscription(subscription="subscription_value",) + response = await client.delete_subscription( + subscription="subscription_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1845,20 +2033,30 @@ async def test_delete_subscription_flattened_async(): @pytest.mark.asyncio async def test_delete_subscription_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_subscription( - pubsub.DeleteSubscriptionRequest(), subscription="subscription_value", + pubsub.DeleteSubscriptionRequest(), + subscription="subscription_value", ) -@pytest.mark.parametrize("request_type", [pubsub.ModifyAckDeadlineRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.ModifyAckDeadlineRequest, + dict, + ], +) def test_modify_ack_deadline(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1886,7 +2084,8 @@ def test_modify_ack_deadline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1904,7 +2103,8 @@ async def test_modify_ack_deadline_async( transport: str = "grpc_asyncio", request_type=pubsub.ModifyAckDeadlineRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1934,7 +2134,9 @@ async def test_modify_ack_deadline_async_from_dict(): def test_modify_ack_deadline_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1956,14 +2158,17 @@ def test_modify_ack_deadline_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_modify_ack_deadline_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -1985,13 +2190,16 @@ async def test_modify_ack_deadline_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] def test_modify_ack_deadline_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2023,7 +2231,9 @@ def test_modify_ack_deadline_flattened(): def test_modify_ack_deadline_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2038,7 +2248,9 @@ def test_modify_ack_deadline_flattened_error(): @pytest.mark.asyncio async def test_modify_ack_deadline_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2073,7 +2285,9 @@ async def test_modify_ack_deadline_flattened_async(): @pytest.mark.asyncio async def test_modify_ack_deadline_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2086,10 +2300,17 @@ async def test_modify_ack_deadline_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [pubsub.AcknowledgeRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.AcknowledgeRequest, + dict, + ], +) def test_acknowledge(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2115,7 +2336,8 @@ def test_acknowledge_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2131,7 +2353,8 @@ async def test_acknowledge_async( transport: str = "grpc_asyncio", request_type=pubsub.AcknowledgeRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2159,7 +2382,9 @@ async def test_acknowledge_async_from_dict(): def test_acknowledge_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2179,14 +2404,17 @@ def test_acknowledge_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] - - + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] + + @pytest.mark.asyncio async def test_acknowledge_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2206,13 +2434,16 @@ async def test_acknowledge_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] def test_acknowledge_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.acknowledge), "__call__") as call: @@ -2221,7 +2452,8 @@ def test_acknowledge_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.acknowledge( - subscription="subscription_value", ack_ids=["ack_ids_value"], + subscription="subscription_value", + ack_ids=["ack_ids_value"], ) # Establish that the underlying call was made with the expected @@ -2237,7 +2469,9 @@ def test_acknowledge_flattened(): def test_acknowledge_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2251,7 +2485,9 @@ def test_acknowledge_flattened_error(): @pytest.mark.asyncio async def test_acknowledge_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.acknowledge), "__call__") as call: @@ -2262,7 +2498,8 @@ async def test_acknowledge_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.acknowledge( - subscription="subscription_value", ack_ids=["ack_ids_value"], + subscription="subscription_value", + ack_ids=["ack_ids_value"], ) # Establish that the underlying call was made with the expected @@ -2279,7 +2516,9 @@ async def test_acknowledge_flattened_async(): @pytest.mark.asyncio async def test_acknowledge_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2291,10 +2530,17 @@ async def test_acknowledge_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [pubsub.PullRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.PullRequest, + dict, + ], +) def test_pull(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2320,7 +2566,8 @@ def test_pull_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2336,7 +2583,8 @@ async def test_pull_async( transport: str = "grpc_asyncio", request_type=pubsub.PullRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2364,7 +2612,9 @@ async def test_pull_async_from_dict(): def test_pull_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2384,14 +2634,17 @@ def test_pull_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_pull_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2411,13 +2664,16 @@ async def test_pull_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] def test_pull_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pull), "__call__") as call: @@ -2449,7 +2705,9 @@ def test_pull_flattened(): def test_pull_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2464,7 +2722,9 @@ def test_pull_flattened_error(): @pytest.mark.asyncio async def test_pull_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pull), "__call__") as call: @@ -2499,7 +2759,9 @@ async def test_pull_flattened_async(): @pytest.mark.asyncio async def test_pull_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2512,10 +2774,17 @@ async def test_pull_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [pubsub.StreamingPullRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.StreamingPullRequest, + dict, + ], +) def test_streaming_pull(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2544,7 +2813,8 @@ async def test_streaming_pull_async( transport: str = "grpc_asyncio", request_type=pubsub.StreamingPullRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2576,10 +2846,17 @@ async def test_streaming_pull_async_from_dict(): await test_streaming_pull_async(request_type=dict) -@pytest.mark.parametrize("request_type", [pubsub.ModifyPushConfigRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.ModifyPushConfigRequest, + dict, + ], +) def test_modify_push_config(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2607,7 +2884,8 @@ def test_modify_push_config_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2625,7 +2903,8 @@ async def test_modify_push_config_async( transport: str = "grpc_asyncio", request_type=pubsub.ModifyPushConfigRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2655,7 +2934,9 @@ async def test_modify_push_config_async_from_dict(): def test_modify_push_config_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2677,14 +2958,17 @@ def test_modify_push_config_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_modify_push_config_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2706,13 +2990,16 @@ async def test_modify_push_config_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] def test_modify_push_config_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2740,7 +3027,9 @@ def test_modify_push_config_flattened(): def test_modify_push_config_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2754,7 +3043,9 @@ def test_modify_push_config_flattened_error(): @pytest.mark.asyncio async def test_modify_push_config_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2785,7 +3076,9 @@ async def test_modify_push_config_flattened_async(): @pytest.mark.asyncio async def test_modify_push_config_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2797,10 +3090,17 @@ async def test_modify_push_config_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [pubsub.GetSnapshotRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.GetSnapshotRequest, + dict, + ], +) def test_get_snapshot(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2810,7 +3110,10 @@ def test_get_snapshot(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_snapshot), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = pubsub.Snapshot(name="name_value", topic="topic_value",) + call.return_value = pubsub.Snapshot( + name="name_value", + topic="topic_value", + ) response = client.get_snapshot(request) # Establish that the underlying gRPC stub method was called. @@ -2828,7 +3131,8 @@ def test_get_snapshot_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2844,7 +3148,8 @@ async def test_get_snapshot_async( transport: str = "grpc_asyncio", request_type=pubsub.GetSnapshotRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2855,7 +3160,10 @@ async def test_get_snapshot_async( with mock.patch.object(type(client.transport.get_snapshot), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - pubsub.Snapshot(name="name_value", topic="topic_value",) + pubsub.Snapshot( + name="name_value", + topic="topic_value", + ) ) response = await client.get_snapshot(request) @@ -2876,7 +3184,9 @@ async def test_get_snapshot_async_from_dict(): def test_get_snapshot_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2896,12 +3206,17 @@ def test_get_snapshot_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "snapshot=snapshot/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "snapshot=snapshot/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_snapshot_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -2921,11 +3236,16 @@ async def test_get_snapshot_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "snapshot=snapshot/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "snapshot=snapshot/value", + ) in kw["metadata"] def test_get_snapshot_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_snapshot), "__call__") as call: @@ -2933,7 +3253,9 @@ def test_get_snapshot_flattened(): call.return_value = pubsub.Snapshot() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_snapshot(snapshot="snapshot_value",) + client.get_snapshot( + snapshot="snapshot_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2945,19 +3267,24 @@ def test_get_snapshot_flattened(): def test_get_snapshot_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_snapshot( - pubsub.GetSnapshotRequest(), snapshot="snapshot_value", + pubsub.GetSnapshotRequest(), + snapshot="snapshot_value", ) @pytest.mark.asyncio async def test_get_snapshot_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_snapshot), "__call__") as call: @@ -2967,7 +3294,9 @@ async def test_get_snapshot_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(pubsub.Snapshot()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_snapshot(snapshot="snapshot_value",) + response = await client.get_snapshot( + snapshot="snapshot_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2980,20 +3309,30 @@ async def test_get_snapshot_flattened_async(): @pytest.mark.asyncio async def test_get_snapshot_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_snapshot( - pubsub.GetSnapshotRequest(), snapshot="snapshot_value", + pubsub.GetSnapshotRequest(), + snapshot="snapshot_value", ) -@pytest.mark.parametrize("request_type", [pubsub.ListSnapshotsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.ListSnapshotsRequest, + dict, + ], +) def test_list_snapshots(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3022,7 +3361,8 @@ def test_list_snapshots_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3038,7 +3378,8 @@ async def test_list_snapshots_async( transport: str = "grpc_asyncio", request_type=pubsub.ListSnapshotsRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3049,7 +3390,9 @@ async def test_list_snapshots_async( with mock.patch.object(type(client.transport.list_snapshots), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - pubsub.ListSnapshotsResponse(next_page_token="next_page_token_value",) + pubsub.ListSnapshotsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_snapshots(request) @@ -3069,7 +3412,9 @@ async def test_list_snapshots_async_from_dict(): def test_list_snapshots_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3089,12 +3434,17 @@ def test_list_snapshots_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "project=project/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "project=project/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_snapshots_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3116,11 +3466,16 @@ async def test_list_snapshots_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "project=project/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "project=project/value", + ) in kw["metadata"] def test_list_snapshots_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_snapshots), "__call__") as call: @@ -3128,7 +3483,9 @@ def test_list_snapshots_flattened(): call.return_value = pubsub.ListSnapshotsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_snapshots(project="project_value",) + client.list_snapshots( + project="project_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3140,19 +3497,24 @@ def test_list_snapshots_flattened(): def test_list_snapshots_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_snapshots( - pubsub.ListSnapshotsRequest(), project="project_value", + pubsub.ListSnapshotsRequest(), + project="project_value", ) @pytest.mark.asyncio async def test_list_snapshots_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_snapshots), "__call__") as call: @@ -3164,7 +3526,9 @@ async def test_list_snapshots_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_snapshots(project="project_value",) + response = await client.list_snapshots( + project="project_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3177,19 +3541,23 @@ async def test_list_snapshots_flattened_async(): @pytest.mark.asyncio async def test_list_snapshots_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_snapshots( - pubsub.ListSnapshotsRequest(), project="project_value", + pubsub.ListSnapshotsRequest(), + project="project_value", ) def test_list_snapshots_pager(transport_name: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3197,15 +3565,28 @@ def test_list_snapshots_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(), pubsub.Snapshot(), pubsub.Snapshot(),], + snapshots=[ + pubsub.Snapshot(), + pubsub.Snapshot(), + pubsub.Snapshot(), + ], next_page_token="abc", ), - pubsub.ListSnapshotsResponse(snapshots=[], next_page_token="def",), pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(),], next_page_token="ghi", + snapshots=[], + next_page_token="def", + ), + pubsub.ListSnapshotsResponse( + snapshots=[ + pubsub.Snapshot(), + ], + next_page_token="ghi", ), pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(), pubsub.Snapshot(),], + snapshots=[ + pubsub.Snapshot(), + pubsub.Snapshot(), + ], ), RuntimeError, ) @@ -3225,7 +3606,8 @@ def test_list_snapshots_pager(transport_name: str = "grpc"): def test_list_snapshots_pages(transport_name: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3233,15 +3615,28 @@ def test_list_snapshots_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(), pubsub.Snapshot(), pubsub.Snapshot(),], + snapshots=[ + pubsub.Snapshot(), + pubsub.Snapshot(), + pubsub.Snapshot(), + ], next_page_token="abc", ), - pubsub.ListSnapshotsResponse(snapshots=[], next_page_token="def",), pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(),], next_page_token="ghi", + snapshots=[], + next_page_token="def", ), pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(), pubsub.Snapshot(),], + snapshots=[ + pubsub.Snapshot(), + ], + next_page_token="ghi", + ), + pubsub.ListSnapshotsResponse( + snapshots=[ + pubsub.Snapshot(), + pubsub.Snapshot(), + ], ), RuntimeError, ) @@ -3252,7 +3647,9 @@ def test_list_snapshots_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_snapshots_async_pager(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3261,19 +3658,34 @@ async def test_list_snapshots_async_pager(): # Set the response to a series of pages. call.side_effect = ( pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(), pubsub.Snapshot(), pubsub.Snapshot(),], + snapshots=[ + pubsub.Snapshot(), + pubsub.Snapshot(), + pubsub.Snapshot(), + ], next_page_token="abc", ), - pubsub.ListSnapshotsResponse(snapshots=[], next_page_token="def",), pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(),], next_page_token="ghi", + snapshots=[], + next_page_token="def", ), pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(), pubsub.Snapshot(),], + snapshots=[ + pubsub.Snapshot(), + ], + next_page_token="ghi", + ), + pubsub.ListSnapshotsResponse( + snapshots=[ + pubsub.Snapshot(), + pubsub.Snapshot(), + ], ), RuntimeError, ) - async_pager = await client.list_snapshots(request={},) + async_pager = await client.list_snapshots( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] async for response in async_pager: @@ -3285,7 +3697,9 @@ async def test_list_snapshots_async_pager(): @pytest.mark.asyncio async def test_list_snapshots_async_pages(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3294,15 +3708,28 @@ async def test_list_snapshots_async_pages(): # Set the response to a series of pages. call.side_effect = ( pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(), pubsub.Snapshot(), pubsub.Snapshot(),], + snapshots=[ + pubsub.Snapshot(), + pubsub.Snapshot(), + pubsub.Snapshot(), + ], next_page_token="abc", ), - pubsub.ListSnapshotsResponse(snapshots=[], next_page_token="def",), pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(),], next_page_token="ghi", + snapshots=[], + next_page_token="def", + ), + pubsub.ListSnapshotsResponse( + snapshots=[ + pubsub.Snapshot(), + ], + next_page_token="ghi", ), pubsub.ListSnapshotsResponse( - snapshots=[pubsub.Snapshot(), pubsub.Snapshot(),], + snapshots=[ + pubsub.Snapshot(), + pubsub.Snapshot(), + ], ), RuntimeError, ) @@ -3313,10 +3740,17 @@ async def test_list_snapshots_async_pages(): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [pubsub.CreateSnapshotRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.CreateSnapshotRequest, + dict, + ], +) def test_create_snapshot(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3326,7 +3760,10 @@ def test_create_snapshot(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_snapshot), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = pubsub.Snapshot(name="name_value", topic="topic_value",) + call.return_value = pubsub.Snapshot( + name="name_value", + topic="topic_value", + ) response = client.create_snapshot(request) # Establish that the underlying gRPC stub method was called. @@ -3344,7 +3781,8 @@ def test_create_snapshot_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3360,7 +3798,8 @@ async def test_create_snapshot_async( transport: str = "grpc_asyncio", request_type=pubsub.CreateSnapshotRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3371,7 +3810,10 @@ async def test_create_snapshot_async( with mock.patch.object(type(client.transport.create_snapshot), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - pubsub.Snapshot(name="name_value", topic="topic_value",) + pubsub.Snapshot( + name="name_value", + topic="topic_value", + ) ) response = await client.create_snapshot(request) @@ -3392,7 +3834,9 @@ async def test_create_snapshot_async_from_dict(): def test_create_snapshot_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3412,12 +3856,17 @@ def test_create_snapshot_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_snapshot_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3437,11 +3886,16 @@ async def test_create_snapshot_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name/value", + ) in kw["metadata"] def test_create_snapshot_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_snapshot), "__call__") as call: @@ -3450,7 +3904,8 @@ def test_create_snapshot_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_snapshot( - name="name_value", subscription="subscription_value", + name="name_value", + subscription="subscription_value", ) # Establish that the underlying call was made with the expected @@ -3466,7 +3921,9 @@ def test_create_snapshot_flattened(): def test_create_snapshot_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3480,7 +3937,9 @@ def test_create_snapshot_flattened_error(): @pytest.mark.asyncio async def test_create_snapshot_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_snapshot), "__call__") as call: @@ -3491,7 +3950,8 @@ async def test_create_snapshot_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_snapshot( - name="name_value", subscription="subscription_value", + name="name_value", + subscription="subscription_value", ) # Establish that the underlying call was made with the expected @@ -3508,7 +3968,9 @@ async def test_create_snapshot_flattened_async(): @pytest.mark.asyncio async def test_create_snapshot_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3520,10 +3982,17 @@ async def test_create_snapshot_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [pubsub.UpdateSnapshotRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.UpdateSnapshotRequest, + dict, + ], +) def test_update_snapshot(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3533,7 +4002,10 @@ def test_update_snapshot(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_snapshot), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = pubsub.Snapshot(name="name_value", topic="topic_value",) + call.return_value = pubsub.Snapshot( + name="name_value", + topic="topic_value", + ) response = client.update_snapshot(request) # Establish that the underlying gRPC stub method was called. @@ -3551,7 +4023,8 @@ def test_update_snapshot_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3567,7 +4040,8 @@ async def test_update_snapshot_async( transport: str = "grpc_asyncio", request_type=pubsub.UpdateSnapshotRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3578,7 +4052,10 @@ async def test_update_snapshot_async( with mock.patch.object(type(client.transport.update_snapshot), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - pubsub.Snapshot(name="name_value", topic="topic_value",) + pubsub.Snapshot( + name="name_value", + topic="topic_value", + ) ) response = await client.update_snapshot(request) @@ -3599,7 +4076,9 @@ async def test_update_snapshot_async_from_dict(): def test_update_snapshot_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3619,14 +4098,17 @@ def test_update_snapshot_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "snapshot.name=snapshot.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "snapshot.name=snapshot.name/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_snapshot_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3646,15 +4128,23 @@ async def test_update_snapshot_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "snapshot.name=snapshot.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "snapshot.name=snapshot.name/value", + ) in kw["metadata"] -@pytest.mark.parametrize("request_type", [pubsub.DeleteSnapshotRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.DeleteSnapshotRequest, + dict, + ], +) def test_delete_snapshot(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3680,7 +4170,8 @@ def test_delete_snapshot_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3696,7 +4187,8 @@ async def test_delete_snapshot_async( transport: str = "grpc_asyncio", request_type=pubsub.DeleteSnapshotRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3724,7 +4216,9 @@ async def test_delete_snapshot_async_from_dict(): def test_delete_snapshot_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3744,12 +4238,17 @@ def test_delete_snapshot_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "snapshot=snapshot/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "snapshot=snapshot/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_snapshot_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3769,11 +4268,16 @@ async def test_delete_snapshot_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "snapshot=snapshot/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "snapshot=snapshot/value", + ) in kw["metadata"] def test_delete_snapshot_flattened(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_snapshot), "__call__") as call: @@ -3781,7 +4285,9 @@ def test_delete_snapshot_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_snapshot(snapshot="snapshot_value",) + client.delete_snapshot( + snapshot="snapshot_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3793,19 +4299,24 @@ def test_delete_snapshot_flattened(): def test_delete_snapshot_flattened_error(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_snapshot( - pubsub.DeleteSnapshotRequest(), snapshot="snapshot_value", + pubsub.DeleteSnapshotRequest(), + snapshot="snapshot_value", ) @pytest.mark.asyncio async def test_delete_snapshot_flattened_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_snapshot), "__call__") as call: @@ -3815,7 +4326,9 @@ async def test_delete_snapshot_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_snapshot(snapshot="snapshot_value",) + response = await client.delete_snapshot( + snapshot="snapshot_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3828,20 +4341,30 @@ async def test_delete_snapshot_flattened_async(): @pytest.mark.asyncio async def test_delete_snapshot_flattened_error_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_snapshot( - pubsub.DeleteSnapshotRequest(), snapshot="snapshot_value", + pubsub.DeleteSnapshotRequest(), + snapshot="snapshot_value", ) -@pytest.mark.parametrize("request_type", [pubsub.SeekRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + pubsub.SeekRequest, + dict, + ], +) def test_seek(request_type, transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3867,7 +4390,8 @@ def test_seek_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3883,7 +4407,8 @@ async def test_seek_async( transport: str = "grpc_asyncio", request_type=pubsub.SeekRequest ): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3911,7 +4436,9 @@ async def test_seek_async_from_dict(): def test_seek_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3931,14 +4458,17 @@ def test_seek_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_seek_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -3958,9 +4488,10 @@ async def test_seek_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "subscription=subscription/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "subscription=subscription/value", + ) in kw["metadata"] def test_credentials_transport_error(): @@ -3970,7 +4501,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -3990,7 +4522,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = SubscriberClient(client_options=options, transport=transport,) + client = SubscriberClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -4006,7 +4541,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = SubscriberClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -4036,7 +4572,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.SubscriberGrpcTransport, transports.SubscriberGrpcAsyncIOTransport,], + [ + transports.SubscriberGrpcTransport, + transports.SubscriberGrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -4048,8 +4587,13 @@ def test_transport_adc(transport_class): def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.SubscriberGrpcTransport,) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.SubscriberGrpcTransport, + ) def test_subscriber_base_transport_error(): @@ -4112,7 +4656,8 @@ def test_subscriber_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.SubscriberTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -4153,7 +4698,10 @@ def test_subscriber_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.SubscriberGrpcTransport, transports.SubscriberGrpcAsyncIOTransport,], + [ + transports.SubscriberGrpcTransport, + transports.SubscriberGrpcAsyncIOTransport, + ], ) def test_subscriber_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -4280,7 +4828,8 @@ def test_subscriber_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.SubscriberGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4292,7 +4841,8 @@ def test_subscriber_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.SubscriberGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4399,7 +4949,8 @@ def test_snapshot_path(): project = "squid" snapshot = "clam" expected = "projects/{project}/snapshots/{snapshot}".format( - project=project, snapshot=snapshot, + project=project, + snapshot=snapshot, ) actual = SubscriberClient.snapshot_path(project, snapshot) assert expected == actual @@ -4421,7 +4972,8 @@ def test_subscription_path(): project = "oyster" subscription = "nudibranch" expected = "projects/{project}/subscriptions/{subscription}".format( - project=project, subscription=subscription, + project=project, + subscription=subscription, ) actual = SubscriberClient.subscription_path(project, subscription) assert expected == actual @@ -4442,7 +4994,10 @@ def test_parse_subscription_path(): def test_topic_path(): project = "winkle" topic = "nautilus" - expected = "projects/{project}/topics/{topic}".format(project=project, topic=topic,) + expected = "projects/{project}/topics/{topic}".format( + project=project, + topic=topic, + ) actual = SubscriberClient.topic_path(project, topic) assert expected == actual @@ -4481,7 +5036,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "whelk" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = SubscriberClient.common_folder_path(folder) assert expected == actual @@ -4499,7 +5056,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "oyster" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = SubscriberClient.common_organization_path(organization) assert expected == actual @@ -4517,7 +5076,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "cuttlefish" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = SubscriberClient.common_project_path(project) assert expected == actual @@ -4537,7 +5098,8 @@ def test_common_location_path(): project = "winkle" location = "nautilus" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = SubscriberClient.common_location_path(project, location) assert expected == actual @@ -4562,7 +5124,8 @@ def test_client_with_default_client_info(): transports.SubscriberTransport, "_prep_wrapped_messages" ) as prep: client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4571,14 +5134,16 @@ def test_client_with_default_client_info(): ) as prep: transport_class = SubscriberClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) def test_set_iam_policy(transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4588,7 +5153,10 @@ def test_set_iam_policy(transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) @@ -4609,7 +5177,8 @@ def test_set_iam_policy(transport: str = "grpc"): @pytest.mark.asyncio async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4620,7 +5189,10 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -4640,7 +5212,9 @@ async def test_set_iam_policy_async(transport: str = "grpc_asyncio"): def test_set_iam_policy_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -4660,12 +5234,17 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -4685,11 +5264,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_set_iam_policy_from_dict(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -4706,7 +5290,9 @@ def test_set_iam_policy_from_dict(): @pytest.mark.asyncio async def test_set_iam_policy_from_dict_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -4723,7 +5309,8 @@ async def test_set_iam_policy_from_dict_async(): def test_get_iam_policy(transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4733,7 +5320,10 @@ def test_get_iam_policy(transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) @@ -4754,7 +5344,8 @@ def test_get_iam_policy(transport: str = "grpc"): @pytest.mark.asyncio async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4765,7 +5356,10 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -4785,7 +5379,9 @@ async def test_get_iam_policy_async(transport: str = "grpc_asyncio"): def test_get_iam_policy_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -4805,12 +5401,17 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -4830,11 +5431,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_get_iam_policy_from_dict(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -4851,7 +5457,9 @@ def test_get_iam_policy_from_dict(): @pytest.mark.asyncio async def test_get_iam_policy_from_dict_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -4868,7 +5476,8 @@ async def test_get_iam_policy_from_dict_async(): def test_test_iam_permissions(transport: str = "grpc"): client = SubscriberClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4901,7 +5510,8 @@ def test_test_iam_permissions(transport: str = "grpc"): @pytest.mark.asyncio async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4934,7 +5544,9 @@ async def test_test_iam_permissions_async(transport: str = "grpc_asyncio"): def test_test_iam_permissions_field_headers(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -4956,12 +5568,17 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. @@ -4985,11 +5602,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource/value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict(): - client = SubscriberClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -5008,7 +5630,9 @@ def test_test_iam_permissions_from_dict(): @pytest.mark.asyncio async def test_test_iam_permissions_from_dict_async(): - client = SubscriberAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = SubscriberAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -5030,7 +5654,8 @@ async def test_test_iam_permissions_from_dict_async(): @pytest.mark.asyncio async def test_transport_close_async(): client = SubscriberAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/pubsub_v1/publisher/sequencer/test_ordered_sequencer.py b/tests/unit/pubsub_v1/publisher/sequencer/test_ordered_sequencer.py index 09795d37b..7384af2a2 100644 --- a/tests/unit/pubsub_v1/publisher/sequencer/test_ordered_sequencer.py +++ b/tests/unit/pubsub_v1/publisher/sequencer/test_ordered_sequencer.py @@ -25,7 +25,7 @@ def create_message(): - return gapic_types.PubsubMessage(data=b"foo", attributes={"bar": u"baz"}) + return gapic_types.PubsubMessage(data=b"foo", attributes={"bar": "baz"}) def create_client(): diff --git a/tests/unit/pubsub_v1/publisher/sequencer/test_unordered_sequencer.py b/tests/unit/pubsub_v1/publisher/sequencer/test_unordered_sequencer.py index 486cba5f7..ee0cfab83 100644 --- a/tests/unit/pubsub_v1/publisher/sequencer/test_unordered_sequencer.py +++ b/tests/unit/pubsub_v1/publisher/sequencer/test_unordered_sequencer.py @@ -24,7 +24,7 @@ def create_message(): - return gapic_types.PubsubMessage(data=b"foo", attributes={"bar": u"baz"}) + return gapic_types.PubsubMessage(data=b"foo", attributes={"bar": "baz"}) def create_client(): diff --git a/tests/unit/pubsub_v1/publisher/test_publisher_client.py b/tests/unit/pubsub_v1/publisher/test_publisher_client.py index 20d5b328c..372f53015 100644 --- a/tests/unit/pubsub_v1/publisher/test_publisher_client.py +++ b/tests/unit/pubsub_v1/publisher/test_publisher_client.py @@ -308,7 +308,7 @@ def test_publish_with_ordering_key_uses_extended_retry_deadline(creds): _, kwargs = batch_class.call_args batch_commit_retry = kwargs["commit_retry"] - expected_retry = custom_retry.with_deadline(2.0 ** 32) + expected_retry = custom_retry.with_deadline(2.0**32) _assert_retries_equal(batch_commit_retry, expected_retry) diff --git a/tests/unit/pubsub_v1/subscriber/test_dispatcher.py b/tests/unit/pubsub_v1/subscriber/test_dispatcher.py index bbc6170e2..c1de19e65 100644 --- a/tests/unit/pubsub_v1/subscriber/test_dispatcher.py +++ b/tests/unit/pubsub_v1/subscriber/test_dispatcher.py @@ -245,7 +245,13 @@ def test_retry_modacks_in_new_thread(): dispatcher_ = dispatcher.Dispatcher(manager, mock.sentinel.queue) f = futures.Future() - items = [requests.ModAckRequest(ack_id="ack_id_string", seconds=20, future=f,)] + items = [ + requests.ModAckRequest( + ack_id="ack_id_string", + seconds=20, + future=f, + ) + ] # failure triggers creation of new retry thread manager.send_unary_modack.side_effect = [([], items)] with mock.patch("time.sleep", return_value=None): @@ -266,7 +272,13 @@ def test_retry_modacks(): dispatcher_ = dispatcher.Dispatcher(manager, mock.sentinel.queue) f = futures.Future() - items = [requests.ModAckRequest(ack_id="ack_id_string", seconds=20, future=f,)] + items = [ + requests.ModAckRequest( + ack_id="ack_id_string", + seconds=20, + future=f, + ) + ] # first and second calls fail, third one succeeds manager.send_unary_modack.side_effect = [([], items), ([], items), (items, [])] with mock.patch("time.sleep", return_value=None):