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

test: DictWrapper equals method #234

Merged
merged 3 commits into from
Dec 7, 2020
Merged
Changes from 2 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
14 changes: 13 additions & 1 deletion tests/functional/test_lambda_trigger_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
UserMigrationTriggerEvent,
VerifyAuthChallengeResponseTriggerEvent,
)
from aws_lambda_powertools.utilities.data_classes.common import BaseProxyEvent
from aws_lambda_powertools.utilities.data_classes.common import BaseProxyEvent, DictWrapper
from aws_lambda_powertools.utilities.data_classes.dynamo_db_stream_event import (
AttributeValue,
DynamoDBRecordEventName,
Expand All @@ -43,6 +43,18 @@ def load_event(file_name: str) -> dict:
return json.load(fp)


def test_dict_wrapper_equals():
class DataClassSample(DictWrapper):
@property
def message(self) -> str:
return self.get("message")

assert DataClassSample({"message": "foo1"}) == DataClassSample({"message": "foo1"})
assert DataClassSample({"message": "foo1"}) != DataClassSample({"message": "foo2"})
assert DataClassSample({"message": "foo1"}) is not object()
assert object() is not DataClassSample({"message": "foo1"})

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this into a literal dict object and reuse it?

This will esse changing that one place only if we must in the future :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, like this you mean: 0ab2786?


def test_cloud_watch_trigger_event():
event = CloudWatchLogsEvent(load_event("cloudWatchLogEvent.json"))

Expand Down