Skip to content

Commit

Permalink
Add tests for creating push subscription. [(#1332)](GoogleCloudPlatfo…
Browse files Browse the repository at this point in the history
…rm/python-docs-samples#1332)

This is a separate PR from actually adding the sample, which is in GoogleCloudPlatform/python-docs-samples#1331.
  • Loading branch information
noerog authored and Jon Wayne Parrott committed Jan 25, 2018
1 parent 308acd4 commit 4a63dad
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions samples/snippets/subscriber_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
PROJECT = os.environ['GCLOUD_PROJECT']
TOPIC = 'subscription-test-topic'
SUBSCRIPTION = 'subscription-test-subscription'
ENDPOINT = 'https://{}.appspot.com/push'.format(PROJECT)


@pytest.fixture(scope='module')
Expand Down Expand Up @@ -97,6 +98,21 @@ def _():
assert subscriber_client.get_subscription(subscription_path)


def test_create_push(subscriber_client):
subscription_path = subscriber_client.subscription_path(
PROJECT, SUBSCRIPTION)
try:
subscriber_client.delete_subscription(subscription_path)
except Exception:
pass

subscriber.create_push_subscription(PROJECT, TOPIC, SUBSCRIPTION, ENDPOINT)

@eventually_consistent.call
def _():
assert subscriber_client.get_subscription(subscription_path)


def test_delete(subscriber_client, subscription):
subscriber.delete_subscription(PROJECT, SUBSCRIPTION)

Expand Down

0 comments on commit 4a63dad

Please sign in to comment.