Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from src import app

# Mock the DynamoDB Service during the test
@moto.mock_dynamodb
@moto.mock_aws

class TestSampleLambdaWithDynamoDB(TestCase):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# SPDX-License-Identifier: MIT-0

import boto3
from moto import mock_s3
from moto import mock_aws
from src.sampleCodeLayer.python.layer import get_s3_bucket_list_as_string

@mock_s3
@mock_aws
def test_get_s3_bucket_list_as_string() -> None:

# set up test bucket
s3_client = boto3.client('s3')
s3_client = boto3.client('s3', region_name='us-east-1')
test_bucket_names = ["test_bucket1","test_bucket2"]
test_data = b'col_1,col_2\n1,2\n3,4\n'
for test_bucket_name in test_bucket_names:
Expand Down
6 changes: 3 additions & 3 deletions python-test-samples/apigw-lambda/tests/unit/mock_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from urllib import response
import boto3
import pytest
from moto import mock_s3
from moto import mock_aws
from aws_lambda_powertools.utilities.data_classes import APIGatewayProxyEvent
from src import app

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


@mock_s3
@mock_aws
def test_lambda_handler(apigw_event: dict) -> None:

# set up test bucket
s3_client = boto3.client('s3')
s3_client = boto3.client('s3', region_name='us-east-1')
test_bucket_names = ["test_bucket1","test_bucket2"]
test_data = b'col_1,col_2\n1,2\n3,4\n'
for test_bucket_name in test_bucket_names:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
from boto3.dynamodb.conditions import Key
import moto

# Mock the DynamoDB Service during the test
@moto.mock_dynamodb
# Mock all AWS Services
@moto.mock_aws
class TestKinesisLambdaWithDynamoDB(TestCase):
"""
Unit Test class for src/app.py
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
from src.sample_lambda.app import lambda_handler, create_letter_in_s3 # pylint: disable=wrong-import-position
from src.sample_lambda.schemas import INPUT_SCHEMA # pylint: disable=wrong-import-position

# [1] Mock all AWS Services in use
@moto.mock_dynamodb
@moto.mock_s3
# [1] Mock all AWS Services
@moto.mock_aws
class TestSampleLambda(TestCase):
"""
Test class for the application sample AWS Lambda Function
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
# Import the handler under test
import app

# Mock the DynamoDB Service during the test
@moto.mock_dynamodb
# Mock all AWS Services
@moto.mock_aws


class TestSampleLambdaWithDynamoDB(TestCase):
Expand Down