Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9fade02

Browse filesBrowse files
committed
Fix regression3 failures:
- Message payload must be bytes, base64ed, but then must be serializable to JSON. - Likewise, 'attributes' values must be serializable to JSON.
1 parent 227045a commit 9fade02
Copy full SHA for 9fade02

File tree

Expand file treeCollapse file tree

3 files changed

+6
-5
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+6
-5
lines changed

‎gcloud/pubsub/test_topic.py

Copy file name to clipboardExpand all lines: gcloud/pubsub/test_topic.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,12 @@ def test_delete(self):
126126
self.assertEqual(req['method'], 'DELETE')
127127
self.assertEqual(req['path'], '/%s' % PATH)
128128

129-
def test_publish_single_wo_attrs(self):
129+
def test_publish_single_bytes_wo_attrs(self):
130130
import base64
131131
TOPIC_NAME = 'topic_name'
132132
PROJECT = 'PROJECT'
133133
PAYLOAD = b'This is the message text'
134-
B64 = base64.b64encode(PAYLOAD)
134+
B64 = base64.b64encode(PAYLOAD).decode('ascii')
135135
MSGID = 'DEADBEEF'
136136
MESSAGE = {'data': B64,
137137
'attributes': {}}
@@ -151,7 +151,7 @@ def test_publish_single_w_attrs(self):
151151
TOPIC_NAME = 'topic_name'
152152
PROJECT = 'PROJECT'
153153
PAYLOAD = b'This is the message text'
154-
B64 = base64.b64encode(PAYLOAD)
154+
B64 = base64.b64encode(PAYLOAD).decode('ascii')
155155
MSGID = 'DEADBEEF'
156156
MESSAGE = {'data': B64,
157157
'attributes': {'attr1': 'value1', 'attr2': 'value2'}}

‎gcloud/pubsub/topic.py

Copy file name to clipboardExpand all lines: gcloud/pubsub/topic.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ def publish(self, message, **attrs):
113113
:rtype: str
114114
:returns: message ID assigned by the server to the published message
115115
"""
116-
message_data = {'data': base64.b64encode(message), 'attributes': attrs}
116+
message_b = base64.b64encode(message).decode('ascii')
117+
message_data = {'data': message_b, 'attributes': attrs}
117118
data = {'messages': [message_data]}
118119
response = self.connection.api_request(method='POST',
119120
path='%s:publish' % self.path,

‎regression/pubsub.py

Copy file name to clipboardExpand all lines: regression/pubsub.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def test_message_pull_mode_e2e(self):
114114
self.to_delete.append(subscription)
115115

116116
MESSAGE = b'MESSAGE'
117-
EXTRA = b'EXTRA'
117+
EXTRA = 'EXTRA'
118118
topic.publish(MESSAGE, extra=EXTRA)
119119

120120
received = subscription.pull()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.