Skip to content

Commit 8382fa9

Browse files
author
Ubuntu
committed
Upgrating to python 3.13
1 parent f4eabae commit 8382fa9

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

python-test-samples/apigw-lambda/README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![python: 3.9](https://img.shields.io/badge/Python-3.9-green)](https://img.shields.io/badge/Python-3.9-green)
1+
[![python: 3.13](https://img.shields.io/badge/Python-3.13-green)](https://img.shields.io/badge/Python-3.13-green)
22
[![AWS: Lambda](https://img.shields.io/badge/AWS-Lambda-blueviolet)](https://img.shields.io/badge/AWS-Lambda-blueviolet)
33
[![test: unit](https://img.shields.io/badge/Test-Unit-blue)](https://img.shields.io/badge/Test-Unit-blue)
44
[![test: integration](https://img.shields.io/badge/Test-Integration-yellow)](https://img.shields.io/badge/Test-Integration-yellow)
@@ -45,7 +45,7 @@ The SAM CLI extends the AWS CLI that adds functionality for building and testing
4545
To use the SAM CLI, you need the following tools.
4646

4747
* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
48-
* Python 3 - [Install Python 3](https://www.python.org/downloads/)
48+
* Python 3.13 - [Install Python 3.13](https://www.python.org/downloads/)
4949
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)
5050

5151
[[top]](#python-test-samples-project)
@@ -172,11 +172,15 @@ The project uses the [moto](http://docs.getmoto.org/en/latest/) dependency libra
172172
# Create and Activate a Python Virtual Environment
173173
174174
pip3 install virtualenv
175-
python3 -m venv venv
175+
python3 -m virtualenv venv
176176
source ./venv/bin/activate
177177
178-
# install dependencies
178+
# Verify Python version (Should show Python 3.13.x)
179+
180+
python3 --version
181+
pip3 --version
179182
183+
# install dependencies
180184
pip3 install -r tests/requirements.txt
181185
182186
# run unit tests with mocks
@@ -202,7 +206,7 @@ The `AWS CLI` enables you to invoke a Lambda function in the cloud.
202206
```shell
203207
# invoke a Lambda function in the cloud using the AWS CLI. Substitute the function name as created in your stack.
204208
205-
aws lambda invoke --function-name apigw-lambda-PythonTestDemo-6Ecinx8IauZv outfile.txt
209+
aws lambda invoke --function-name apigw-lambda-PythonTestDemo-XlkJiaHvJn1t outfile.txt
206210
```
207211
[[top]](#python-test-samples-project)
208212

@@ -218,7 +222,7 @@ sam logs -n PythonTestDemo --stack-name apigw-lambda --tail
218222
In a new terminal, curl the API Gateway and watch the log output.
219223

220224
```shell
221-
curl <API Gateway url>
225+
curl https://<API Gateway deploy>.execute-api.eu-west-1.amazonaws.com/Prod/hello
222226
```
223227

224228
You can find more information and examples about filtering Lambda function logs in the [SAM CLI Documentation](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-logging.html).

python-test-samples/apigw-lambda/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Resources:
2222
Resource: 'arn:aws:s3:::*'
2323
CodeUri: src/
2424
Handler: app.lambda_handler
25-
Runtime: python3.9
25+
Runtime: python3.13
2626
Architectures:
2727
- x86_64
2828
Events:

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

Lines changed: 4 additions & 4 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 # Changed from mock_s3
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 # Changed from @mock_s3
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') # Added region for consistency
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:
@@ -35,4 +35,4 @@ def test_lambda_handler(apigw_event: dict) -> None:
3535
assert test_response["statusCode"] == 200
3636
assert test_bucket_names[0] in test_response_data
3737
assert test_bucket_names[1] in test_response_data
38-
assert len(test_response_data) == 2
38+
assert len(test_response_data) == 2

0 commit comments

Comments
 (0)