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
Raw data
{
"_id": null,
"home_page": "https://github.com/mintel/pytest-localstack",
"name": "pytest-localstack",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.0,<4.0.0",
"maintainer_email": "",
"keywords": "pytest,localstack,aws",
"author": "Mintel Group Ltd.",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/07/8f/bac39c3847d027da9683f482145b3ac7595b1eb9b7666d4368cd4d809566/pytest_localstack-0.6.1.tar.gz",
"platform": null,
"description": "pytest-localstack\n=================\n\n.. image:: https://img.shields.io/pypi/v/pytest-localstack.svg\n :alt: PyPI\n :target: https://pypi.org/project/pytest-localstack/\n\n.. image:: https://img.shields.io/travis/mintel/pytest-localstack/master.svg\n :alt: Travis-CI\n :target: https://travis-ci.org/mintel/pytest-localstack\n\n.. image:: https://img.shields.io/codecov/c/github/mintel/pytest-localstack.svg\n :alt: Codecov\n :target: https://codecov.io/gh/mintel/pytest-localstack\n\n.. image:: https://img.shields.io/github/license/mintel/pytest-localstack.svg\n :target: https://github.com/mintel/pytest-localstack/blob/master/LICENSE\n\n.. image:: https://img.shields.io/github/issues/mintel/pytest-localstack.svg\n :target: https://github.com/mintel/pytest-localstack/issues\n\n.. image:: https://img.shields.io/github/forks/mintel/pytest-localstack.svg\n :target: https://github.com/mintel/pytest-localstack/network\n\n.. image:: https://img.shields.io/github/stars/mintel/pytest-localstack.svg\n :target: https://github.com/mintel/pytest-localstack/stargazers\n\npytest-localstack is a plugin for pytest_ to create AWS_ integration tests\nvia a Localstack_ Docker container.\n\n`Read The Docs`_\n\n**Requires:**\n\n- pytest >= 3.3.0\n- Docker\n\nTested against Python >= 3.6.\n\n.. _pytest: http://docs.pytest.org/\n.. _AWS: https://aws.amazon.com/\n.. _Localstack: https://github.com/localstack/localstack\n.. _Read the Docs: https://pytest-localstack.readthedocs.io/\n\n\nFeatures\n--------\n* Create `pytest fixtures`_ that start and stop a Localstack container.\n* Temporarily patch botocore to redirect botocore/boto3 API calls to Localstack container.\n* Plugin system to easily extend supports to other AWS client libraries such as aiobotocore_.\n\n.. _pytest fixtures: https://docs.pytest.org/en/stable/fixture.html\n\nExample\n-------\n.. code-block:: python\n\n import boto3\n import pytest_localstack\n\n localstack = pytest_localstack.patch_fixture(\n services=[\"s3\"], # Limit to the AWS services you need.\n scope='module', # Use the same Localstack container for all tests in this module.\n autouse=True, # Automatically use this fixture in tests.\n )\n\n def test_s3_bucket_creation():\n s3 = boto3.resource('s3') # Botocore/boto3 will be patched to use Localstack\n assert len(list(s3.buckets.all())) == 0\n bucket = s3.Bucket('foobar')\n bucket.create()\n assert len(list(s3.buckets.all())) == 1\n\nServices\n--------\n* apigateway\n* cloudformation\n* cloudwatch\n* dynamodb\n* dynamodbstreams\n* ec2\n* es\n* firehose\n* iam\n* kinesis\n* lambda\n* logs\n* redshift\n* route53\n* s3\n* secretsmanager\n* ses\n* sns\n* sqs\n* ssm\n* stepfunctions\n* sts\n\nInstallation\n------------\n.. code-block:: bash\n\n $ pip install pytest-localstack\n\n\nTODO\n----\n\n* More detailed docs.\n* Break Docker container running out of LocalstackSession.\n* Make botocore patching more comprehensible.\n* Add common test resource fixture factories i.e. S3 buckets, SQS queues, SNS topics, etc.\n* Test this works for non-localhost Docker containers.\n* Add other client libraries such as aiobotocore_.\n\n.. _aiobotocore: https://github.com/aio-libs/aiobotocore\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Pytest plugin for AWS integration tests",
"version": "0.6.1",
"project_urls": {
"Documentation": "https://pytest-localstack.readthedocs.io/",
"Homepage": "https://github.com/mintel/pytest-localstack",
"Repository": "https://github.com/mintel/pytest-localstack"
},
"split_keywords": [
"pytest",
"localstack",
"aws"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "57cec47153bec21d1a210f4337901b97c79b25b2e9654dbcec49b0ac40c3e8d5",
"md5": "b4178745da932390a42b4a3b58b10a50",
"sha256": "0e0f8f2f7d86030f71914e316b2c46cc2f9c924b7e95c0ff34902b58358ddaab"
},
"downloads": -1,
"filename": "pytest_localstack-0.6.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b4178745da932390a42b4a3b58b10a50",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.0,<4.0.0",
"size": 25100,
"upload_time": "2023-06-07T04:32:20",
"upload_time_iso_8601": "2023-06-07T04:32:20.965577Z",
"url": "https://files.pythonhosted.org/packages/57/ce/c47153bec21d1a210f4337901b97c79b25b2e9654dbcec49b0ac40c3e8d5/pytest_localstack-0.6.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "078fbac39c3847d027da9683f482145b3ac7595b1eb9b7666d4368cd4d809566",
"md5": "17649a1c74d8ec0c502ae2a84927a0a4",
"sha256": "fd0928a837ef226882bf51e17c8c69368ccb7e57bdd66a92901e807919f49308"
},
"downloads": -1,
"filename": "pytest_localstack-0.6.1.tar.gz",
"has_sig": false,
"md5_digest": "17649a1c74d8ec0c502ae2a84927a0a4",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.0,<4.0.0",
"size": 20856,
"upload_time": "2023-06-07T04:32:22",
"upload_time_iso_8601": "2023-06-07T04:32:22.802121Z",
"url": "https://files.pythonhosted.org/packages/07/8f/bac39c3847d027da9683f482145b3ac7595b1eb9b7666d4368cd4d809566/pytest_localstack-0.6.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-07 04:32:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mintel",
"github_project": "pytest-localstack",
"travis_ci": true,
"coveralls": false,
"github_actions": false,
"lcname": "pytest-localstack"
}