diff --git a/python-test-samples/kinesis-lambda-dynamodb/README.md b/python-test-samples/kinesis-lambda-dynamodb/README.md index 92665bc7..b79bc481 100644 --- a/python-test-samples/kinesis-lambda-dynamodb/README.md +++ b/python-test-samples/kinesis-lambda-dynamodb/README.md @@ -1,5 +1,4 @@ -[![python: 3.9](https://img.shields.io/badge/Python-3.9-green)](https://img.shields.io/badge/Python-3.9-green) -[![AWS: DynamoDB](https://img.shields.io/badge/AWS-DynamoDB-blueviolet)](https://img.shields.io/badge/AWS-DynamoDB-blueviolet) +[![python: 3.13](https://img.shields.io/badge/Python-3.13-green)](https://img.shields.io/badge/Python-3.13-green)[![AWS: DynamoDB](https://img.shields.io/badge/AWS-DynamoDB-blueviolet)](https://img.shields.io/badge/AWS-DynamoDB-blueviolet) [![AWS: Kinesis](https://img.shields.io/badge/AWS-Kinesis-orange)](https://img.shields.io/badge/AWS-Kinesis-orange) [![test: unit](https://img.shields.io/badge/Test-Unit-blue)](https://img.shields.io/badge/Test-Unit-blue) [![test: integration](https://img.shields.io/badge/Test-Integration-yellow)](https://img.shields.io/badge/Test-Integration-yellow) diff --git a/python-test-samples/kinesis-lambda-dynamodb/template.yaml b/python-test-samples/kinesis-lambda-dynamodb/template.yaml index f4c88de4..4c1127c0 100644 --- a/python-test-samples/kinesis-lambda-dynamodb/template.yaml +++ b/python-test-samples/kinesis-lambda-dynamodb/template.yaml @@ -64,7 +64,7 @@ Resources: Properties: CodeUri: src/ Handler: app.lambda_handler - Runtime: python3.9 + Runtime: python3.13 Architectures: - x86_64 Tracing: Active diff --git a/python-test-samples/kinesis-lambda-dynamodb/tests/unit/mock_test.py b/python-test-samples/kinesis-lambda-dynamodb/tests/unit/mock_test.py index 0e0213cc..24b9a416 100644 --- a/python-test-samples/kinesis-lambda-dynamodb/tests/unit/mock_test.py +++ b/python-test-samples/kinesis-lambda-dynamodb/tests/unit/mock_test.py @@ -13,14 +13,15 @@ import boto3 from boto3 import Session from boto3.dynamodb.conditions import Key -import moto +from moto import mock_aws # Mock the DynamoDB Service during the test -@moto.mock_dynamodb +@mock_aws # Only use this decorator, remove @moto.mock_dynamodb class TestKinesisLambdaWithDynamoDB(TestCase): """ Unit Test class for src/app.py """ + def setUp(self) -> None: """ Test Set up: @@ -35,7 +36,7 @@ def setUp(self) -> None: os.environ["DYNAMODB_TABLE_NAME"] = self.test_ddb_table_name sam_template_table = self.read_sam_template()["Resources"]["DynamoDBTable"] sam_template_table_properties = sam_template_table["Properties"] - self.mock_dynamodb = boto3.Session(region_name="us-east-1").resource("dynamodb") + self.mock_dynamodb = boto3.Session.resource("dynamodb") self.mock_dynamodb_table = self.mock_dynamodb.create_table( TableName = self.test_ddb_table_name, KeySchema = sam_template_table_properties["KeySchema"], @@ -47,7 +48,6 @@ def tearDown(self) -> None: """ For teardown, remove the environment variable """ - del os.environ['DYNAMODB_TABLE_NAME'] def read_sam_template(self, sam_template_fn : str = "template.yaml" ) -> dict: @@ -64,7 +64,6 @@ def load_test_event(self, test_event_file_name: str) -> Dict[str, Any]: Add the test isolation postfix to the path parameter {id} """ try: - with open(f"tests/events/{test_event_file_name}.json","r") as file_name: event = json.load(file_name) return event