pytest_aws_apigateway
is a pytest plugin to make testing AWS Lambda integrations with AWS ApiGateway easier.
It registers AWS Lambda function handlers as callbacks to requests made using httpx
so you can test your
REST API using HTTP requests.
pytest-aws-apigateway
lets you register AWS Lambda function handlers to act just like AWS ApiGateway proxy
integrations.
import httpx
from pytest_aws_apigateway import ApiGatewayMock
def handler(event, context):
return {"statusCode": 200, "body": json.dumps({"message": "Hello World!"})}
def test_hello_world(apigateway_mock: ApiGatewayMock):
apigateway_mock.add_integration(
"/", handler=handler, method="GET", endpoint="https://greetings/"
)
with httpx.Client() as client:
resp = client.get("https://greetings/")
assert resp.json() == {"message": "Hello World!"}
pytest-aws-apigateway
is distributed under the terms of the MIT license.