Skip to content

Commit

Permalink
chore: remove gcp-devrel-py-tools from iot and pubsub [(#3470)](Googl…
Browse files Browse the repository at this point in the history
…eCloudPlatform/python-docs-samples#3470)

* [iot] chore: remove unused dependency

* [pubsub] chore: remove gcp-devrel-py-tools
  • Loading branch information
Takashi Matsuo authored and plamut committed Jul 10, 2020
1 parent cca0219 commit c2daa69
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
20 changes: 13 additions & 7 deletions samples/snippets/publisher_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import time
import uuid

from gcp_devrel.testing import eventually_consistent
import backoff
from google.cloud import pubsub_v1
import mock
import pytest
Expand Down Expand Up @@ -75,12 +75,14 @@ def new_sleep(period):


def test_list(client, topic_admin, capsys):
@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
publisher.list_topics(PROJECT)
out, _ = capsys.readouterr()
assert topic_admin in out

eventually_consistent_test()


def test_create(client):
topic_path = client.topic_path(PROJECT, TOPIC_ADMIN)
Expand All @@ -91,19 +93,23 @@ def test_create(client):

publisher.create_topic(PROJECT, TOPIC_ADMIN)

@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
assert client.get_topic(topic_path)

eventually_consistent_test()


def test_delete(client, topic_admin):
publisher.delete_topic(PROJECT, TOPIC_ADMIN)

@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
with pytest.raises(Exception):
client.get_topic(client.topic_path(PROJECT, TOPIC_ADMIN))

eventually_consistent_test()


def test_publish(topic_publish, capsys):
publisher.publish_messages(PROJECT, TOPIC_PUBLISH)
Expand Down
3 changes: 1 addition & 2 deletions samples/snippets/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
backoff==1.10.0
pytest==5.3.2
gcp-devrel-py-tools==0.0.15
mock==3.0.5
google-cloud-core==1.3.0
32 changes: 21 additions & 11 deletions samples/snippets/subscriber_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os
import uuid

from gcp_devrel.testing import eventually_consistent
import backoff
from google.cloud import pubsub_v1
import pytest

Expand Down Expand Up @@ -110,20 +110,24 @@ def subscription_async(subscriber_client, topic):


def test_list_in_topic(subscription_admin, capsys):
@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
subscriber.list_subscriptions_in_topic(PROJECT, TOPIC)
out, _ = capsys.readouterr()
assert subscription_admin in out

eventually_consistent_test()


def test_list_in_project(subscription_admin, capsys):
@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
subscriber.list_subscriptions_in_project(PROJECT)
out, _ = capsys.readouterr()
assert subscription_admin in out

eventually_consistent_test()


def test_create(subscriber_client):
subscription_path = subscriber_client.subscription_path(
Expand All @@ -137,10 +141,12 @@ def test_create(subscriber_client):

subscriber.create_subscription(PROJECT, TOPIC, SUBSCRIPTION_ADMIN)

@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
assert subscriber_client.get_subscription(subscription_path)

eventually_consistent_test()


def test_create_push(subscriber_client):
subscription_path = subscriber_client.subscription_path(
Expand All @@ -155,10 +161,12 @@ def test_create_push(subscriber_client):
PROJECT, TOPIC, SUBSCRIPTION_ADMIN, ENDPOINT
)

@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
assert subscriber_client.get_subscription(subscription_path)

eventually_consistent_test()


def test_update(subscriber_client, subscription_admin, capsys):
subscriber.update_subscription(PROJECT, SUBSCRIPTION_ADMIN, NEW_ENDPOINT)
Expand All @@ -170,11 +178,13 @@ def test_update(subscriber_client, subscription_admin, capsys):
def test_delete(subscriber_client, subscription_admin):
subscriber.delete_subscription(PROJECT, SUBSCRIPTION_ADMIN)

@eventually_consistent.call
def _():
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
def eventually_consistent_test():
with pytest.raises(Exception):
subscriber_client.get_subscription(subscription_admin)

eventually_consistent_test()


def _publish_messages(publisher_client, topic):
for n in range(5):
Expand Down

0 comments on commit c2daa69

Please sign in to comment.