Skip to content

Commit a8238fa

Browse files
heitorlessaRan Isenberg
andauthored
fix: allow handlers with keyword arguments (#47)
* fix: allow handlers with keyword arguments Signed-off-by: heitorlessa <lessa@amazon.co.uk> * chore: restore old formatting Signed-off-by: heitorlessa <lessa@amazon.co.uk> * fix format and ready release --------- Signed-off-by: heitorlessa <lessa@amazon.co.uk> Co-authored-by: Ran Isenberg <ran.isenberg@ranthebuilder.cloud>
1 parent e730e92 commit a8238fa

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

aws_lambda_env_modeler/modeler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ def init_environment_variables(model: Type[Model]):
3535
def decorator(lambda_handler_function: Callable):
3636

3737
@wraps(lambda_handler_function)
38-
def wrapper(event: Dict[str, Any], context):
38+
def wrapper(event: Dict[str, Any], context, **kwargs):
3939
__parse_model(model)
40-
return lambda_handler_function(event, context)
40+
return lambda_handler_function(event, context, **kwargs)
4141

4242
return wrapper
4343

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "aws_lambda_env_modeler"
3-
version = "1.0.3"
3+
version = "1.0.5"
44
description = "AWS-Lambda-Env-Modeler is a Python library designed to simplify the process of managing and validating environment variables in your AWS Lambda functions."
55
authors = ["Ran Isenberg"]
66
classifiers=[

tests/unit/test_env_vars_parser.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,17 @@ def my_handler(event, context) -> Dict[str, Any]:
4949
return {}
5050

5151
my_handler({}, None)
52+
53+
54+
def test_extended_handler_schema_ok(monkeypatch: pytest.MonkeyPatch):
55+
monkeypatch.setenv('POWERTOOLS_SERVICE_NAME', SERVICE_NAME)
56+
monkeypatch.setenv('LOG_LEVEL', 'DEBUG')
57+
monkeypatch.setenv('REST_API', 'https://www.ranthebuilder.cloud/api')
58+
59+
endpoint = os.environ['REST_API']
60+
61+
@init_environment_variables(model=MySchema)
62+
def my_handler(event, context, endpoint=None):
63+
return endpoint
64+
65+
assert my_handler({}, None, endpoint=endpoint) == endpoint

0 commit comments

Comments
 (0)