Skip to content

Commit 48701ca

Browse files
authored
Fix update test to use new endpoint (GoogleCloudPlatform#1925)
* Fix update test to use new endpoint * Handle subscription already exists Previous deletions don't always succeed * Use a new endpoint for update
1 parent 9677117 commit 48701ca

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pubsub/cloud-client/subscriber_test.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from gcp_devrel.testing import eventually_consistent
1919
from google.cloud import pubsub_v1
20+
import google.api_core.exceptions
2021
import mock
2122
import pytest
2223

@@ -28,6 +29,7 @@
2829
SUBSCRIPTION_SYNC1 = 'subscription-test-subscription-sync1'
2930
SUBSCRIPTION_SYNC2 = 'subscription-test-subscription-sync2'
3031
ENDPOINT = 'https://{}.appspot.com/push'.format(PROJECT)
32+
NEW_ENDPOINT = 'https://{}.appspot.com/push2'.format(PROJECT)
3133

3234

3335
@pytest.fixture(scope='module')
@@ -64,7 +66,10 @@ def subscription(subscriber_client, topic):
6466
except Exception:
6567
pass
6668

67-
subscriber_client.create_subscription(subscription_path, topic=topic)
69+
try:
70+
subscriber_client.create_subscription(subscription_path, topic=topic)
71+
except google.api_core.exceptions.AlreadyExists:
72+
pass
6873

6974
yield subscription_path
7075

@@ -155,13 +160,10 @@ def _():
155160

156161

157162
def test_update(subscriber_client, subscription, capsys):
158-
ACK_DEADLINE_SECONDS = 100
159-
160-
subscriber.update_subscription(PROJECT, SUBSCRIPTION, ACK_DEADLINE_SECONDS)
163+
subscriber.update_subscription(PROJECT, SUBSCRIPTION, NEW_ENDPOINT)
161164

162165
out, _ = capsys.readouterr()
163-
assert subscription in out
164-
assert '100' in out
166+
assert 'Subscription updated' in out
165167

166168

167169
def _publish_messages(publisher_client, topic):

0 commit comments

Comments
 (0)