Skip to content

Commit

Permalink
🦉 Updates from OwlBot post-processor
Browse files Browse the repository at this point in the history
  • Loading branch information
gcf-owl-bot[bot] authored and mukund-ananthu committed Feb 9, 2024
1 parent 6ed4334 commit a4413f7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
3 changes: 1 addition & 2 deletions tests/unit/gapic/pubsub_v1/test_publisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,8 +1738,7 @@ 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
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/pubsub_v1/publisher/test_publisher_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,33 @@ def test_publish_with_ordering_key_uses_extended_retry_deadline(creds):
expected_retry = custom_retry.with_deadline(2.0**32)
_assert_retries_equal(batch_commit_retry, expected_retry)

def test_publish_with_ordering_key_with_no_retry(creds):
client = publisher.Client(
credentials=creds,
publisher_options=types.PublisherOptions(enable_message_ordering=True),
)

# Use mocks in lieu of the actual batch class.
batch = mock.Mock(spec=client._batch_class)
future = mock.sentinel.future
future.add_done_callback = mock.Mock(spec=["__call__"])
batch.publish.return_value = future

topic = "topic/path"
client._set_batch(topic, batch)

# Actually mock the batch class now.
batch_class = mock.Mock(spec=(), return_value=batch)
client._set_batch_class(batch_class)

future = client.publish(topic, b"foo", ordering_key="first", retry=None)
assert future is mock.sentinel.future

# Check the retry settings used for the batch.
batch_class.assert_called_once()




def test_publish_attrs_bytestring(creds):
client = publisher.Client(credentials=creds)
Expand Down

0 comments on commit a4413f7

Please sign in to comment.