Skip to content

Commit c2daa69

Browse files
Takashi Matsuoplamut
Takashi Matsuo
authored andcommitted
chore: remove gcp-devrel-py-tools from iot and pubsub [(#3470)](GoogleCloudPlatform/python-docs-samples#3470)
* [iot] chore: remove unused dependency * [pubsub] chore: remove gcp-devrel-py-tools
1 parent cca0219 commit c2daa69

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

samples/snippets/publisher_test.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import time
1717
import uuid
1818

19-
from gcp_devrel.testing import eventually_consistent
19+
import backoff
2020
from google.cloud import pubsub_v1
2121
import mock
2222
import pytest
@@ -75,12 +75,14 @@ def new_sleep(period):
7575

7676

7777
def test_list(client, topic_admin, capsys):
78-
@eventually_consistent.call
79-
def _():
78+
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
79+
def eventually_consistent_test():
8080
publisher.list_topics(PROJECT)
8181
out, _ = capsys.readouterr()
8282
assert topic_admin in out
8383

84+
eventually_consistent_test()
85+
8486

8587
def test_create(client):
8688
topic_path = client.topic_path(PROJECT, TOPIC_ADMIN)
@@ -91,19 +93,23 @@ def test_create(client):
9193

9294
publisher.create_topic(PROJECT, TOPIC_ADMIN)
9395

94-
@eventually_consistent.call
95-
def _():
96+
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
97+
def eventually_consistent_test():
9698
assert client.get_topic(topic_path)
9799

100+
eventually_consistent_test()
101+
98102

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

102-
@eventually_consistent.call
103-
def _():
106+
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
107+
def eventually_consistent_test():
104108
with pytest.raises(Exception):
105109
client.get_topic(client.topic_path(PROJECT, TOPIC_ADMIN))
106110

111+
eventually_consistent_test()
112+
107113

108114
def test_publish(topic_publish, capsys):
109115
publisher.publish_messages(PROJECT, TOPIC_PUBLISH)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1+
backoff==1.10.0
12
pytest==5.3.2
2-
gcp-devrel-py-tools==0.0.15
33
mock==3.0.5
4-
google-cloud-core==1.3.0

samples/snippets/subscriber_test.py

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import os
1616
import uuid
1717

18-
from gcp_devrel.testing import eventually_consistent
18+
import backoff
1919
from google.cloud import pubsub_v1
2020
import pytest
2121

@@ -110,20 +110,24 @@ def subscription_async(subscriber_client, topic):
110110

111111

112112
def test_list_in_topic(subscription_admin, capsys):
113-
@eventually_consistent.call
114-
def _():
113+
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
114+
def eventually_consistent_test():
115115
subscriber.list_subscriptions_in_topic(PROJECT, TOPIC)
116116
out, _ = capsys.readouterr()
117117
assert subscription_admin in out
118118

119+
eventually_consistent_test()
120+
119121

120122
def test_list_in_project(subscription_admin, capsys):
121-
@eventually_consistent.call
122-
def _():
123+
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
124+
def eventually_consistent_test():
123125
subscriber.list_subscriptions_in_project(PROJECT)
124126
out, _ = capsys.readouterr()
125127
assert subscription_admin in out
126128

129+
eventually_consistent_test()
130+
127131

128132
def test_create(subscriber_client):
129133
subscription_path = subscriber_client.subscription_path(
@@ -137,10 +141,12 @@ def test_create(subscriber_client):
137141

138142
subscriber.create_subscription(PROJECT, TOPIC, SUBSCRIPTION_ADMIN)
139143

140-
@eventually_consistent.call
141-
def _():
144+
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
145+
def eventually_consistent_test():
142146
assert subscriber_client.get_subscription(subscription_path)
143147

148+
eventually_consistent_test()
149+
144150

145151
def test_create_push(subscriber_client):
146152
subscription_path = subscriber_client.subscription_path(
@@ -155,10 +161,12 @@ def test_create_push(subscriber_client):
155161
PROJECT, TOPIC, SUBSCRIPTION_ADMIN, ENDPOINT
156162
)
157163

158-
@eventually_consistent.call
159-
def _():
164+
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
165+
def eventually_consistent_test():
160166
assert subscriber_client.get_subscription(subscription_path)
161167

168+
eventually_consistent_test()
169+
162170

163171
def test_update(subscriber_client, subscription_admin, capsys):
164172
subscriber.update_subscription(PROJECT, SUBSCRIPTION_ADMIN, NEW_ENDPOINT)
@@ -170,11 +178,13 @@ def test_update(subscriber_client, subscription_admin, capsys):
170178
def test_delete(subscriber_client, subscription_admin):
171179
subscriber.delete_subscription(PROJECT, SUBSCRIPTION_ADMIN)
172180

173-
@eventually_consistent.call
174-
def _():
181+
@backoff.on_exception(backoff.expo, AssertionError, max_time=60)
182+
def eventually_consistent_test():
175183
with pytest.raises(Exception):
176184
subscriber_client.get_subscription(subscription_admin)
177185

186+
eventually_consistent_test()
187+
178188

179189
def _publish_messages(publisher_client, topic):
180190
for n in range(5):

0 commit comments

Comments
 (0)