File tree Expand file tree Collapse file tree 17 files changed +186
-169
lines changed
event_handler_bedrock_agents/src
event_handler_graphql/src Expand file tree Collapse file tree 17 files changed +186
-169
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,16 @@ def load_event(path: Path):
11
11
return json .load (f )
12
12
13
13
14
- @pytest .fixture
15
- def lambda_context ():
16
- @dataclass
17
- class LambdaContext :
18
- function_name : str = "test"
19
- memory_limit_in_mb : int = 128
20
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:809313241:function:test"
21
- aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
14
+ @dataclass
15
+ class LambdaContext :
16
+ function_name : str = "test"
17
+ memory_limit_in_mb : int = 128
18
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:809313241:function:test"
19
+ aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
20
+
22
21
22
+ @pytest .fixture
23
+ def lambda_context () -> LambdaContext :
23
24
return LambdaContext ()
24
25
25
26
@@ -29,7 +30,7 @@ def sqs_event():
29
30
return load_event (path = Path ("events/sqs_event.json" ))
30
31
31
32
32
- def test_app_batch_partial_response (sqs_event , lambda_context ):
33
+ def test_app_batch_partial_response (sqs_event , lambda_context : LambdaContext ):
33
34
# GIVEN
34
35
processor_result = processor # access processor for additional assertions
35
36
successful_record = sqs_event ["Records" ][0 ]
Original file line number Diff line number Diff line change 4
4
import test_lambda_mask
5
5
6
6
7
- @pytest .fixture
8
- def lambda_context ():
9
- @dataclass
10
- class LambdaContext :
11
- function_name : str = "test"
12
- memory_limit_in_mb : int = 128
13
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:111111111:function:test"
14
- aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
7
+ @dataclass
8
+ class LambdaContext :
9
+ function_name : str = "test"
10
+ memory_limit_in_mb : int = 128
11
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:111111111:function:test"
12
+ aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
13
+
14
+ def get_remaining_time_in_millis (self ) -> int :
15
+ return 5
15
16
16
- def get_remaining_time_in_millis (self ) -> int :
17
- return 5
18
17
18
+ @pytest .fixture
19
+ def lambda_context () -> LambdaContext :
19
20
return LambdaContext ()
20
21
21
22
22
- def test_encrypt_lambda (lambda_context ):
23
+ def test_encrypt_lambda (lambda_context : LambdaContext ):
23
24
# GIVEN: A sample event for testing
24
25
event = {"testkey" : "testvalue" }
25
26
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
6
6
7
- @pytest .fixture
8
- def lambda_context ():
9
- @dataclass
10
- class LambdaContext :
11
- function_name : str = "test"
12
- memory_limit_in_mb : int = 128
13
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
14
- aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
7
+ @dataclass
8
+ class LambdaContext :
9
+ function_name : str = "test"
10
+ memory_limit_in_mb : int = 128
11
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
12
+ aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
13
+
15
14
15
+ @pytest .fixture
16
+ def lambda_context () -> LambdaContext :
16
17
return LambdaContext ()
17
18
18
19
19
- def test_lambda_handler (lambda_context ):
20
+ def test_lambda_handler (lambda_context : LambdaContext ):
20
21
minimal_event = {
21
22
"apiPath" : "/current_time" ,
22
23
"httpMethod" : "GET" ,
Original file line number Diff line number Diff line change 10
10
)
11
11
12
12
13
- @pytest .fixture
14
- def lambda_context ():
15
- @dataclass
16
- class LambdaContext :
17
- function_name : str = "test"
18
- memory_limit_in_mb : int = 128
19
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
20
- aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
13
+ @dataclass
14
+ class LambdaContext :
15
+ function_name : str = "test"
16
+ memory_limit_in_mb : int = 128
17
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
18
+ aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
19
+
21
20
21
+ @pytest .fixture
22
+ def lambda_context () -> LambdaContext :
22
23
return LambdaContext ()
23
24
24
25
25
26
@pytest .mark .asyncio
26
- async def test_async_direct_resolver (lambda_context ):
27
+ async def test_async_direct_resolver (lambda_context : LambdaContext ):
27
28
# GIVEN
28
29
fake_event = json .loads (Path ("assert_async_graphql_response.json" ).read_text ())
29
30
Original file line number Diff line number Diff line change 8
8
from assert_graphql_response_module import Location , app # instance of AppSyncResolver
9
9
10
10
11
- @pytest .fixture
12
- def lambda_context ():
13
- @dataclass
14
- class LambdaContext :
15
- function_name : str = "test"
16
- memory_limit_in_mb : int = 128
17
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
18
- aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
11
+ @dataclass
12
+ class LambdaContext :
13
+ function_name : str = "test"
14
+ memory_limit_in_mb : int = 128
15
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
16
+ aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
17
+
19
18
19
+ @pytest .fixture
20
+ def lambda_context () -> LambdaContext :
20
21
return LambdaContext ()
21
22
22
23
23
- def test_direct_resolver (lambda_context ):
24
+ def test_direct_resolver (lambda_context : LambdaContext ):
24
25
# GIVEN
25
26
fake_event = json .loads (Path ("assert_graphql_response.json" ).read_text ())
26
27
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
6
6
7
- @pytest .fixture
8
- def lambda_context ():
9
- @dataclass
10
- class LambdaContext :
11
- function_name : str = "test"
12
- memory_limit_in_mb : int = 128
13
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
14
- aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
7
+ @dataclass
8
+ class LambdaContext :
9
+ function_name : str = "test"
10
+ memory_limit_in_mb : int = 128
11
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
12
+ aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
13
+
15
14
15
+ @pytest .fixture
16
+ def lambda_context () -> LambdaContext :
16
17
return LambdaContext ()
17
18
18
19
19
- def test_lambda_handler (lambda_context ):
20
+ def test_lambda_handler (lambda_context : LambdaContext ):
20
21
minimal_event = {
21
22
"path" : "/todos" ,
22
23
"httpMethod" : "GET" ,
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
6
6
7
- @pytest .fixture
8
- def lambda_context ():
9
- @dataclass
10
- class LambdaContext :
11
- function_name : str = "test"
12
- memory_limit_in_mb : int = 128
13
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
14
- aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
7
+ @dataclass
8
+ class LambdaContext :
9
+ function_name : str = "test"
10
+ memory_limit_in_mb : int = 128
11
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
12
+ aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
13
+
15
14
15
+ @pytest .fixture
16
+ def lambda_context () -> LambdaContext :
16
17
return LambdaContext ()
17
18
18
19
19
- def test_lambda_handler (lambda_context ):
20
+ def test_lambda_handler (lambda_context : LambdaContext ):
20
21
minimal_event = {
21
22
"rawPath" : "/todos" ,
22
23
"requestContext" : {
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
6
6
7
- @pytest .fixture
8
- def lambda_context ():
9
- @dataclass
10
- class LambdaContext :
11
- function_name : str = "test"
12
- memory_limit_in_mb : int = 128
13
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
14
- aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
7
+ @dataclass
8
+ class LambdaContext :
9
+ function_name : str = "test"
10
+ memory_limit_in_mb : int = 128
11
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
12
+ aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
13
+
15
14
15
+ @pytest .fixture
16
+ def lambda_context () -> LambdaContext :
16
17
return LambdaContext ()
17
18
18
19
19
- def test_lambda_handler (lambda_context ):
20
+ def test_lambda_handler (lambda_context : LambdaContext ):
20
21
minimal_event = {
21
22
"rawPath" : "/todos" ,
22
23
"requestContext" : {
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
6
6
7
- @pytest .fixture
8
- def lambda_context ():
9
- @dataclass
10
- class LambdaContext :
11
- function_name : str = "test"
12
- memory_limit_in_mb : int = 128
13
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
14
- aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
7
+ @dataclass
8
+ class LambdaContext :
9
+ function_name : str = "test"
10
+ memory_limit_in_mb : int = 128
11
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:123456789012:function:test"
12
+ aws_request_id : str = "da658bd3-2d6f-4e7b-8ec2-937234644fdc"
13
+
15
14
15
+ @pytest .fixture
16
+ def lambda_context () -> LambdaContext :
16
17
return LambdaContext ()
17
18
18
19
19
- def test_lambda_handler (lambda_context ):
20
+ def test_lambda_handler (lambda_context : LambdaContext ):
20
21
minimal_event = {
21
22
"path" : "/todos" ,
22
23
"httpMethod" : "GET" ,
Original file line number Diff line number Diff line change 4
4
import pytest
5
5
6
6
7
- @pytest .fixture
8
- def lambda_context ():
9
- @dataclass
10
- class LambdaContext :
11
- function_name : str = "test"
12
- memory_limit_in_mb : int = 128
13
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:809313241:function:test"
14
- aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
7
+ @dataclass
8
+ class LambdaContext :
9
+ function_name : str = "test"
10
+ memory_limit_in_mb : int = 128
11
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:809313241:function:test"
12
+ aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
13
+
14
+ def get_remaining_time_in_millis (self ) -> int :
15
+ return 5
15
16
16
- def get_remaining_time_in_millis (self ) -> int :
17
- return 5
18
17
18
+ @pytest .fixture
19
+ def lambda_context () -> LambdaContext :
19
20
return LambdaContext ()
20
21
21
22
22
- def test_idempotent_lambda_handler (monkeypatch , lambda_context ):
23
+ def test_idempotent_lambda_handler (monkeypatch , lambda_context : LambdaContext ):
23
24
# Set POWERTOOLS_IDEMPOTENCY_DISABLED before calling decorated functions
24
25
monkeypatch .setenv ("POWERTOOLS_IDEMPOTENCY_DISABLED" , 1 )
25
26
Original file line number Diff line number Diff line change 5
5
import pytest
6
6
7
7
8
- @pytest .fixture
9
- def lambda_context ():
10
- @dataclass
11
- class LambdaContext :
12
- function_name : str = "test"
13
- memory_limit_in_mb : int = 128
14
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:809313241:function:test"
15
- aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
8
+ @dataclass
9
+ class LambdaContext :
10
+ function_name : str = "test"
11
+ memory_limit_in_mb : int = 128
12
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:809313241:function:test"
13
+ aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
14
+
15
+ def get_remaining_time_in_millis (self ) -> int :
16
+ return 5
16
17
17
- def get_remaining_time_in_millis (self ) -> int :
18
- return 5
19
18
19
+ @pytest .fixture
20
+ def lambda_context () -> LambdaContext :
20
21
return LambdaContext ()
21
22
22
23
23
- def test_idempotent_lambda (lambda_context ):
24
+ def test_idempotent_lambda (lambda_context : LambdaContext ):
24
25
# Configure the boto3 to use the endpoint for the DynamoDB Local instance
25
26
dynamodb_local_client = boto3 .client ("dynamodb" , endpoint_url = "http://localhost:8000" )
26
27
app_test_dynamodb_local .persistence_layer .client = dynamodb_local_client
Original file line number Diff line number Diff line change 5
5
import pytest
6
6
7
7
8
- @pytest .fixture
9
- def lambda_context ():
10
- @dataclass
11
- class LambdaContext :
12
- function_name : str = "test"
13
- memory_limit_in_mb : int = 128
14
- invoked_function_arn : str = "arn:aws:lambda:eu-west-1:809313241:function:test"
15
- aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
8
+ @dataclass
9
+ class LambdaContext :
10
+ function_name : str = "test"
11
+ memory_limit_in_mb : int = 128
12
+ invoked_function_arn : str = "arn:aws:lambda:eu-west-1:809313241:function:test"
13
+ aws_request_id : str = "52fdfc07-2182-154f-163f-5f0f9a621d72"
14
+
15
+ def get_remaining_time_in_millis (self ) -> int :
16
+ return 5
16
17
17
- def get_remaining_time_in_millis (self ) -> int :
18
- return 5
19
18
19
+ @pytest .fixture
20
+ def lambda_context () -> LambdaContext :
20
21
return LambdaContext ()
21
22
22
23
23
- def test_idempotent_lambda (lambda_context ):
24
+ def test_idempotent_lambda (lambda_context : LambdaContext ):
24
25
mock_client = MagicMock ()
25
26
app_test_io_operations .persistence_layer .client = mock_client
26
27
result = app_test_io_operations .handler ({"testkey" : "testvalue" }, lambda_context )
You can’t perform that action at this time.
0 commit comments