From f96ac40fca81b1aa8254a77d595adc43f160b983 Mon Sep 17 00:00:00 2001 From: Brian Pandola Date: Thu, 11 Mar 2021 00:54:21 -0800 Subject: [PATCH] Fix: `ApproximateArrivalTimestamp` should be epoch with millisecond precision (#3764) The Record class was already capturing a unix timestamp, but it was incorrectly converting it to ISO format when sending back to the client. Updating the model to return the correct timestamp necessitated a minor change to one of the tests because `botocore` converts non-timezone aware timestamps to local time. --- moto/kinesis/models.py | 2 +- tests/test_kinesis/test_kinesis.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/moto/kinesis/models.py b/moto/kinesis/models.py index 280402d5..3065b81a 100644 --- a/moto/kinesis/models.py +++ b/moto/kinesis/models.py @@ -43,7 +43,7 @@ class Record(BaseModel): "Data": self.data, "PartitionKey": self.partition_key, "SequenceNumber": str(self.sequence_number), - "ApproximateArrivalTimestamp": self.created_at_datetime.isoformat(), + "ApproximateArrivalTimestamp": self.created_at, } diff --git a/tests/test_kinesis/test_kinesis.py b/tests/test_kinesis/test_kinesis.py index 85f24857..a2fc2f34 100644 --- a/tests/test_kinesis/test_kinesis.py +++ b/tests/test_kinesis/test_kinesis.py @@ -6,6 +6,7 @@ import time import boto.kinesis import boto3 from boto.kinesis.exceptions import ResourceNotFoundException, InvalidArgumentException +from dateutil.tz import tzlocal from moto import mock_kinesis, mock_kinesis_deprecated from moto.core import ACCOUNT_ID @@ -378,7 +379,7 @@ def test_get_records_timestamp_filtering(): conn.put_record(StreamName=stream_name, Data="0", PartitionKey="0") time.sleep(1.0) - timestamp = datetime.datetime.utcnow() + timestamp = datetime.datetime.now(tz=tzlocal()) conn.put_record(StreamName=stream_name, Data="1", PartitionKey="1")