Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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