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

fix(parser): change ApproximateCreationDateTime field to datetime in DynamoDBStreamChangedRecordModel #3049

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
4 changes: 2 additions & 2 deletions aws_lambda_powertools/utilities/parser/models/dynamodb.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import date
from datetime import datetime
from typing import Any, Dict, List, Optional, Type, Union

from pydantic import BaseModel
Expand All @@ -7,7 +7,7 @@


class DynamoDBStreamChangedRecordModel(BaseModel):
ApproximateCreationDateTime: Optional[date] = None
ApproximateCreationDateTime: Optional[datetime] = None
Keys: Dict[str, Dict[str, Any]]
NewImage: Optional[Union[Dict[str, Any], Type[BaseModel], BaseModel]] = None
OldImage: Optional[Union[Dict[str, Any], Type[BaseModel], BaseModel]] = None
Expand Down
1 change: 1 addition & 0 deletions tests/events/dynamoStreamEvent.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"eventID": "1",
"eventVersion": "1.0",
"dynamodb": {
"ApproximateCreationDateTime": 1693997155.0,
"Keys": {
"Id": {
"N": "101"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/data_classes/test_dynamo_db_stream_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_dynamodb_stream_trigger_event():
assert record.user_identity is None
dynamodb = record.dynamodb
assert dynamodb is not None
assert dynamodb.approximate_creation_date_time is None
assert dynamodb.approximate_creation_date_time == record_raw["dynamodb"]["ApproximateCreationDateTime"]
keys = dynamodb.keys
assert keys is not None
assert keys["Id"] == decimal_context.create_decimal(101)
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/parser/test_dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def test_dynamo_db_stream_trigger_event_no_envelope():
dynamodb = record.dynamodb
raw_dynamodb = raw_record["dynamodb"]
assert dynamodb is not None
assert dynamodb.ApproximateCreationDateTime is None
assert dynamodb.ApproximateCreationDateTime is not None
assert dynamodb.ApproximateCreationDateTime.timestamp() == raw_dynamodb["ApproximateCreationDateTime"]
assert dynamodb.OldImage is None
assert dynamodb.SequenceNumber == raw_dynamodb["SequenceNumber"]
assert dynamodb.SizeBytes == raw_dynamodb["SizeBytes"]
Expand Down