Skip to content

chore(deps): bump email-validator from 1.1.3 to 1.2.1 #263

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

Closed
Closed
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
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,39 @@ All notable changes to this project will be documented in this file.

This project follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format for changes and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 1.25.10 - 2022-04-29

### Bug Fixes

* **data-classes:** Add missing SES fields and ([#1045](https://github.com/awslabs/aws-lambda-powertools-python/issues/1045))
* **deps:** Ignore boto3 changes until needed ([#1151](https://github.com/awslabs/aws-lambda-powertools-python/issues/1151))
* **deps-dev:** remove jmespath due to dev deps conflict ([#1148](https://github.com/awslabs/aws-lambda-powertools-python/issues/1148))
* **event_handler:** exception_handler to handle ServiceError exceptions ([#1160](https://github.com/awslabs/aws-lambda-powertools-python/issues/1160))
* **event_handler:** Allow for event_source support ([#1159](https://github.com/awslabs/aws-lambda-powertools-python/issues/1159))
* **parser:** Add missing fields for SESEvent ([#1027](https://github.com/awslabs/aws-lambda-powertools-python/issues/1027))

### Documentation

* **layer:** upgrade to 1.25.9

### Features

* **parameters:** add clear_cache method for providers ([#1194](https://github.com/awslabs/aws-lambda-powertools-python/issues/1194))

### Maintenance

* **ci:** changelog pre-generation to fetch tags from origin
* **ci:** post release on tagged issues too
* **ci:** disable mergify configuration after breaking changes ([#1188](https://github.com/awslabs/aws-lambda-powertools-python/issues/1188))
* **deps:** bump codecov/codecov-action from 3.0.0 to 3.1.0 ([#1143](https://github.com/awslabs/aws-lambda-powertools-python/issues/1143))
* **deps:** bump github/codeql-action from 1 to 2 ([#1154](https://github.com/awslabs/aws-lambda-powertools-python/issues/1154))
* **deps-dev:** bump flake8-bugbear from 22.1.11 to 22.4.25 ([#1156](https://github.com/awslabs/aws-lambda-powertools-python/issues/1156))
* **deps-dev:** bump flake8-eradicate from 1.2.0 to 1.2.1 ([#1158](https://github.com/awslabs/aws-lambda-powertools-python/issues/1158))
* **deps-dev:** bump mkdocs-git-revision-date-plugin ([#1146](https://github.com/awslabs/aws-lambda-powertools-python/issues/1146))
* **deps-dev:** bump mypy from 0.942 to 0.950 ([#1162](https://github.com/awslabs/aws-lambda-powertools-python/issues/1162))
* **deps-dev:** bump xenon from 0.8.0 to 0.9.0 ([#1145](https://github.com/awslabs/aws-lambda-powertools-python/issues/1145))
* **deps-dev:** bump mypy from 0.931 to 0.942 ([#1133](https://github.com/awslabs/aws-lambda-powertools-python/issues/1133))

## 1.25.9 - 2022-04-21

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ release: pr
$(MAKE) release-prod

changelog:
git fetch --tags
git fetch --tags origin
@echo "[+] Pre-generating CHANGELOG for tag: $$(git describe --abbrev=0 --tag)"
docker run -v "${PWD}":/workdir quay.io/git-chglog/git-chglog $$(git describe --abbrev=0 --tag).. > TMP_CHANGELOG.md

Expand Down
3 changes: 2 additions & 1 deletion aws_lambda_powertools/utilities/parameters/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

from .appconfig import AppConfigProvider, get_app_config
from .base import BaseProvider
from .base import BaseProvider, clear_caches
from .dynamodb import DynamoDBProvider
from .exceptions import GetParameterError, TransformParameterError
from .secrets import SecretsProvider, get_secret
Expand All @@ -23,4 +23,5 @@
"get_parameter",
"get_parameters",
"get_secret",
"clear_caches",
]
8 changes: 8 additions & 0 deletions aws_lambda_powertools/utilities/parameters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ def _get_multiple(self, path: str, **sdk_options) -> Dict[str, str]:
"""
raise NotImplementedError()

def clear_cache(self):
self.store.clear()


def get_transform_method(key: str, transform: Optional[str] = None) -> Optional[str]:
"""
Expand Down Expand Up @@ -251,3 +254,8 @@ def transform_value(
if raise_on_transform_error:
raise TransformParameterError(str(exc))
return None


def clear_caches():
"""Clear cached parameter values from all providers"""
DEFAULT_PROVIDERS.clear()
8 changes: 0 additions & 8 deletions aws_lambda_powertools/utilities/parser/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@
SesModel,
SesReceipt,
SesReceiptAction,
SesReceiptActionBase,
SesReceiptBounceAction,
SesReceiptS3Action,
SesReceiptVerdict,
SesReceiptWorkmailAction,
SesRecordModel,
)
from .sns import SnsModel, SnsNotificationModel, SnsRecordModel
Expand Down Expand Up @@ -88,10 +84,6 @@
"SesMailHeaders",
"SesReceipt",
"SesReceiptAction",
"SesReceiptActionBase",
"SesReceiptBounceAction",
"SesReceiptWorkmailAction",
"SesReceiptS3Action",
"SesReceiptVerdict",
"SnsModel",
"SnsNotificationModel",
Expand Down
34 changes: 3 additions & 31 deletions aws_lambda_powertools/utilities/parser/models/ses.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import List, Optional, Union
from typing import List, Optional

from pydantic import BaseModel, Field
from pydantic.networks import EmailStr
Expand All @@ -12,49 +12,21 @@ class SesReceiptVerdict(BaseModel):
status: Literal["PASS", "FAIL", "GRAY", "PROCESSING_FAILED"]


class SesReceiptActionBase(BaseModel):
topicArn: Optional[str]


class SesReceiptAction(SesReceiptActionBase):
class SesReceiptAction(BaseModel):
type: Literal["Lambda"] # noqa A003,VNE003
invocationType: Literal["Event"]
functionArn: str


class SesReceiptS3Action(SesReceiptActionBase):
type: Literal["S3"] # noqa A003,VNE003
topicArn: str
bucketName: str
objectKey: str


class SesReceiptBounceAction(SesReceiptActionBase):
type: Literal["Bounce"] # noqa A003,VNE003
topicArn: str
smtpReplyCode: str
message: str
sender: str
statusCode: str


class SesReceiptWorkmailAction(SesReceiptActionBase):
type: Literal["WorkMail"] # noqa A003,VNE003
topicArn: str
organizationArn: str


class SesReceipt(BaseModel):
timestamp: datetime
processingTimeMillis: PositiveInt
recipients: List[EmailStr]
spamVerdict: SesReceiptVerdict
virusVerdict: SesReceiptVerdict
spfVerdict: SesReceiptVerdict
dkimVerdict: SesReceiptVerdict
dmarcVerdict: SesReceiptVerdict
dmarcPolicy: Optional[Literal["quarantine", "reject", "none"]]
action: Union[SesReceiptAction, SesReceiptS3Action, SesReceiptBounceAction, SesReceiptWorkmailAction]
action: SesReceiptAction


class SesMailHeaders(BaseModel):
Expand Down
78 changes: 75 additions & 3 deletions docs/utilities/parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,9 @@ The **`config`** and **`boto3_session`** parameters enable you to pass in a cust

## Testing your code

For unit testing your applications, you can mock the calls to the parameters utility to avoid calling AWS APIs. This
can be achieved in a number of ways - in this example, we use the [pytest monkeypatch fixture](https://docs.pytest.org/en/latest/how-to/monkeypatch.html)
to patch the `parameters.get_parameter` method:
### Mocking parameter values

For unit testing your applications, you can mock the calls to the parameters utility to avoid calling AWS APIs. This can be achieved in a number of ways - in this example, we use the [pytest monkeypatch fixture](https://docs.pytest.org/en/latest/how-to/monkeypatch.html) to patch the `parameters.get_parameter` method:

=== "tests.py"
```python
Expand Down Expand Up @@ -588,3 +588,75 @@ object named `get_parameter_mock`.
assert return_val.get('message') == 'mock_value'

```


### Clearing cache

Parameters utility caches all parameter values for performance and cost reasons. However, this can have unintended interference in tests using the same parameter name.

Within your tests, you can use `clear_cache` method available in [every provider](#built-in-provider-class). When using multiple providers or higher level functions like `get_parameter`, use `clear_caches` standalone function to clear cache globally.


=== "clear_cache method"
```python hl_lines="9"
import pytest

from src import app


@pytest.fixture(scope="function", autouse=True)
def clear_parameters_cache():
yield
app.ssm_provider.clear_cache() # This will clear SSMProvider cache

@pytest.fixture
def mock_parameter_response(monkeypatch):
def mockreturn(name):
return "mock_value"

monkeypatch.setattr(app.ssm_provider, "get", mockreturn)

# Pass our fixture as an argument to all tests where we want to mock the get_parameter response
def test_handler(mock_parameter_response):
return_val = app.handler({}, {})
assert return_val.get('message') == 'mock_value'
```

=== "global clear_caches"
```python hl_lines="10"
import pytest

from aws_lambda_powertools.utilities import parameters
from src import app


@pytest.fixture(scope="function", autouse=True)
def clear_parameters_cache():
yield
parameters.clear_caches() # This will clear all providers cache

@pytest.fixture
def mock_parameter_response(monkeypatch):
def mockreturn(name):
return "mock_value"

monkeypatch.setattr(app.ssm_provider, "get", mockreturn)

# Pass our fixture as an argument to all tests where we want to mock the get_parameter response
def test_handler(mock_parameter_response):
return_val = app.handler({}, {})
assert return_val.get('message') == 'mock_value'
```

=== "app.py"
```python
from aws_lambda_powertools.utilities import parameters
from botocore.config import Config

ssm_provider = parameters.SSMProvider(config=Config(region_name="us-west-1"))


def handler(event, context):
value = ssm_provider.get("/my/parameter")
return {"message": value}
```
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aws_lambda_powertools"
version = "1.25.9"
version = "1.25.10"
description = "A suite of utilities for AWS Lambda functions to ease adopting best practices such as tracing, structured logging, custom metrics, batching, idempotency, feature flags, and more."
authors = ["Amazon Web Services"]
include = ["aws_lambda_powertools/py.typed", "THIRD-PARTY-LICENSES"]
Expand Down
Loading