From 0f83623c346a8ef56a6d9069a21cf9570f591fd0 Mon Sep 17 00:00:00 2001 From: noerog <32459203+noerog@users.noreply.github.com> Date: Thu, 25 Jan 2018 13:41:26 -0500 Subject: [PATCH] Add tests for creating push subscription. [(#1332)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1332) This is a separate PR from actually adding the sample, which is in https://github.com/GoogleCloudPlatform/python-docs-samples/pull/1331. --- samples/snippets/subscriber_test.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/samples/snippets/subscriber_test.py b/samples/snippets/subscriber_test.py index 8b5e97ac4..0999e1218 100644 --- a/samples/snippets/subscriber_test.py +++ b/samples/snippets/subscriber_test.py @@ -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') @@ -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)