Skip to content

Commit

Permalink
Add 'Message.ack_id' property. (#5693)
Browse files Browse the repository at this point in the history
Also, add explicit test for 'Message.size' property.

Closes #5691.
  • Loading branch information
tseaver authored Jul 26, 2018
1 parent 4be5d1b commit ccdec94
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
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

0 comments on commit ccdec94

Please sign in to comment.