Skip to content

Commit 99d8d3d

Browse files
author
Pete Davis
committed
Replaced mocked services with mock_aws
1 parent f4529c4 commit 99d8d3d

File tree

6 files changed

+13
-14
lines changed

6 files changed

+13
-14
lines changed

python-test-samples/apigw-lambda-dynamodb/tests/unit/mock_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from src import app
1818

1919
# Mock the DynamoDB Service during the test
20-
@moto.mock_dynamodb
20+
@moto.mock_aws
2121

2222
class TestSampleLambdaWithDynamoDB(TestCase):
2323
"""

python-test-samples/apigw-lambda-layer/tests/unit/mock_test_samplecodelayer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
# SPDX-License-Identifier: MIT-0
33

44
import boto3
5-
from moto import mock_s3
5+
from moto import mock_aws
66
from src.sampleCodeLayer.python.layer import get_s3_bucket_list_as_string
77

8-
@mock_s3
8+
@mock_aws
99
def test_get_s3_bucket_list_as_string() -> None:
1010

1111
# set up test bucket
12-
s3_client = boto3.client('s3')
12+
s3_client = boto3.client('s3', region_name='us-east-1')
1313
test_bucket_names = ["test_bucket1","test_bucket2"]
1414
test_data = b'col_1,col_2\n1,2\n3,4\n'
1515
for test_bucket_name in test_bucket_names:

python-test-samples/apigw-lambda/tests/unit/mock_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from urllib import response
66
import boto3
77
import pytest
8-
from moto import mock_s3
8+
from moto import mock_aws
99
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
1010
from src import app
1111

@@ -16,11 +16,11 @@ def apigw_event() -> APIGatewayProxyEvent:
1616
return APIGatewayProxyEvent(json.load(f))
1717

1818

19-
@mock_s3
19+
@mock_aws
2020
def test_lambda_handler(apigw_event: dict) -> None:
2121

2222
# set up test bucket
23-
s3_client = boto3.client('s3')
23+
s3_client = boto3.client('s3', region_name='us-east-1')
2424
test_bucket_names = ["test_bucket1","test_bucket2"]
2525
test_data = b'col_1,col_2\n1,2\n3,4\n'
2626
for test_bucket_name in test_bucket_names:

python-test-samples/kinesis-lambda-dynamodb/tests/unit/mock_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
from boto3.dynamodb.conditions import Key
1616
import moto
1717

18-
# Mock the DynamoDB Service during the test
19-
@moto.mock_dynamodb
18+
# Mock all AWS Services
19+
@moto.mock_aws
2020
class TestKinesisLambdaWithDynamoDB(TestCase):
2121
"""
2222
Unit Test class for src/app.py

python-test-samples/lambda-mock/tests/unit/src/test_sample_lambda.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@
2020
from src.sample_lambda.app import lambda_handler, create_letter_in_s3 # pylint: disable=wrong-import-position
2121
from src.sample_lambda.schemas import INPUT_SCHEMA # pylint: disable=wrong-import-position
2222

23-
# [1] Mock all AWS Services in use
24-
@moto.mock_dynamodb
25-
@moto.mock_s3
23+
# [1] Mock all AWS Services
24+
@moto.mock_aws
2625
class TestSampleLambda(TestCase):
2726
"""
2827
Test class for the application sample AWS Lambda Function

workshops/serverless-testing-workshop/tests/unit/src/test_checkout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
# Import the handler under test
2828
import app
2929

30-
# Mock the DynamoDB Service during the test
31-
@moto.mock_dynamodb
30+
# Mock all AWS Services
31+
@moto.mock_aws
3232

3333

3434
class TestSampleLambdaWithDynamoDB(TestCase):

0 commit comments

Comments
 (0)