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

refactor(event_source): convert functional tests to unit tests #2506

Merged
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8e4812b
ci(event_source): Splitting tests for improved maintainability and re…
leandrodamascena Jun 20, 2023
15169c6
tests: removing files
leandrodamascena Jun 20, 2023
1f0f3c0
tests: moving to unit tests
leandrodamascena Jun 20, 2023
8323cb9
tests: codecoverage
leandrodamascena Jun 20, 2023
7347b7d
Merge branch 'develop' into techdebt/event_source_tests
leandrodamascena Jun 21, 2023
f6543ba
tests: fix data class events
leandrodamascena Jun 21, 2023
3031acb
refactor: active mq
leandrodamascena Jun 21, 2023
279a5f6
refactor: alb event
leandrodamascena Jun 21, 2023
cf6a07c
refactor: rabbitmq event
leandrodamascena Jun 21, 2023
cc79fa9
refactor: api gatewa authorizer
leandrodamascena Jun 21, 2023
95db001
refactor: api gateway proxy
leandrodamascena Jun 21, 2023
dbadb82
refactor: appsync direct
leandrodamascena Jun 21, 2023
4c990d6
refactor: cloudwatch widget
leandrodamascena Jun 21, 2023
2ef31f9
refactor: connect contact
leandrodamascena Jun 21, 2023
d78e015
refactor: event bridge
leandrodamascena Jun 21, 2023
23f3698
refactor: kafka
leandrodamascena Jun 21, 2023
98afae3
refactor: kinesisfirehose
leandrodamascena Jun 21, 2023
eb17f67
refactor: kinesis stream
leandrodamascena Jun 21, 2023
80ffdff
refactor: s3 event
leandrodamascena Jun 21, 2023
09b7b5a
refactor: lambda function url
leandrodamascena Jun 21, 2023
cd21d28
refactor: cloudwatch logs events
leandrodamascena Jun 21, 2023
388504b
refactor: dynamodb stream
leandrodamascena Jun 21, 2023
5346ad2
refactor: codepipeline
leandrodamascena Jun 21, 2023
2c627fa
refactor: cognito
leandrodamascena Jun 22, 2023
d203a13
refactor: aws config
leandrodamascena Jun 22, 2023
f927617
Merge branch 'develop' into techdebt/event_source_tests
leandrodamascena Jun 22, 2023
d8b2739
refactor: addressing Heitor's feedback
leandrodamascena Jun 22, 2023
56dbb51
Merge branch 'develop' into techdebt/event_source_tests
leandrodamascena Jun 23, 2023
c162ea7
feature: addressing Heitor's feedback
leandrodamascena Jun 23, 2023
f39c81d
feature: mypy error
leandrodamascena Jun 23, 2023
468da93
feature: mypy error
leandrodamascena Jun 23, 2023
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
24 changes: 22 additions & 2 deletions aws_lambda_powertools/utilities/data_classes/active_mq_event.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Iterator, Optional
from typing import Any, Dict, Iterator, Optional

from aws_lambda_powertools.utilities.data_classes.common import DictWrapper
from aws_lambda_powertools.utilities.data_classes.shared_functions import base64_decode
Expand Down Expand Up @@ -112,6 +112,10 @@ class ActiveMQEvent(DictWrapper):
- https://aws.amazon.com/blogs/compute/using-amazon-mq-as-an-event-source-for-aws-lambda/
"""

def __init__(self, data: Dict[str, Any]):
super().__init__(data)
self._messages = None

@property
def event_source(self) -> str:
return self["eventSource"]
Expand All @@ -128,4 +132,20 @@ def messages(self) -> Iterator[ActiveMQMessage]:

@property
def message(self) -> ActiveMQMessage:
heitorlessa marked this conversation as resolved.
Show resolved Hide resolved
return next(self.messages)
"""
Returns the next ActiveMQ message using an iterator.

Returns
-------
ActiveMQMessage
The next activemq message.

Raises
------
StopIteration
If there are no more records available.

"""
if self._messages is None:
self._messages = self.messages
return next(self._messages)
leandrodamascena marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 21 additions & 2 deletions aws_lambda_powertools/utilities/data_classes/kafka_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ class KafkaEvent(DictWrapper):
- https://docs.aws.amazon.com/lambda/latest/dg/with-msk.html
"""

def __init__(self, data: Dict[str, Any]):
super().__init__(data)
self._records = None

@property
def event_source(self) -> str:
"""The AWS service from which the Kafka event record originated."""
Expand Down Expand Up @@ -116,5 +120,20 @@ def records(self) -> Iterator[KafkaEventRecord]:

@property
def record(self) -> KafkaEventRecord:
"""The next Kafka record."""
return next(self.records)
"""
Returns the next Kafka record using an iterator.

Returns
-------
KafkaEventRecord
The next Kafka record.

Raises
------
StopIteration
If there are no more records available.

"""
if self._records is None:
self._records = self.records
return next(self._records)
79 changes: 0 additions & 79 deletions tests/functional/data_classes/test_amazon_mq.py

This file was deleted.

113 changes: 0 additions & 113 deletions tests/functional/data_classes/test_lambda_function_url.py

This file was deleted.

Loading