DynamoDB fixtures for pytest
Project description
pytest-dynamodb
Package 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 |
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 |
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
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
File details
Details for the file pytest-dynamodb-2.2.0.tar.gz
.
File metadata
- Download URL: pytest-dynamodb-2.2.0.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 106279ca7e7fe5b281d5627520399afb96a47d54f41e80fcb9ea4539fb2e1db2 |
|
MD5 | 4ef1184a3be205eebdfacf62a0400bcd |
|
BLAKE2b-256 | 92863efd5e1891e01cb9b14683b04a93bfd95605a89939db6e96e5a385273d7f |
File details
Details for the file pytest_dynamodb-2.2.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_dynamodb-2.2.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54c3774e3e64b8d203adf1f3908a8131a207b48d3a5d6375cba025f321b029bf |
|
MD5 | c082ab66a96a6597fce8ec4216f914d0 |
|
BLAKE2b-256 | 0d3da1c875aefc1aab1b560ec706231d5289fdbc36c9304d7102c4f32cec79af |