Pytest plugin for AWS integration tests
Project description
pytest-localstack
pytest-localstack is a plugin for pytest to create AWS integration tests via a Localstack Docker container.
Requires:
pytest >= 3.3.0
Docker
Tested against Python >= 3.6.
Features
Create pytest fixtures that start and stop a Localstack container.
Temporarily patch botocore to redirect botocore/boto3 API calls to Localstack container.
Plugin system to easily extend supports to other AWS client libraries such as aiobotocore.
Example
import boto3
import pytest_localstack
localstack = pytest_localstack.patch_fixture(
services=["s3"], # Limit to the AWS services you need.
scope='module', # Use the same Localstack container for all tests in this module.
autouse=True, # Automatically use this fixture in tests.
)
def test_s3_bucket_creation():
s3 = boto3.resource('s3') # Botocore/boto3 will be patched to use Localstack
assert len(list(s3.buckets.all())) == 0
bucket = s3.Bucket('foobar')
bucket.create()
assert len(list(s3.buckets.all())) == 1
Services
apigateway
cloudformation
cloudwatch
dynamodb
dynamodbstreams
es
firehose
kinesis
lambda
logs
redshift
route53
s3
ses
sns
ssm
sqs
Installation
$ pip install pytest-localstack
TODO
More detailed docs.
Break Docker container running out of LocalstackSession.
Make botocore patching more comprehensible.
Add common test resource fixture factories i.e. S3 buckets, SQS queues, SNS topics, etc.
Test this works for non-localhost Docker containers.
Add other client libraries such as aiobotocore.
Change Log
0.3.0 (2019-07-02)
Add CloudWatch Logs service.
0.2.0 (2019-03-06)
Use botocore to determine default AWS region (will us-east-1 fallback).
Replace use of pytest.config with pytest_configure() hook.
0.1.5 (2018-08-17)
Fix a bug involving our patched botocore Session trying to access _internal_components and getting _components instead.
0.1.4 (2018-08-03)
Fix pinned install requirements conflict between pytest and pluggy.
0.1.3 (2018-07-17)
Fix for botocore >= 1.10.58.
0.1.2 (2018-06-22)
Broke out LocalstackSession into RunningSession which doesn’t start localstack itself.
0.1.1 (2018-04-23)
Fixed bug where patched botocore clients wouldn’t populated the _exceptions attribute.
0.1.0 (2018-03-13)
Initial release
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 pytest_localstack-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fb155fee466b44f08655e7970983700b94855a5b8f17e010e6cc74d0645ee8b |
|
MD5 | 32281f9191e2c2d792a5624125f0ef51 |
|
BLAKE2b-256 | 8a0a3d46780985fe9ec178e3d13eaa023b0babcb5a80e37aa1332584fbd9b04a |