Closed
Description
Describe the solution you'd like
This is a follow up of #144 (comment).
Having Data Classes and Typing has made a significant difference! Being able to leverage them in testing using provided samples, mocks and/or fixtures could be useful too.
A dedicated module might make sense in order not to modify existing utilities to accommodate testing ability.
Describe alternatives you've considered
aws_lambda_context
module as described in the linked thread.- Sub-classing
LambdaContext
with setters only - not possible as Python requires@property
to be redeclared
Additional context
In the mean time, I've had success with:
import pytest
from aws_lambda_powertools.utilities.typing import LambdaContext
class MockLambdaContext(LambdaContext):
def __init__(self):
self._function_name = 'test-fn'
self._memory_limit_in_mb = 128
self._invoked_function_arn = 'arn:aws:lambda:us-east-1:12345678:function:test-fn'
self._aws_request_id = '52fdfc07-2182-154f-163f-5f0f9a621d72'
@pytest.fixture
def lambda_context() -> LambdaContext:
return MockLambdaContext()
I was also not able to use the documented suggestion as provided. Not sure if this warrants a separate issue.
Metadata
Metadata
Assignees
Type
Projects
Status
Triage