pytest-db-plugin 0.0.0.0.0.2

Creator: codyrutscher

Last updated:

Add to Cart

Description:

pytestdbplugin 0.0.0.0.0.2

pytest db plugin
uploading test stdout & stderr to a DB for easy debugging and comparison
Installtion

for es db client: pip install pytest-db[es]
for only default (local files) db client: pip install pytest-db

Flow

pytest test ends
pytest test teardown starts
plugin starts
plugin connects to DB
plugin collects all sources
plugin uploads all sources
plugin ends DB connection
plugin ends

Invocation

pytest ...

as long as the plugin is installed, and the url is provided, the plugin will attempt to upload
if the plugin is installed but a config file is not present / malformed / missing url, a warning will be displayed in the end of the test



Configuration

minimal
optional

not having one will not break the test
not having one will mean nothing is uploaded UNLESS the url param is
passed in the invocation command

a default db client will be used in such cases and the data will be written into "/tmp"




will be located in invocation directory
name: ".config.toml"
allows for customizing:

DB url and authentication
DB interaction failure should fail test [default: false]


toml format (see example)
see supported dbs

Compitability

python3.6+
pytest
enables adding additional data. see additional-data

Supported DB

local file system (local)
Elasticsearch (es)

Additional data

each upload can include additional keys and values
the key will be defined in the config file
the value will be defined as a either

const
function that will be invoked in after collecting the doc
supported function languages:

bash
python


config file example:



...
[additional-data]
[additional-data.consts]
name = 'my-name'

[additional-data.bash]
os = 'lsb_release -sr'

[additional-data.python]
current directory = 'import os; print(os.getcwd())'


python functions will be called using exec
bash functions will be called using subprocess.check_output

Config File Example
ES
# optional
title = 'my pytest db plugin config'
user = 'avin'

# required
type = 'es'
url = 'my-url'
index = 'my-index'

# optional
must-upload = true

[additional-data]
[additional-data.consts]
name = 'avin'

[additional-data.bash]
os = 'lsb_release -sr'

[additional-data.python]
current directory = 'import os; print(os.getcwd())'

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.