From 6dbdd3f8b6bb12926f848d8f9ade75612df4caab Mon Sep 17 00:00:00 2001 From: Peter Lamut Date: Mon, 23 Mar 2020 11:26:04 +0100 Subject: [PATCH 1/2] test: cover the fix for sync pull with no messages --- tests/system.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/system.py b/tests/system.py index 2eccad8ed..a40bbb14a 100644 --- a/tests/system.py +++ b/tests/system.py @@ -27,6 +27,7 @@ import six import google.auth +from google.api_core import exceptions as core_exceptions from google.cloud import pubsub_v1 from google.cloud.pubsub_v1 import exceptions from google.cloud.pubsub_v1 import futures @@ -432,6 +433,28 @@ def one_arg_close(subscriber): # the cleanup helper expects exactly one argumen assert conn_count_end == conn_count_start +def test_synchronous_pull_no_deadline_error_if_no_messages( + publisher, topic_path, subscriber, subscription_path, cleanup +): + # Make sure the topic and subscription get deleted. + cleanup.append((publisher.delete_topic, topic_path)) + cleanup.append((subscriber.delete_subscription, subscription_path)) + + # Create a topic and subscribe to it. + publisher.create_topic(topic_path) + subscriber.create_subscription(subscription_path, topic_path) + + try: + response = subscriber.pull(subscription_path, max_messages=2) + except core_exceptions.DeadlineExceeded: + pytest.fail( + "Unexpected DeadlineExceeded error on syncronous pull when no " + "messages published to the topic." + ) + else: + assert list(response.received_messages) == [] + + class TestStreamingPull(object): def test_streaming_pull_callback_error_propagation( self, publisher, topic_path, subscriber, subscription_path, cleanup From aa3e4dd4c17356f2c2d97de2127a70b98bbc5bc0 Mon Sep 17 00:00:00 2001 From: Peter Lamut Date: Tue, 24 Mar 2020 09:07:29 +0100 Subject: [PATCH 2/2] Fix typo in test failure message --- tests/system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/system.py b/tests/system.py index a40bbb14a..81c196ccc 100644 --- a/tests/system.py +++ b/tests/system.py @@ -448,7 +448,7 @@ def test_synchronous_pull_no_deadline_error_if_no_messages( response = subscriber.pull(subscription_path, max_messages=2) except core_exceptions.DeadlineExceeded: pytest.fail( - "Unexpected DeadlineExceeded error on syncronous pull when no " + "Unexpected DeadlineExceeded error on synchronous pull when no " "messages published to the topic." ) else: