Skip to main content

Python test fixtures for your local AWS cloud stack

Project description

boto3-fixtures

PyPI version TravisCI build status Code Coverage

boto3-fixtures provides test fixtures for your local AWS cloud stack.

Testing software which touches cloud infrastructure doesn't have to be difficult! boto3-fixtures provides a dead-simple framework for setup+teardown of mocked AWS infrastructure. Use in combination with projects like moto or localstack.

Supports

  • Kinesis
  • SQS
  • S3
  • Lambda
  • DynamoDB

Getting Started

This library provides a context decorator, boto3_fixtures.Service, which will setup and teardown AWS services.

from boto3_fixtures import Service

with Service("kinesis", ["my-kinesis-stream"]) as streams:
    # Streams exist

# Streams are destroyed

Combine this with a local testing stack of your choice (moto, localstack).

import boto3, boto3_fixtures, moto

def test_my_code():
    with moto.mock_sqs():
        with boto3_fixtures.Service("sqs", names=["first-queue", "second-queue"]) as queues:
            client = boto3.client("sqs")
            response = client.list_queues()
            assert len(response["QueueUrls"]) == 2

You can create pytest fixtures to simplify this even further.

import pytest, boto3_fixtures, moto

@pytest.fixture
def sqs_queues():
    return ["first-queue", "second-queue"]

@pytest.fixture
def sqs(sqs_queues):
    with moto.mock_sqs():
        with boto3_fixtures.Service("sqs", names=["first-queue", "second-queue"]) as queues:
            yield queues


@pytest.mark.usefixtures("sqs")
def test_my_code():
    # Queues exist for the duration of this test (or whatever scope you set on the fixture)
    pass

WIP

  • Tons more examples
  • pytest plugin/fixtures
  • More AWS services!

Please submit a PR or issue if you'd like to see support for a specific AWS service!

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

boto3-fixtures-0.0.4b1.tar.gz (9.3 kB view hashes)

Uploaded Source

Built Distribution

boto3_fixtures-0.0.4b1-py2.py3-none-any.whl (12.9 kB view hashes)

Uploaded Python 2 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