Python test fixtures for your local AWS cloud stack
Project description
boto3-fixtures
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for boto3_fixtures-0.0.4b2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dd9f3893ffdfa04aded9635b674410c22b753a1b385cd73bb0ccf735458bae2 |
|
MD5 | 11146c38b0fb3742c39ba4bea9230ffd |
|
BLAKE2b-256 | 469bb6c8c3369e34a64d82258ee4f90dc9149d215126ede35d5728d33e971c7c |