Skip to content

Commit a2e3312

Browse files
committed
Add E2E regression test for message publication + pull.
1 parent 18a8330 commit a2e3312

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

regression/pubsub.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,27 @@ def test_list_subscriptions(self):
100100
if subscription.name in subscriptions_to_create and
101101
subscription.topic.name == TOPIC_NAME]
102102
self.assertEqual(len(created), len(subscriptions_to_create))
103+
104+
def test_message_pull_mode_e2e(self):
105+
from base64 import b64encode as b64
106+
TOPIC_NAME = 'subscribe-me'
107+
topic = Topic(TOPIC_NAME)
108+
self.assertFalse(topic.exists())
109+
topic.create()
110+
self.to_delete.append(topic)
111+
SUBSCRIPTION_NAME = 'subscribing-now'
112+
subscription = Subscription(SUBSCRIPTION_NAME, topic)
113+
self.assertFalse(subscription.exists())
114+
subscription.create()
115+
self.to_delete.append(subscription)
116+
117+
MESSAGE = b'MESSAGE'
118+
EXTRA = b'EXTRA TWO'
119+
topic.publish(MESSAGE, extra=EXTRA)
120+
121+
received = subscription.pull()
122+
ack_ids = [msg['ackId'] for msg in received]
123+
subscription.acknowledge(ack_ids)
124+
one, = received
125+
self.assertEqual(one['message']['data'], b64(MESSAGE))
126+
self.assertEqual(one['message']['attributes'], {'extra': EXTRA})

0 commit comments

Comments
 (0)