Metadata-Version: 2.1
Name: pytest-db-plugin
Version: 0.0.0.0.0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: Avi Naftalis
Author-email: avin@hailo.ai
License: UNKNOWN
Platform: UNKNOWN
Classifier: Framework :: Pytest
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Provides-Extra: es

# pytest db plugin
## What
- uploading test stdout & stderr to a DB
## Why
- keeping all stdout & stderr ready in a DB for easy debugging and comparison
## How
### Flow
1. pytest test ends
2. pytest test teardown starts
3. plugin starts
4. plugin connects to DB
5. plugin collects all sources
6. plugin uploads all sources
7. plugin ends DB connection
8. plugin ends
### Installtion
- for default db client: `pip install pytest-db`
- for es db client: `pip install pytest-db[es]`
##### Hosting
- the package will be hosted on global pypi
### 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 additionalizing:
    1. DB url and authentication
    2. DB interaction failure should fail test [default: false]
    3. sources to upload [default: stdout, stderr]
- toml format
```toml
type = <type>
url = <url>
index = <index>
must-upload = false
```
- see [supported dbs](#supported-db)
### Compitability
- python3.6+
- pytest
- enables adding additional data. see [additional-data](#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:
```toml
...
[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`*



