Skip to main content

A set of py.test fixtures for AWS Chalice

Project description

PyPI version Python versions See Build Status on Travis CI

A set of py.test fixtures for AWS Chalice


Features

  • Launch the local gateway per test function
  • Provide an abstracted client fixture to access the local gateway
  • Expose an interface to overwrite response context with arbitrary objects
    • As of Chalice version 1.8.0, LocalGateway object doesn’t handle Cognito’s context
    • Not only for this purpose, it’s an interface provided to allow custom contexts in unit tests

Requirements

Installation

You can install “pytest-chalice” via pip from PyPI:

$ pip install pytest-chalice

Usage

from chalice import Chalice

app = Chalice(__name__)


@app.route('/')
def index:
    return {'hello': 'world'}

pytest-chalice expects a fixture called app which will be the chalice app instance from your project. You can create it in your conftest.py:

import pytest

from chalice import Chalice

from project.app import app as chalice_app


@pytest.fixture
def app() -> Chalice:
    return chalice_app
from http import HTTPStatus


def test_index(client):
    response = client.get('/')
    assert response.status_code == HTTPStatus.OK
    assert response.json == {'hello': 'world'}

See examples for more detailed

Contributing

Contributions are very welcome. Tests can be run with tox, please ensure the coverage at least stays the same before you submit a pull request.

License

Distributed under the terms of the MIT license, “pytest-chalice” is free and open source software

Issues

If you encounter any problems, please file an issue along with a detailed description.

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-chalice-0.0.5.tar.gz (15.0 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page