Merge pull request #997 from ferranscopely/sqs_timestamps_exponential_notation

Don't use exponential notation for SQS message timestamps
This commit is contained in:
Jack Danger 2017-07-04 13:44:42 -07:00 committed by GitHub
commit 5cbcc7bcf4
2 changed files with 21 additions and 2 deletions

View File

@ -96,7 +96,7 @@ class Message(BaseModel):
return escape(self._body)
def mark_sent(self, delay_seconds=None):
self.sent_timestamp = unix_time_millis()
self.sent_timestamp = int(unix_time_millis())
if delay_seconds:
self.delay(delay_seconds=delay_seconds)
@ -111,7 +111,7 @@ class Message(BaseModel):
visibility_timeout = 0
if not self.approximate_first_receive_timestamp:
self.approximate_first_receive_timestamp = unix_time_millis()
self.approximate_first_receive_timestamp = int(unix_time_millis())
self.approximate_receive_count += 1

View File

@ -272,6 +272,25 @@ def test_send_receive_message_with_attributes():
message2.get('MD5OfMessageAttributes').should.equal('994258b45346a2cc3f9cbb611aa7af30')
@mock_sqs
def test_send_receive_message_timestamps():
sqs = boto3.resource('sqs', region_name='us-east-1')
conn = boto3.client("sqs", region_name='us-east-1')
conn.create_queue(QueueName="test-queue")
queue = sqs.Queue("test-queue")
queue.send_message(MessageBody="derp")
messages = conn.receive_message(
QueueUrl=queue.url, MaxNumberOfMessages=1)['Messages']
message = messages[0]
sent_timestamp = message.get('Attributes').get('SentTimestamp')
approximate_first_receive_timestamp = message.get('Attributes').get('ApproximateFirstReceiveTimestamp')
int.when.called_with(sent_timestamp).shouldnt.throw(ValueError)
int.when.called_with(approximate_first_receive_timestamp).shouldnt.throw(ValueError)
@mock_sqs
def test_receive_messages_with_wait_seconds_timeout_of_zero():
"""