Skip to content

Commit

Permalink
Fix update test to use new endpoint [(#1925)](GoogleCloudPlatform/pyt…
Browse files Browse the repository at this point in the history
…hon-docs-samples#1925)

* Fix update test to use new endpoint

* Handle subscription already exists

Previous deletions don't always succeed

* Use a new endpoint for update
  • Loading branch information
engelke authored and plamut committed Jul 10, 2020
1 parent 31d8762 commit aa05874
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions samples/snippets/subscriber_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -28,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')
Expand Down Expand Up @@ -64,7 +66,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

Expand Down Expand Up @@ -155,13 +160,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, NEW_ENDPOINT)

out, _ = capsys.readouterr()
assert subscription in out
assert '100' in out
assert 'Subscription updated' in out


def _publish_messages(publisher_client, topic):
Expand Down

0 comments on commit aa05874

Please sign in to comment.