Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'Message.ack_id' property. #5693

Merged
merged 1 commit into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions pubsub/google/cloud/pubsub_v1/subscriber/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,11 @@ def size(self):
"""Return the size of the underlying message, in bytes."""
return self._message.ByteSize()

@property
def ack_id(self):
"""str: the ID used to ack the message."""
return self._ack_id

def ack(self):
"""Acknowledge the given message.

Expand Down
11 changes: 11 additions & 0 deletions pubsub/tests/unit/pubsub_v1/subscriber/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,17 @@ def test_data():
assert msg.data == b'foo'


def test_size():
msg = create_message(b'foo')
assert msg.size == 30 # payload + protobuf overhead


def test_ack_id():
ack_id = 'MY-ACK-ID'
msg = create_message(b'foo', ack_id=ack_id)
assert msg.ack_id == ack_id


def test_publish_time():
msg = create_message(b'foo')
assert msg.publish_time == PUBLISHED
Expand Down