Validator plugin for Vedro testing framework
Project description
Vedro Valera Validator
vedro-valera-validator is a plugin for the Vedro framework that utilizes the valera validator, a package designed for data validation based on d42 (district42) schemas. Valera validator provides a simple yet powerful approach to ensure your data aligns perfectly with your expectations.
Installation
Quick
For a quick installation, you can use a plugin manager as follows:
$ vedro plugin install vedro-valera-validator
Manual
To install manually, follow these steps:
- Install the package using pip:
$ pip3 install vedro-valera-validator
- Next, activate the plugin in your
vedro.cfg.py
configuration file:
# ./vedro.cfg.py
import vedro
import vedro_valera_validator
class Config(vedro.Config):
class Plugins(vedro.Config.Plugins):
class ValeraValidator(vedro_valera_validator.ValeraValidator):
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
Additional Resources
For a detailed guide and further information, check out the documentation.
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 vedro_valera_validator-1.2.0.tar.gz
.
File metadata
- Download URL: vedro_valera_validator-1.2.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed09b79a48b0489a265e40ee98a77856145f08d94dbe839db2031ab64425fd20 |
|
MD5 | 01d0eb9e6fb7d377b4d84f023873093b |
|
BLAKE2b-256 | 01401a78b7012ede515a5548ff6b5d0296f996f5faf5f1c4871faff47d34bcc3 |
File details
Details for the file vedro_valera_validator-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: vedro_valera_validator-1.2.0-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ec3027bb4f0806efa298be936226c0b8856615a3320695156512c454b0ea642 |
|
MD5 | 5bacea13f6555c59edaaa79ea848ced6 |
|
BLAKE2b-256 | 3a2d686ff614938ba57ba12c31c52727106cbf70dcd96af98f6b0fc8be5ecc26 |