From 9767d193db6a1848fbbaf59e72030e1d61271b27 Mon Sep 17 00:00:00 2001 From: Charles Engelke Date: Wed, 12 Dec 2018 11:12:57 -0800 Subject: [PATCH 1/3] Fix update test to use new endpoint --- pubsub/cloud-client/subscriber_test.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pubsub/cloud-client/subscriber_test.py b/pubsub/cloud-client/subscriber_test.py index 3f5de61de8..f11ce79cb6 100644 --- a/pubsub/cloud-client/subscriber_test.py +++ b/pubsub/cloud-client/subscriber_test.py @@ -155,13 +155,10 @@ def _(): def test_update(subscriber_client, subscription, capsys): - ACK_DEADLINE_SECONDS = 100 - - subscriber.update_subscription(PROJECT, SUBSCRIPTION, ACK_DEADLINE_SECONDS) + subscriber.update_subscription(PROJECT, SUBSCRIPTION, ENDPOINT) out, _ = capsys.readouterr() - assert subscription in out - assert '100' in out + assert 'Subscription updated' in out def _publish_messages(publisher_client, topic): From 94a5e9ed26df9fa84b5c222c61d95663424395e7 Mon Sep 17 00:00:00 2001 From: Charles Engelke Date: Wed, 12 Dec 2018 12:11:26 -0800 Subject: [PATCH 2/3] Handle subscription already exists Previous deletions don't always succeed --- pubsub/cloud-client/subscriber_test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pubsub/cloud-client/subscriber_test.py b/pubsub/cloud-client/subscriber_test.py index f11ce79cb6..d54436664a 100644 --- a/pubsub/cloud-client/subscriber_test.py +++ b/pubsub/cloud-client/subscriber_test.py @@ -17,6 +17,7 @@ from gcp_devrel.testing import eventually_consistent from google.cloud import pubsub_v1 +import google.api_core.exceptions import mock import pytest @@ -64,7 +65,10 @@ def subscription(subscriber_client, topic): except Exception: pass - subscriber_client.create_subscription(subscription_path, topic=topic) + try: + subscriber_client.create_subscription(subscription_path, topic=topic) + except google.api_core.exceptions.AlreadyExists: + pass yield subscription_path From 2db170014cec8051f8b4937a84771261a9e310fe Mon Sep 17 00:00:00 2001 From: Charles Engelke Date: Wed, 12 Dec 2018 15:37:15 -0800 Subject: [PATCH 3/3] Use a new endpoint for update --- pubsub/cloud-client/subscriber_test.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubsub/cloud-client/subscriber_test.py b/pubsub/cloud-client/subscriber_test.py index d54436664a..df5b1092ba 100644 --- a/pubsub/cloud-client/subscriber_test.py +++ b/pubsub/cloud-client/subscriber_test.py @@ -29,6 +29,7 @@ SUBSCRIPTION_SYNC1 = 'subscription-test-subscription-sync1' SUBSCRIPTION_SYNC2 = 'subscription-test-subscription-sync2' ENDPOINT = 'https://{}.appspot.com/push'.format(PROJECT) +NEW_ENDPOINT = 'https://{}.appspot.com/push2'.format(PROJECT) @pytest.fixture(scope='module') @@ -159,7 +160,7 @@ def _(): def test_update(subscriber_client, subscription, capsys): - subscriber.update_subscription(PROJECT, SUBSCRIPTION, ENDPOINT) + subscriber.update_subscription(PROJECT, SUBSCRIPTION, NEW_ENDPOINT) out, _ = capsys.readouterr() assert 'Subscription updated' in out