Metadata-Version: 2.1
Name: pytest-localstack
Version: 0.4.1
Summary: Pytest plugin for AWS integration tests
Home-page: https://github.com/mintel/pytest-localstack
Author: Jaye Doepke
Author-email: jdoepke@mintel.com
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: Pytest
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Utilities
Requires-Dist: botocore (!=1.4.45,>=1.4.31)
Requires-Dist: docker
Requires-Dist: pluggy (>=0.6.0)
Requires-Dist: pytest (>=3.3.0)
Requires-Dist: six
Requires-Dist: contextlib2 ; python_version < "3.3"
Requires-Dist: mock ; python_version < "3.3"
Provides-Extra: test
Requires-Dist: boto3 ; extra == 'test'
Requires-Dist: hypothesis ; extra == 'test'

pytest-localstack
=================

.. image:: https://img.shields.io/pypi/v/pytest-localstack.svg
    :alt: PyPI
    :target: https://pypi.org/project/pytest-localstack/

.. image:: https://img.shields.io/travis/mintel/pytest-localstack/master.svg
    :alt: Travis-CI
    :target: https://travis-ci.org/mintel/pytest-localstack

.. image:: https://img.shields.io/codecov/c/github/mintel/pytest-localstack.svg
    :alt: Codecov
    :target: https://codecov.io/gh/mintel/pytest-localstack

.. image:: https://img.shields.io/github/license/mintel/pytest-localstack.svg
    :target: https://github.com/mintel/pytest-localstack/blob/master/LICENSE

.. image:: https://img.shields.io/github/issues/mintel/pytest-localstack.svg
    :target: https://github.com/mintel/pytest-localstack/issues

.. image:: https://img.shields.io/github/forks/mintel/pytest-localstack.svg
    :target: https://github.com/mintel/pytest-localstack/network

.. image:: https://img.shields.io/github/stars/mintel/pytest-localstack.svg
    :target: https://github.com/mintel/pytest-localstack/stargazers

pytest-localstack is a plugin for pytest_ to create AWS_ integration tests
via a Localstack_ Docker container.

`Read The Docs`_

**Requires:**

- pytest >= 3.3.0
- Docker

Tested against Python >= 3.6.

.. _pytest: http://docs.pytest.org/
.. _AWS: https://aws.amazon.com/
.. _Localstack: https://github.com/localstack/localstack
.. _Read the Docs: https://pytest-localstack.readthedocs.io/


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_.

.. _pytest fixtures: https://docs.pytest.org/en/stable/fixture.html

Example
-------
.. code-block:: python

    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
* ec2
* es
* firehose
* iam
* kinesis
* lambda
* logs
* redshift
* route53
* s3
* secretsmanager
* ses
* sns
* sqs
* ssm
* stepfunctions
* sts

Installation
------------
.. code-block:: bash

    $ 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_.

.. _aiobotocore: https://github.com/aio-libs/aiobotocore


Change Log
==========

0.4.1 (2019-08-22)
------------------

- Raise TimeoutErrors when services fail to start from any causing exception.
- Use more botocore client-based service checks.

0.4.0 (2019-08-21)
------------------

- Add EC2 service.
- Add IAM service.
- Add Secret Manager service.
- Add Step Functions service.
- Add STS service.

0.3.2 (2019-08-16)
------------------

- Track/restore original boto3.DEFAULT_SESSION during patching.


0.3.1 (2019-08-13)
------------------

- Fix exclusion of tests from installed packages.

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


