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.4b1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c83ddb8ce44a1eefce5c76598fd20416953942161d518e65bfe72b280fbd6f4d |
|
MD5 | 98a0bac081535c8f80e69906255e01a2 |
|
BLAKE2b-256 | 435afe6b6272a08ff769c56869c7eb04c23f7a58dc838ef6b2f710a2806f4e7f |