Vedro plugin for integrating d42 schema validation
Project description
Vedro D42 Validator
This plugin integrates d42 schema validation into the Vedro testing framework, providing enhanced schema validation and error handling capabilities during test execution.
Installation
Quick
For a quick installation, you can use a plugin manager as follows:
$ vedro plugin install vedro-d42-validator
Manual
To install manually, follow these steps:
- Install the package using pip:
$ pip3 install vedro-d42-validator
- Next, activate the plugin in your
vedro.cfg.pyconfiguration file:
# ./vedro.cfg.py
import vedro
import vedro_d42_validator
class Config(vedro.Config):
class Plugins(vedro.Config.Plugins):
class D42Validator(vedro_d42_validator.D42Validator):
enabled = True
Usage
Here is an example scenario demonstrating how to decode a base64 encoded string:
# ./scenarios/decode_base64_encoded_string.py
import vedro
from base64 import b64decode
from d42 import schema
class Scenario(vedro.Scenario):
subject = "decode base64 encoded string"
def given(self):
self.encoded = "Y3VjdW1iZXI="
def when(self):
self.result = {
"result": b64decode(self.encoded)
}
def then(self):
assert self.result == schema.dict({
"result": schema.bytes(b"banana")
})
Run the test using the command:
$ vedro run
If the expected and actual results don't match, a ValidationException will be raised, as illustrated below:
ValidationException:
- Value <class 'bytes'> at _['result'] must be equal to b'banana', but b'cucumber' given
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vedro_d42_validator-1.4.0.tar.gz.
File metadata
- Download URL: vedro_d42_validator-1.4.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3ce5ccd2dec9eb9635a9ff282093353fafe671bf2166931dfdda4da19a2aa5e
|
|
| MD5 |
b59e2b6cf3b52fbf7f3911f3d2ea0b2f
|
|
| BLAKE2b-256 |
b8774ea21d55fec3b3637c547402068e1b240c9c918508df892f96996e638f3a
|
File details
Details for the file vedro_d42_validator-1.4.0-py3-none-any.whl.
File metadata
- Download URL: vedro_d42_validator-1.4.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17c6be29a4c4f7c0a9b413204258af648116bfb4a0685f70f591c53a4bb2a9c2
|
|
| MD5 |
a7aad601efe2d7364119a3dbd5a538d2
|
|
| BLAKE2b-256 |
b0a457bc0387c76fa8700739a9b21f7d630cea95a974f0e23bae77129ae13153
|