Skip to main content

DynamoDB fixtures for pytest

Project description

https://raw.githubusercontent.com/ClearcodeHQ/pytest-dynamodb/master/logo.png

pytest-dynamodb

Latest PyPI version Wheel Status Supported Python Versions License

Package status

Tests Coverage Status

What is this?

This is a pytest plugin, that enables you to test your code that relies on a running DynamoDB Database. It allows you to specify fixtures for DynamoDB process and client (resource in AWS boto terms).

How to use

Plugin contains two fixtures

  • dynamodb - it’s a client/resource fixture that has functional scope. After each test it drops tables in DynamoDB.

  • dynamodb_proc - session scoped fixture, that starts DynamoDB instance at it’s first use and stops at the end of the tests.

Simply include one of these fixtures into your tests fixture list.

You can also create additional dynamodb client and process fixtures if you’d need to:

from pytest_dynamodb import factories

dynamodb_my_proc = factories.dynamodb_proc(
    port=None, logsdir='/tmp', delay=True)
dynamodb_my = factories.dynamodb('dynamodb_my_proc')

Configuration

You can define your settings in three ways, it’s fixture factory argument, command line option and pytest.ini configuration option. You can pick which you prefer, but remember that these settings are handled in the following order:

  • Fixture factory argument

  • Command line option

  • Configuration option in your pytest.ini file

Configuration options

DynamoDB option

Fixture factory argument

Command line option

pytest.ini option

Default

Path to dynamodb jar file

dynamodb_dir

–dynamodb-dir

dynamodb_dir

/tmp/dynamodb

host

host

–dynamodb-host

dynamodb_host

127.0.0.1

port

port

–dynamodb-port

dynamodb_port

random

AWS Access Key

access_key

–dynamodb-aws_access_key

dynamodb_aws_access_key

access_key

AWS Secret Key

secret_key

–dynamodb-aws_secret_key

dynamodb_aws_secret_key

secret_key

AWS Region

region

–dynamodb-aws_region

dynamodb_aws_region

us-west-1

Introduce delays

delay

–dynamodb-delay

dynamodb_delay

false

Example usage:

  • pass it as an argument in your own fixture

    dynamodb_proc = factories.dynamodb_proc(
        port=8888)
  • use --dynamodb-port command line option when you run your tests

    py.test tests --dynamodb-port=8888
  • specify your port as dynamodb_port in your pytest.ini file.

    To do so, put a line like the following under the [pytest] section of your pytest.ini:

    [pytest]
    dynamodb_port = 8888

Package resources

CHANGELOG

2.1.0

Misc

  • Rely on get_port functionality delivered by port_for

  • Migrate CI to github actions

  • Support only python 3.7 and up

2.0.1

Bugfix

  • Adjust for mirakuru 2.2.0 and up

2.0.0

  • [feature] Drop support for python 2.7. From now on, only support python 3.6 and up

1.2.0

  • [enhancement] ability to configure aws region and credentials,

1.1.1

  • [enhancement] removed path.py dependency

1.1.0

  • [enhancement] change deprecated getfuncargvalaue to getfixturevalues, require at least pytest 3.0.0

1.0.1

  • [enhancements] set executor timeout to 60. By default mirakuru waits indefinitely, which might cause test hangs

1.0.0

  • create command line and pytest.ini configuration options for introducing delays

  • create command line and pytest.ini configuration options for dynamodb_dir

  • create command line and pytest.ini configuration options for host

  • create command line and pytest.ini configuration options for port

  • Extracted code from pytest-dbfixtures

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-dynamodb-2.1.0.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

pytest_dynamodb-2.1.0-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file pytest-dynamodb-2.1.0.tar.gz.

File metadata

  • Download URL: pytest-dynamodb-2.1.0.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for pytest-dynamodb-2.1.0.tar.gz
Algorithm Hash digest
SHA256 e008193b9770ce5495973d30e293a75e6fc76d8ae3ab47ea3c5ff603acdb4d0d
MD5 8edba54c0132f740eac3f247a6e21ce5
BLAKE2b-256 133dd9d94ad9a21a09197dca1d1e619e93302272517d5c1545267e4c59a467ff

See more details on using hashes here.

File details

Details for the file pytest_dynamodb-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: pytest_dynamodb-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.4.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.5

File hashes

Hashes for pytest_dynamodb-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3454a47b8d9a8343930260046d3fec447641ff2e6026febc6f49f6bae74bd0c6
MD5 ca950e55c63cb8cf8ef55015ecc59d6a
BLAKE2b-256 ee3d5c583f98eb7e421de8b88153bf1748c00c9da5994ec82c92ab1b0564d1b4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page