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 plamut committed Jul 10, 2020
1 parent 010ad9d commit 0f83623
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 0f83623

Please sign in to comment.