FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix regression3 failures in pubsub by tseaver · Pull Request #804 · googleapis/google-cloud-python · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
6 changes: 3 additions & 3 deletions gcloud/pubsub/test_topic.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ def test_delete(self):
self.assertEqual(req['method'], 'DELETE')
self.assertEqual(req['path'], '/%s' % PATH)

def test_publish_single_wo_attrs(self):
def test_publish_single_bytes_wo_attrs(self):
import base64
TOPIC_NAME = 'topic_name'
PROJECT = 'PROJECT'
PAYLOAD = b'This is the message text'
B64 = base64.b64encode(PAYLOAD)
B64 = base64.b64encode(PAYLOAD).decode('ascii')
MSGID = 'DEADBEEF'
MESSAGE = {'data': B64,
'attributes': {}}
Expand All @@ -151,7 +151,7 @@ def test_publish_single_w_attrs(self):
TOPIC_NAME = 'topic_name'
PROJECT = 'PROJECT'
PAYLOAD = b'This is the message text'
B64 = base64.b64encode(PAYLOAD)
B64 = base64.b64encode(PAYLOAD).decode('ascii')
MSGID = 'DEADBEEF'
MESSAGE = {'data': B64,
'attributes': {'attr1': 'value1', 'attr2': 'value2'}}
Expand Down
3 changes: 2 additions & 1 deletion gcloud/pubsub/topic.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ def publish(self, message, **attrs):
:rtype: str
:returns: message ID assigned by the server to the published message
"""
message_data = {'data': base64.b64encode(message), 'attributes': attrs}
message_b = base64.b64encode(message).decode('ascii')
message_data = {'data': message_b, 'attributes': attrs}
data = {'messages': [message_data]}
response = self.connection.api_request(method='POST',
path='%s:publish' % self.path,
Expand Down
2 changes: 1 addition & 1 deletion regression/pubsub.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def test_message_pull_mode_e2e(self):
self.to_delete.append(subscription)

MESSAGE = b'MESSAGE'
EXTRA = b'EXTRA'
EXTRA = 'EXTRA'
topic.publish(MESSAGE, extra=EXTRA)

received = subscription.pull()
Expand Down

Back | FazBrowse Home | New Git URL