Skip to main content

DynamoDB fixtures for pytest

Project description

pytest-dynamodb

Latest PyPI version Wheel Status Supported Python Versions License

Package status

Tests Coverage Status Requirements 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

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

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

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-1.0.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

pytest_dynamodb-1.0.0-py2.py3-none-any.whl (11.2 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

File hashes

Hashes for pytest-dynamodb-1.0.0.tar.gz
Algorithm Hash digest
SHA256 722f3795b141454fd48262d0fdc36eea8b7699ff64c18ce8f72d9959d0449e83
MD5 e149cdfa38cca671459a19a8f62e5b6c
BLAKE2b-256 d01d36b843d27f8d389a172d4e782a6a44db18515e82f73ccd779e09ab036bb8

See more details on using hashes here.

File details

Details for the file pytest_dynamodb-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pytest_dynamodb-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 9992dca646437a06995d3c969aec70e01a83ba187a33ef4174d4b93bd1fa03e2
MD5 34af004b4b1e874f4ffc356106f728a3
BLAKE2b-256 04b32efbe0daa71b019dc683c88d7ab6b88332145dac4d46382c6d52e2aba5e6

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