Skip to main content

pytest plugin for AWS ApiGateway

Project description

pytest-aws-apigateway

PyPI - Version PyPI - Python Version


Rationale

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.

Usage

Add integrations

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://some/")
        assert resp.json() == {"message": "Hello World!"}

License

pytest-aws-apigateway is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest_aws_apigateway-0.7.0.tar.gz (11.0 kB view hashes)

Uploaded Source

Built Distribution

pytest_aws_apigateway-0.7.0-py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page